public class GeojsonUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
openGeoJsonInBrowserWithGeojsonIO(Map<String,org.wololo.geojson.FeatureCollection> featureCollections)
All filename-
Feature pairs will be displayed in your default browser via the
geojson.io website. |
static void |
openGeoJsonInBrowserWithGitHubGist(Map<String,org.wololo.geojson.FeatureCollection> featureCollections)
All filename-
Feature pairs will be displayed in your default browser via the
api.github.com/gists website. |
static List<org.wololo.geojson.Feature> |
transformGeometry(org.opengis.referencing.operation.MathTransform transformer,
org.wololo.geojson.Feature... featuresToTransform)
Transforms geojson geometry between different formats.
|
public static List<org.wololo.geojson.Feature> transformGeometry(org.opengis.referencing.operation.MathTransform transformer, org.wololo.geojson.Feature... featuresToTransform) throws org.opengis.referencing.operation.TransformException
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]));
transformer - transformer initialized with the correct formatsfeaturesToTransform - features that need to be transformed into the target formatorg.opengis.referencing.operation.TransformException - if the geographic projection transformation failspublic static void openGeoJsonInBrowserWithGeojsonIO(Map<String,org.wololo.geojson.FeatureCollection> featureCollections) throws IOException
Feature pairs will be displayed in your default browser via the
geojson.io website. Requires connection to the internet. (Only EPSG:4326 (WGS84) mode tested)featureCollections - map of fileNames to their respective contents (i.e. the FeatureCollection)IOException - if errors during parsing or execution occurredpublic static void openGeoJsonInBrowserWithGitHubGist(Map<String,org.wololo.geojson.FeatureCollection> featureCollections) throws IOException
Feature pairs will be displayed in your default browser via the
api.github.com/gists website. Requires connection to the internet. (Only EPSG:4326 (WGS84) mode tested)
Has sometimes display errors - esp. if multiple FeatureCollections are to be shown in one page. In that case it is
suggested to use openGeoJsonInBrowserWithGeojsonIO(java.util.Map<java.lang.String, org.wololo.geojson.FeatureCollection>).featureCollections - map of fileNames and the respective contents (i.e. the FeatureCollection)IOException - if errors during parsing or execution occurredCopyright © 2017. All rights reserved.