Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/377.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用OpenMap API从shapefile中提取点数据要使用哪个类?_Java_Api_Coldfusion_Shapefile_Openmap - Fatal编程技术网

Java 使用OpenMap API从shapefile中提取点数据要使用哪个类?

Java 使用OpenMap API从shapefile中提取点数据要使用哪个类?,java,api,coldfusion,shapefile,openmap,Java,Api,Coldfusion,Shapefile,Openmap,我目前正在使用Shapefile类和ColdFusion查看每个Shapefile的“记录”。每个记录都有一个边界框,我能够获得这些信息,但还没有找到一种方法来实际检索每个记录中的点 有人能告诉我们应该使用哪些类以及如何使用它们吗 这与以下情况完全相同(包括一些措辞): 尽管我使用的是ColdFusion,但我相信对解决方案的任何提示都会对我有很大帮助 我目前的测试代码如下: <cfset shapeFile = createObject("java","com.bbn.openmap.

我目前正在使用Shapefile类和ColdFusion查看每个Shapefile的“记录”。每个记录都有一个边界框,我能够获得这些信息,但还没有找到一种方法来实际检索每个记录中的点

有人能告诉我们应该使用哪些类以及如何使用它们吗

这与以下情况完全相同(包括一些措辞):

尽管我使用的是ColdFusion,但我相信对解决方案的任何提示都会对我有很大帮助

我目前的测试代码如下:

<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()#"> 

getFileLength=#shapeFile.getFileLength()#
getFileVersion=#shapeFile.getFileVersion()#
getShapeType=#shapeFile.getShapeType()#
toString=#shapeFile.toString()#


我从来没有使用过这个,也没有做过任何GIS,但是在看了API之后,我的建议如下

因此,在获得shapefile后,您将:

myESRIRecord = shapeFile.getNextRecord();
这将获得一个类或其子类,具体取决于它的形状类型

为了弄明白这一点,我处理过的形状文件是:

并且只包含类型

ESRIPolygonRecord包含一个名为“polygons”的属性,该属性包含com.bbn.openmap.layer.shape.ESRIPoly$ESRIFLOATPLY实例数组

这个库的关键似乎是很多数据都在属性中,无法通过方法访问

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

这个示例代码对我很有用:

<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>

此多边形具有#thisPoly.nPoints#点:
X:#thisPoly.getX(i)#Y:#thisPoly.getY(i)#

也许您可以直接从他们那里获得支持?这非常有效,我不得不改变BlueDragon的一些情况,因为cfloop不支持数组属性,但效果很好。万分感谢!我很高兴你能成功!这个问题让我有兴趣在这个库中玩得更多!