1

現在、Shapefile クラスと ColdFusion を使用して、各シェープファイルの「レコード」を調べています。各レコードには境界ボックスがあり、この情報を取得できますが、各レコード内のポイントを実際に取得する方法が見つかりません。

どのクラスを使用し、どのように使用するかについて、誰かが光を当てることができますか?

これは、次の場合とまったく同じ状況です (多少の言い回しを含む)。

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

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

1 に答える 1

2

私はこれを使用したことも、GIS を実行したこともありませんが、API を見た後、ここに私の提案があります。

したがって、シェープファイルを取得したら、次のようにします。

myESRIRecord = shapeFile.getNextRecord();

これにより、形状のタイプに応じて、 ESRIRecordクラスまたはそのサブクラスの 1 つが取得されます。

これを理解するために私が台無しにしたシェープファイルは次のとおりです。

http://russnelson.com/india.zip

ポリゴンタイプのみが含まれます。

ESRIPolygonRecord には、com.bbn.openmap.layer.shape.ESRIPoly$ESRIFloatPoly インスタンスの配列を含む「polygons」というプロパティが含まれています。

このライブラリの重要な点は、多くのデータがプロパティにあり、メソッドを介してアクセスできないことです。

前述したように、ESRIPolygonRecords のデータは polygons プロパティにあり、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>
于 2010-09-17T22:27:28.760 に答える