johnpoole

side location bug

Feb 13th, 2012
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 1.06 KB | None | 0 0
  1. CRSEnvelope envelope = null;
  2. try {
  3. // Convert a bbox and crs to a JTS geometry in EPSG:4326
  4.  envelope = CRSUtility.reprojectBBox(bbox, crs,
  5.  Globals.DEFAULT_EPSG_CODE);
  6. } catch (Exception e) {
  7.  envelope = new CRSEnvelope(Globals.DEFAULT_EPSG_CODE,
  8.  Globals.MIN_LONGITUDE, Globals.MIN_LATITUDE,
  9.  Globals.MAX_LONGITUDE, Globals.MAX_LATITUDE);
  10. }
  11. Geometry bboxGeometry = GeometryUtility.convertCRSEnvelope(envelope);
  12.  
  13. public static Polygon convertCRSEnvelope(CRSEnvelope envelope) {
  14.         Coordinate swCoord = new Coordinate(envelope.getMinX(), envelope.getMinY());
  15.         Coordinate nwCoord = new Coordinate(envelope.getMinX(), envelope.getMaxY());
  16.         Coordinate neCoord = new Coordinate(envelope.getMaxX(), envelope.getMaxY());
  17.         Coordinate seCoord = new Coordinate(envelope.getMaxX(), envelope.getMinY());
  18.         Coordinate[] coordinates = {swCoord, nwCoord, neCoord, seCoord, swCoord};
  19.         GeometryFactory factory = new GeometryFactory();
  20.         LinearRing simpleRing = new LinearRing(new CoordinateArraySequence(coordinates), factory);
  21.         return new Polygon(simpleRing, null, factory);
  22.     }
Advertisement
Add Comment
Please, Sign In to add comment