0
GeoTools 및 해당 OGR Plugin을 사용하여 Java에서 MapInfo MAP 파일을 읽으려고합니다. 특정 정렬 순서로 기능을 반복하고 싶습니다. 이 목적으로 GeoTool의 Query와 SortBy를 사용하려하지만 생성 된 SQL 쿼리에 구문 오류가 있습니다.GeoTools Query with SortBy : 생성 된 SQL 구문이 잘못되었습니다.
코드 샘플 :
OGRDataStoreFactory factory = new JniOGRDataStoreFactory();
Map<String, String> connectionParams = new HashMap<String, String>();
connectionParams.put("DriverName", "MapInfo File");
connectionParams.put("DatasourceName", new File("MyTable.TAB").getAbsolutePath());
DataStore store = factory.createDataStore(connectionParams);
SimpleFeatureSource featureSource = store.getFeatureSource("MyTable");
Query query = new Query();
query.setSortBy(new SortBy[]{ new SortByImpl(new AttributeExpressionImpl("PED"), SortOrder.ASCENDING)});
SimpleFeatureIterator features = featureSource.getFeatures(query).features();
int count = 0;
while (features.hasNext() && count++ < 10) {
Feature feature = features.next();
System.out.println(feature);
}
이 stderr에 인쇄이 오류 메시지가 발생합니다
ERROR 1: SQL Expression Parsing Error: syntax error, unexpected ORDER, expecting '.'. Occurred around :
SELECT FID, * FROM 'MyTable' ORDER BY PED
^
문제는 테이블 이름 주위에 따옴표입니다.
setSortBy()
행을 제거하면 기능이 반환됩니다. 따라서 일반적으로 데이터 액세스가 작동합니다.
내가 기대가로 작동 따옴표와 명령 줄에서 ogr2ogr
를 사용하여 동일한 쿼리를 시도 할 경우 :
ogr2ogr -f "CSV" /vsistdout/ MyTable.TAB -lco GEOMETRY=AS_WKT -sql "SELECT FID, * FROM \"MyTable\" ORDER BY \"PED\" ASC"
내가 뭔가 잘못하고 오전?