2011-05-19 267 views

回答

2

我不確定geotools是否提供了這個功能。但是,JTS中有一個與Geotools和Neo4j-Spatial都有關的地方。查看JTS包com.vividsolutions.linearref,它具有用於搜索點的線性幾何圖形或點的創建/投影的類。我認爲方法LengthIndexedLine.extractPoint(長度)可能是你在找什麼。

在Neo4j-Spatial中,我們有一個實用程序,它使用LocationIndexedLine(但尚未包含LengthIndexedLine)。請參閱TestSpatialUtils中的測試代碼以及​​它在SpatialTopologyUtils中調用的代碼。

今年還有兩個Google Summer of Code項目正在研究與此相關的功能。其中一個是Geoprocessing,我們將在Neo4j-Spatial中用一個簡單的API公開這些類型的函數。另一個更多的是關於OSM數據模型的數據挖掘,但也可能涉及這些功能。有關更多信息,請觀看neo4j和udig郵件列表。到夏天結束時,我們將在Neo4j-Spatial中提供更豐富的地理處理功能。

+0

謝謝你,Craig Taverner! – 2011-08-14 07:15:14

+0

但SRID = 4326,結果錯誤。 – 2011-08-15 05:33:09

1

我只是將一些代碼推送到Neoj4-Spatial以將JTS方法LengthIndexedLine.extractPoint與新方法locatePoint相比較,該方法的行爲與Oracle SDO_LRS.LOCATE_PT方法相同。所以,至少在主幹上,Neo4j-Spatial現在具有這種能力。實際上,這個代碼很簡單,因爲它包裝了JTS代碼,所以功能一直存在,但現在看起來更像Oracle API。

前面提到的GSoC項目將嘗試在某種程度上對API進行標準化,以便以直觀的方式提供更完整的一組功能。

0
PrecisionModel precisionModel = new PrecisionModel(PrecisionModel.FLOATING_SINGLE); 
    GeometryFactory geometryFactory = new GeometryFactory(precisionModel, 0); 
    Coordinate[] coordinates = new Coordinate[3]; 
    coordinates[0] = new Coordinate(0, 0); 
    coordinates[1] = new Coordinate(5, 5); 
    coordinates[2] = new Coordinate(10, 0); 
    CoordinateSequence coordinateSequence = new CoordinateArraySequence(coordinates); 
    Geometry geo = new LineString(coordinateSequence, geometryFactory); 
    LengthLocationMap lengthLocationMap = new LengthLocationMap(geo); 
    LocationIndexedLine locationIndexedLine = new LocationIndexedLine(geo); 
    LinearLocation linearLocation = lengthLocationMap.getLocation(len); 
    Coordinate result = locationIndexedLine.extractPoint(linearLocation);