當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。