本文介绍了使用OpenMap API我使用哪个类从shape文件中提取点数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用的Shapefile类和ColdFusion要经过的每个shape文件的记录。每个记录有一个边界框,我能够得到这个信息,但还没有找到一种方法,实际上检索每个记录中的点。

有人可以提供一些线索对哪些类使用以及如何使用它们?

这是完全相同的情况(包括一些verbage)为:

Allthough我使用ColdFusion,我不相信任何提示,该解决方案将帮助我很大。

我目前的测试code是如下:

 < CFSET shape文件=的CreateObject(Java的,com.bbn.openmap.layer.shape.ShapeFile)>< CFSET shapeFile.init('/ WWW / _Dev / tl_2009_25_place.shp')><&CFOUTPUT GT;
 getFileLength =#shapeFile.getFileLength()#< BR>
 getFileVersion =#shapeFile.getFileVersion()#< BR>
 getShapeType =#shapeFile.getShapeType()#< BR>
 的toString =#shapeFile.toString()#< BR>
< / CFOUTPUT>
< cfdump VAR =#SHAPEFILE#>
&所述; cfdump变种=#shapeFile.getBoundingBox()#> < BR>
&所述; cfdump变种=#shapeFile.getNextRecord()#>


解决方案

我从来没有用过这个,或者做任何GIS,但看着API后,这里是我的建议。

所以,以后你有你的Shape文件,您可以:

  myESRIRecord = shapeFile.getNextRecord();

这可以让你的

和仅包含类型。

该ESRIPolygonRecord包含一个名为多边形的属性,其中包含com.bbn.openmap.layer.shape.ESRIPoly $ ESRIFloatPoly实例的数组。

与此库的关键,似乎是很多数据是在性能,通过方法不能访问。

因此​​,正如我说的,ESRIPolygonRecords有其多边形特性数据,该ESRIPointRecord有其在x和y属性数据。所以,如果你正在寻找一个的getX()或的getY(),这就是为什么你没有找到它。

本示例code为我工作:

 < CFSET shape文件=的CreateObject(Java的,com.bbn.openmap.layer.shape.ShapeFile)>< CFSET shapeFile.init('/ tmp目录/印度12-05.shp')><!---可能有一个以上的记录,所以你可以重复这一点,或循环得到
      更多的记录--->
< CFSET myRecord = shapeFile.getNextRecord()><!---获取,使这项纪录---&GT的多边形;
< CFSET富= myRecord.polygons>< cfdump VAR =#富#>< CFLOOP阵列=#富#指数=thispoly>
<&CFOUTPUT GT;
    这种聚有#thisPoly.nPoints#几点:< BR>
    <!---因为Java数组都是基于0 --->
    &所述; CFSET loopEnd = thisPoly.nPoints-1。>
    < CFLOOP从=0=#loopEnd#指数=我>
        X:#thisPoly.getX(我)#Y:#thisPoly.getY(我)#< BR>
    < / CFLOOP>
    <!---返回点作为阵列--->
    &所述; cfdump变种=#thisPoly.getDecimalDegrees()#>
    &所述; cfdump变种=#thisPoly.getRadians()#>
< / CFOUTPUT>
< / CFLOOP>

I am currently using Shapefile class and ColdFusion to go through the "records" of each shapefile. Each record has a bounding box and i am able to get this information but havent found a way to actually retrieve the points inside each record.

Can someone shed some light on which classes to use and how to use them?

This is the exact same situation(including some verbage) as:

http://old.nabble.com/what-class-do-you-use-to-extract-data-from-.SHP-files--td20208204.html

Allthough I am using ColdFusion, I do believe that any hints to the solution would help me greatly.

My current test code is as follows:

<cfset shapeFile = createObject("java","com.bbn.openmap.layer.shape.ShapeFile")>

<cfset shapeFile.init('/www/_Dev/tl_2009_25_place.shp')>

<cfoutput>
 getFileLength = #shapeFile.getFileLength()#<br>
 getFileVersion = #shapeFile.getFileVersion()#<br>
 getShapeType = #shapeFile.getShapeType()#<br>
 toString = #shapeFile.toString()#<br>
</cfoutput>
<cfdump var="#shapeFile#">
<cfdump var="#shapeFile.getBoundingBox()#"> <br>
<cfdump var="#shapeFile.getNextRecord()#">
解决方案

I've never used this, or done any GIS, but after looking at the API, here's my suggestion.

So, after you have your shapefile, you would:

myESRIRecord = shapeFile.getNextRecord();

This gets you an ESRIRecord class or one of its subclasses, depending on what type of shape it is.

The shapefile I've messed with to figure this out is:

http://russnelson.com/india.zip

And only contains polygon types.

The ESRIPolygonRecord contains a property called "polygons" which contains an array of com.bbn.openmap.layer.shape.ESRIPoly$ESRIFloatPoly instances.

The key with this library, it seems, is that a lot of the data is in properties, not accessible through methods.

So, as I said, the ESRIPolygonRecords has its data in the polygons property, the ESRIPointRecord has its data in the x and y properties. So, if you were looking for a getX() or getY(), thats why you didn't find it.

This sample code worked for me:

<cfset shapeFile = createObject("java","com.bbn.openmap.layer.shape.ShapeFile")>

<cfset shapeFile.init('/tmp/india-12-05.shp')>

<!--- There may be more then one record, so you can repeat this, or loop to get
      more records --->
<cfset myRecord = shapeFile.getNextRecord()>

<!--- Get the polygons that make up this record --->
<cfset foo = myRecord.polygons>

<cfdump var="#foo#">

<cfloop array="#foo#" index="thispoly">
<cfoutput>
    This poly has #thisPoly.nPoints# points:<br>
    <!--- because java arrays are 0 based --->
    <cfset loopEnd = thisPoly.nPoints-1>
    <cfloop from="0" to="#loopEnd#" index="i">
        X: #thisPoly.getX(i)#   Y: #thisPoly.getY(i)#<br>
    </cfloop>
    <!--- Returns points as array --->
    <cfdump var="#thisPoly.getDecimalDegrees()#">
    <cfdump var="#thisPoly.getRadians()#">
</cfoutput>
</cfloop>

这篇关于使用OpenMap API我使用哪个类从shape文件中提取点数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 13:37
查看更多