-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
153 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
api/src/main/java/datawave/microservice/map/geojson/GeoJSON.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package datawave.microservice.map.geojson; | ||
|
||
import java.io.IOException; | ||
|
||
import org.geotools.feature.FeatureCollection; | ||
import org.geotools.geojson.feature.FeatureJSON; | ||
import org.geotools.geojson.geom.GeometryJSON; | ||
import org.locationtech.jts.geom.Geometry; | ||
import org.opengis.feature.Feature; | ||
import org.opengis.feature.simple.SimpleFeature; | ||
import org.opengis.referencing.crs.CoordinateReferenceSystem; | ||
|
||
/** | ||
* This is copied from org.geotools.geojson.GeoJSON, but increases the number of decimals to print. | ||
*/ | ||
public class GeoJSON { | ||
static final int DECIMALS = 7; | ||
static GeometryJSON gjson = new GeometryJSON(DECIMALS); | ||
static FeatureJSON fjson = new FeatureJSON(new GeometryJSON(DECIMALS)); | ||
|
||
public static Object read(Object input) throws IOException { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
public static void write(Object obj, Object output) throws IOException { | ||
if (obj instanceof Geometry) { | ||
gjson.write((Geometry) obj, output); | ||
} else if (obj instanceof Feature || obj instanceof FeatureCollection || obj instanceof CoordinateReferenceSystem) { | ||
|
||
if (obj instanceof SimpleFeature) { | ||
fjson.writeFeature((SimpleFeature) obj, output); | ||
} else if (obj instanceof FeatureCollection) { | ||
fjson.writeFeatureCollection((FeatureCollection) obj, output); | ||
} else if (obj instanceof CoordinateReferenceSystem) { | ||
fjson.writeCRS((CoordinateReferenceSystem) obj, output); | ||
} else { | ||
throw new IllegalArgumentException("Unable able to encode object of type " + obj.getClass()); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.