本文整理汇总了Java中org.wololo.jts2geojson.GeoJSONWriter.write方法的典型用法代码示例。如果您正苦于以下问题:Java GeoJSONWriter.write方法的具体用法?Java GeoJSONWriter.write怎么用?Java GeoJSONWriter.write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.wololo.jts2geojson.GeoJSONWriter
的用法示例。
在下文中一共展示了GeoJSONWriter.write方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: geometryToGeoJson
import org.wololo.jts2geojson.GeoJSONWriter; //导入方法依赖的package包/类
public static ClobType geometryToGeoJson(GeometryType geometry)
throws FunctionExecutionException {
Geometry jtsGeometry = getGeometry(geometry);
GeoJSONWriter writer = new GeoJSONWriter();
try {
GeoJSON geoJson = writer.write(jtsGeometry);
ClobType result = new ClobType(new ClobImpl(geoJson.toString()));
result.setType(Type.JSON);
return result;
} catch (Exception e) {
throw new FunctionExecutionException(e);
}
}
示例2: transformGeometry
import org.wololo.jts2geojson.GeoJSONWriter; //导入方法依赖的package包/类
/**
* Transforms geojson geometry between different formats. Usage example:
* <pre>
* FeatureCollection featureCollectionIn3857 = ... //e.g. from the route service
* //Preparing transformer
* CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:3857"); //Web Mercartor
* CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:4326"); //WGS84
* MathTransform transformer = CRS.findMathTransform(sourceCRS, targetCRS);
* //Do transformation from EPSG:3857 (Web Mercartor) to EPSG:4326 (WGS84)
* FeatureCollection featureCollectionIn4326 = new FeatureCollection(
* GeojsonUtil.transformGeometry(featureCollectionIn3857,transformer).toArray(new Feature[0]));
* </pre>
*
* @param transformer transformer initialized with the correct formats
* @param featuresToTransform features that need to be transformed into the target format
* @return Zero or more transformed geometry features
* @throws TransformException if the geographic projection transformation fails
*/
public static List<Feature> transformGeometry(MathTransform transformer, Feature... featuresToTransform) throws TransformException {
List<Feature> featureList = new ArrayList<>(featuresToTransform.length);
for (Feature feature : featuresToTransform) {
GeoJSONReader reader = new GeoJSONReader();
Geometry geometry = reader.read(feature.getGeometry());
geometry = JTS.transform(geometry, transformer);
GeoJSONWriter writer = new GeoJSONWriter();
org.wololo.geojson.Geometry json = writer.write(geometry);
featureList.add(new Feature(json, feature.getProperties()));
}
return featureList;
}