本文整理汇总了Java中org.geotools.data.Query.setCoordinateSystemReproject方法的典型用法代码示例。如果您正苦于以下问题:Java Query.setCoordinateSystemReproject方法的具体用法?Java Query.setCoordinateSystemReproject怎么用?Java Query.setCoordinateSystemReproject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.geotools.data.Query
的用法示例。
在下文中一共展示了Query.setCoordinateSystemReproject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: adaptQuery
import org.geotools.data.Query; //导入方法依赖的package包/类
/**
* Transforms the query applying the definition query in this layer, removes reprojection
* since data stores cannot be trusted
* @param query
* @param schema TODO
*
* @throws IOException
*/
protected Query adaptQuery(Query query, SimpleFeatureType schema) throws IOException {
// if needed, reproject the filter to the native srs
Query newQuery = makeDefinitionQuery(query, schema);
// // see if the CRS got xfered over
// // a. old had a CRS, new doesnt
// boolean requireXferCRS = (newQuery.getCoordinateSystem() == null)
// && (query.getCoordinateSystem() != null);
//
// if ((newQuery.getCoordinateSystem() != null) && (query.getCoordinateSystem() != null)) {
// //b. both have CRS, but they're different
// requireXferCRS = !(newQuery.getCoordinateSystem().equals(query.getCoordinateSystem()));
// }
//
// if (requireXferCRS) {
// //carry along the CRS
// if (!(newQuery instanceof Query)) {
// newQuery = new Query(newQuery);
// }
//
// ((Query) newQuery).setCoordinateSystem(query.getCoordinateSystem());
// }
//JD: this is a huge hack... but its the only way to ensure that we
// we get what we ask for ... which is not reprojection, since
// datastores are unreliable in this aspect we dont know if they will
// reproject or not.
// AA: added force coordinate system reset as well, since we cannot
// trust GT2 datastores there neither.
if ( newQuery.getCoordinateSystemReproject() != null ) {
newQuery.setCoordinateSystemReproject(null);
}
if ( newQuery.getCoordinateSystem() != null ) {
newQuery.setCoordinateSystem(null);
}
return newQuery;
}
示例2: load
import org.geotools.data.Query; //导入方法依赖的package包/类
public void load (ShapeDataStore store) throws Exception {
FileDataStore fds = FileDataStoreFinder.getDataStore(shapefile);
SimpleFeatureSource src = fds.getFeatureSource();
Query q = new Query();
q.setCoordinateSystem(src.getInfo().getCRS());
q.setCoordinateSystemReproject(CRS.decode("EPSG:4326", true));
SimpleFeatureCollection sfc = src.getFeatures(q);
for (SimpleFeatureIterator it = sfc.features(); it.hasNext();) {
GeobufFeature feat = new GeobufFeature(it.next());
feat.id = null;
feat.numericId = Long.parseLong((String) feat.properties.get("GEOID10"));
feat.properties = new HashMap<>();
store.add(feat);
}
}