2017-04-21 25 views
1

geotools 라이브러리로 작업하고 있습니다. 내 목표는 좌표를 입력하고 그것을 반환하는 기능의 정보를 포함하는 것입니다.Geotools 가져 오기 기능 정보

Geotools 빠른 시작 자습서지도는 내가 빨간색으로 동그란 버튼으로 원하는 것을 정확히 수행합니다. 그러나 사용 된 방법을 찾을 수 없습니다.

나는 봤는데, 문서를 읽고 아무 ​​소용이 코드를 디버깅. 이 메서드는 이동하는 방법 인 것 같습니다. FeatureCollection myCollection = mySimpleFeatureSource.getFeatures (쿼리 쿼리);

또는

FeatureCollection myCollection = mySimpleFeatureSource.getFeatures (필터 filter);

그러나 나는 그것을 알아 내지 못했거나 아직 좌표로 쿼리하는 방법을 찾지 못했습니다. 누구든지 손을 빌려 주면, 나는 그것을 매우 고맙게 생각합니다!

미리 감사드립니다.

enter image description here

내가 실행 해요 예는 다음과 같습니다

package org.geotools.tutorial.quickstart; import java.io.File; import org.geotools.data.FileDataStore; import org.geotools.data.FileDataStoreFinder; import org.geotools.data.simple.SimpleFeatureSource; import org.geotools.map.FeatureLayer; import org.geotools.map.Layer; import org.geotools.map.MapContent; import org.geotools.styling.SLD; import org.geotools.styling.Style; import org.geotools.swing.JMapFrame; import org.geotools.swing.data.JFileDataStoreChooser; /** * Prompts the user for a shapefile and displays the contents on the screen in a map frame. * <p> * This is the GeoTools Quickstart application used in documentationa and tutorials. * */ public class Quickstart { /** * GeoTools Quickstart demo application. Prompts the user for a shapefile and displays its * contents on the screen in a map frame */ public static void main(String[] args) throws Exception { // display a data store file chooser dialog for shapefiles File file = JFileDataStoreChooser.showOpenFile("shp", null); if (file == null) { return; } FileDataStore store = FileDataStoreFinder.getDataStore(file); SimpleFeatureSource featureSource = store.getFeatureSource(); // Create a map content and add our shapefile to it MapContent map = new MapContent(); map.setTitle("Quickstart"); Style style = SLD.createSimpleStyle(featureSource.getSchema()); Layer layer = new FeatureLayer(featureSource, style); map.addLayer(layer); // Now display the map JMapFrame.showMap(map); } }

답변

1

이상적으로 완료 한 후 QuickStart 당신이 other tutorials을 통해 작동 그래서 Query Tutorial에 와서해야합니다. 여기서는 간단한 Filter을 만드는 방법과 더 복잡한 Query (정렬 순서가있는 필터에 추가, 속성의 하위 집합 등)을 만드는 방법을 소개합니다. 당신의 기능은 기하학이

Filter f = CQL.toFilter("contains(the_geom,Point("+p.x+" "+p.y+"))"); 

the_geomp는 점이다 속성 :

그래서 가장 쉬운 방법은 일반적인 쿼리 언어 (CQL) 정적 toFilter 방법을 사용하는 것입니다 간단한 필터를 만들 수 있습니다.

찾으시는 작은 도구는 InfoTool이며 FilterFeatureLayerHelper에 생성됩니다.