Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CRSEnvelope envelope = null;
- try {
- // Convert a bbox and crs to a JTS geometry in EPSG:4326
- envelope = CRSUtility.reprojectBBox(bbox, crs,
- Globals.DEFAULT_EPSG_CODE);
- } catch (Exception e) {
- envelope = new CRSEnvelope(Globals.DEFAULT_EPSG_CODE,
- Globals.MIN_LONGITUDE, Globals.MIN_LATITUDE,
- Globals.MAX_LONGITUDE, Globals.MAX_LATITUDE);
- }
- Geometry bboxGeometry = GeometryUtility.convertCRSEnvelope(envelope);
- public static Polygon convertCRSEnvelope(CRSEnvelope envelope) {
- Coordinate swCoord = new Coordinate(envelope.getMinX(), envelope.getMinY());
- Coordinate nwCoord = new Coordinate(envelope.getMinX(), envelope.getMaxY());
- Coordinate neCoord = new Coordinate(envelope.getMaxX(), envelope.getMaxY());
- Coordinate seCoord = new Coordinate(envelope.getMaxX(), envelope.getMinY());
- Coordinate[] coordinates = {swCoord, nwCoord, neCoord, seCoord, swCoord};
- GeometryFactory factory = new GeometryFactory();
- LinearRing simpleRing = new LinearRing(new CoordinateArraySequence(coordinates), factory);
- return new Polygon(simpleRing, null, factory);
- }
Advertisement
Add Comment
Please, Sign In to add comment