当前位置: 首页>>代码示例>>Java>>正文


Java GeoJSONWriter类代码示例

本文整理汇总了Java中org.wololo.jts2geojson.GeoJSONWriter的典型用法代码示例。如果您正苦于以下问题:Java GeoJSONWriter类的具体用法?Java GeoJSONWriter怎么用?Java GeoJSONWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GeoJSONWriter类属于org.wololo.jts2geojson包,在下文中一共展示了GeoJSONWriter类的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);
    }
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:14,代码来源:GeometryUtils.java

示例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;
}
 
开发者ID:route360,项目名称:r360-java,代码行数:33,代码来源:GeojsonUtil.java


注:本文中的org.wololo.jts2geojson.GeoJSONWriter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。