@Test public void testQueryWrappingPacificMercator() throws Exception { CoordinateReferenceSystem crs = CRS.decode("EPSG:3832"); ReferencedEnvelope mercatorEnvelope = new ReferencedEnvelope(1113195, 5565975, 0, 4838471, crs); ProjectionHandler handler = ProjectionHandlerFinder.getHandler(mercatorEnvelope, WGS84, true); List<ReferencedEnvelope> envelopes = handler.getQueryEnvelopes(); assertEquals(2, envelopes.size()); ReferencedEnvelope reOrig = envelopes.get(0); assertEquals(160.0, reOrig.getMinX(), EPS); assertEquals(180.0, reOrig.getMaxX(), EPS); ReferencedEnvelope reAdded = envelopes.get(1); assertEquals(-180.0, reAdded.getMinX(), EPS); assertEquals(-160.0, reAdded.getMaxX(), EPS); }
public List<ReferencedEnvelope> getQueryEnvelopes() throws TransformException, FactoryException { CoordinateReferenceSystem renderingCRS = renderingEnvelope.getCoordinateReferenceSystem(); if (!queryAcrossDateline) { ReferencedEnvelope envelope = transformEnvelope(renderingEnvelope, sourceCRS); if (envelope == null) return Collections.emptyList(); return Collections.singletonList(envelope); } if (renderingCRS instanceof GeographicCRS && !CRS.equalsIgnoreMetadata(renderingCRS, WGS84)) { ReferencedEnvelope re = renderingEnvelope; List<ReferencedEnvelope> envelopes = new ArrayList<ReferencedEnvelope>(); addTransformedEnvelope(re, envelopes); if (CRS.getAxisOrder(renderingCRS) == CRS.AxisOrder.NORTH_EAST) { if (re.getMinY() >= -180.0 && re.getMaxY() <= 180) { return envelopes; } adjustEnvelope(re, envelopes, true); } else { if (re.getMinX() >= -180.0 && re.getMaxX() <= 180) { ReferencedEnvelope envelope = transformEnvelope(renderingEnvelope, sourceCRS); if (envelope == null) return Collections.emptyList(); return Collections.singletonList(envelope); } adjustEnvelope(re, envelopes, true); } mergeEnvelopes(envelopes); return envelopes; } else { if (!Double.isNaN(datelineX) && renderingEnvelope.getMinX() < datelineX && renderingEnvelope.getMaxX() > datelineX && renderingEnvelope.getWidth() < targetHalfCircle) { double minX = renderingEnvelope.getMinX(); double minY = renderingEnvelope.getMinY(); double maxX = renderingEnvelope.getMaxX(); double maxY = renderingEnvelope.getMaxY(); ReferencedEnvelope re1 = new ReferencedEnvelope(minX, datelineX - EPS, minY, maxY, renderingCRS); List<ReferencedEnvelope> result = new ArrayList<ReferencedEnvelope>(); ReferencedEnvelope tx1 = transformEnvelope(re1, WGS84); if (tx1 != null) { tx1.expandToInclude(180, tx1.getMinY()); addTransformedEnvelope(tx1, result); } ReferencedEnvelope re2 = new ReferencedEnvelope(datelineX + EPS, maxX, minY, maxY, renderingCRS); ReferencedEnvelope tx2 = transformEnvelope(re2, WGS84); if (tx2 != null) { if (tx2.getMinX() > 180) { tx2.translate(-360, 0); } tx2.expandToInclude(-180, tx1.getMinY()); addTransformedEnvelope(tx2, result); } mergeEnvelopes(result); return result; } else { return getSourceEnvelopes(renderingEnvelope); } } }
ProjectionHandler { public List<ReferencedEnvelope> getQueryEnvelopes() throws TransformException, FactoryException { CoordinateReferenceSystem renderingCRS = renderingEnvelope.getCoordinateReferenceSystem(); if (!queryAcrossDateline) { ReferencedEnvelope envelope = transformEnvelope(renderingEnvelope, sourceCRS); if (envelope == null) return Collections.emptyList(); return Collections.singletonList(envelope); } if (renderingCRS instanceof GeographicCRS && !CRS.equalsIgnoreMetadata(renderingCRS, WGS84)) { ReferencedEnvelope re = renderingEnvelope; List<ReferencedEnvelope> envelopes = new ArrayList<ReferencedEnvelope>(); addTransformedEnvelope(re, envelopes); if (CRS.getAxisOrder(renderingCRS) == CRS.AxisOrder.NORTH_EAST) { if (re.getMinY() >= -180.0 && re.getMaxY() <= 180) { return envelopes; } adjustEnvelope(re, envelopes, true); } else { if (re.getMinX() >= -180.0 && re.getMaxX() <= 180) { ReferencedEnvelope envelope = transformEnvelope(renderingEnvelope, sourceCRS); if (envelope == null) return Collections.emptyList(); return Collections.singletonList(envelope); } adjustEnvelope(re, envelopes, true); } mergeEnvelopes(envelopes); return envelopes; } else { if (!Double.isNaN(datelineX) && renderingEnvelope.getMinX() < datelineX && renderingEnvelope.getMaxX() > datelineX && renderingEnvelope.getWidth() < targetHalfCircle) { double minX = renderingEnvelope.getMinX(); double minY = renderingEnvelope.getMinY(); double maxX = renderingEnvelope.getMaxX(); double maxY = renderingEnvelope.getMaxY(); ReferencedEnvelope re1 = new ReferencedEnvelope(minX, datelineX - EPS, minY, maxY, renderingCRS); List<ReferencedEnvelope> result = new ArrayList<ReferencedEnvelope>(); ReferencedEnvelope tx1 = transformEnvelope(re1, WGS84); if (tx1 != null) { tx1.expandToInclude(180, tx1.getMinY()); addTransformedEnvelope(tx1, result); } ReferencedEnvelope re2 = new ReferencedEnvelope(datelineX + EPS, maxX, minY, maxY, renderingCRS); ReferencedEnvelope tx2 = transformEnvelope(re2, WGS84); if (tx2 != null) { if (tx2.getMinX() > 180) { tx2.translate(-360, 0); } tx2.expandToInclude(-180, tx1.getMinY()); addTransformedEnvelope(tx2, result); } mergeEnvelopes(result); return result; } else { return getSourceEnvelopes(renderingEnvelope); } } } }
ProjectionHandler { public List<ReferencedEnvelope> getQueryEnvelopes() throws TransformException, FactoryException { CoordinateReferenceSystem renderingCRS = renderingEnvelope.getCoordinateReferenceSystem(); if (!queryAcrossDateline) { ReferencedEnvelope envelope = transformEnvelope(renderingEnvelope, sourceCRS); if (envelope == null) return Collections.emptyList(); return Collections.singletonList(envelope); } if (renderingCRS instanceof GeographicCRS && !CRS.equalsIgnoreMetadata(renderingCRS, WGS84)) { ReferencedEnvelope re = renderingEnvelope; List<ReferencedEnvelope> envelopes = new ArrayList<ReferencedEnvelope>(); addTransformedEnvelope(re, envelopes); if (CRS.getAxisOrder(renderingCRS) == CRS.AxisOrder.NORTH_EAST) { if (re.getMinY() >= -180.0 && re.getMaxY() <= 180) { return envelopes; } adjustEnvelope(re, envelopes, true); } else { if (re.getMinX() >= -180.0 && re.getMaxX() <= 180) { ReferencedEnvelope envelope = transformEnvelope(renderingEnvelope, sourceCRS); if (envelope == null) return Collections.emptyList(); return Collections.singletonList(envelope); } adjustEnvelope(re, envelopes, true); } mergeEnvelopes(envelopes); return envelopes; } else { if (!Double.isNaN(datelineX) && renderingEnvelope.getMinX() < datelineX && renderingEnvelope.getMaxX() > datelineX && renderingEnvelope.getWidth() < targetHalfCircle) { double minX = renderingEnvelope.getMinX(); double minY = renderingEnvelope.getMinY(); double maxX = renderingEnvelope.getMaxX(); double maxY = renderingEnvelope.getMaxY(); ReferencedEnvelope re1 = new ReferencedEnvelope(minX, datelineX - EPS, minY, maxY, renderingCRS); List<ReferencedEnvelope> result = new ArrayList<ReferencedEnvelope>(); ReferencedEnvelope tx1 = transformEnvelope(re1, WGS84); if (tx1 != null) { tx1.expandToInclude(180, tx1.getMinY()); addTransformedEnvelope(tx1, result); } ReferencedEnvelope re2 = new ReferencedEnvelope(datelineX + EPS, maxX, minY, maxY, renderingCRS); ReferencedEnvelope tx2 = transformEnvelope(re2, WGS84); if (tx2 != null) { if (tx2.getMinX() > 180) { tx2.translate(-360, 0); } tx2.expandToInclude(-180, tx1.getMinY()); addTransformedEnvelope(tx2, result); } mergeEnvelopes(result); return result; } else { return getSourceEnvelopes(renderingEnvelope); } } } ProjectionHandler(
            CoordinateReferenceSystem sourceCRS,
            Envelope validAreaBounds,
            ReferencedEnvelope renderingEnvelope);  ProjectionHandler(
            CoordinateReferenceSystem sourceCRS,
            Geometry validArea,
            ReferencedEnvelope renderingEnvelope); }
ProjectionHandler { public List<ReferencedEnvelope> getQueryEnvelopes() throws TransformException, FactoryException { CoordinateReferenceSystem renderingCRS = renderingEnvelope.getCoordinateReferenceSystem(); if (!queryAcrossDateline) { ReferencedEnvelope envelope = transformEnvelope(renderingEnvelope, sourceCRS); if (envelope == null) return Collections.emptyList(); return Collections.singletonList(envelope); } if (renderingCRS instanceof GeographicCRS && !CRS.equalsIgnoreMetadata(renderingCRS, WGS84)) { ReferencedEnvelope re = renderingEnvelope; List<ReferencedEnvelope> envelopes = new ArrayList<ReferencedEnvelope>(); addTransformedEnvelope(re, envelopes); if (CRS.getAxisOrder(renderingCRS) == CRS.AxisOrder.NORTH_EAST) { if (re.getMinY() >= -180.0 && re.getMaxY() <= 180) { return envelopes; } adjustEnvelope(re, envelopes, true); } else { if (re.getMinX() >= -180.0 && re.getMaxX() <= 180) { ReferencedEnvelope envelope = transformEnvelope(renderingEnvelope, sourceCRS); if (envelope == null) return Collections.emptyList(); return Collections.singletonList(envelope); } adjustEnvelope(re, envelopes, true); } mergeEnvelopes(envelopes); return envelopes; } else { if (!Double.isNaN(datelineX) && renderingEnvelope.getMinX() < datelineX && renderingEnvelope.getMaxX() > datelineX && renderingEnvelope.getWidth() < targetHalfCircle) { double minX = renderingEnvelope.getMinX(); double minY = renderingEnvelope.getMinY(); double maxX = renderingEnvelope.getMaxX(); double maxY = renderingEnvelope.getMaxY(); ReferencedEnvelope re1 = new ReferencedEnvelope(minX, datelineX - EPS, minY, maxY, renderingCRS); List<ReferencedEnvelope> result = new ArrayList<ReferencedEnvelope>(); ReferencedEnvelope tx1 = transformEnvelope(re1, WGS84); if (tx1 != null) { tx1.expandToInclude(180, tx1.getMinY()); addTransformedEnvelope(tx1, result); } ReferencedEnvelope re2 = new ReferencedEnvelope(datelineX + EPS, maxX, minY, maxY, renderingCRS); ReferencedEnvelope tx2 = transformEnvelope(re2, WGS84); if (tx2 != null) { if (tx2.getMinX() > 180) { tx2.translate(-360, 0); } tx2.expandToInclude(-180, tx1.getMinY()); addTransformedEnvelope(tx2, result); } mergeEnvelopes(result); return result; } else { return getSourceEnvelopes(renderingEnvelope); } } } ProjectionHandler(
            CoordinateReferenceSystem sourceCRS,
            Envelope validAreaBounds,
            ReferencedEnvelope renderingEnvelope);  ProjectionHandler(
            CoordinateReferenceSystem sourceCRS,
            Geometry validArea,
            ReferencedEnvelope renderingEnvelope); void setProjectionParameters(Map projectionParameters); ReferencedEnvelope getRenderingEnvelope(); CoordinateReferenceSystem getSourceCRS(); List<ReferencedEnvelope> getQueryEnvelopes(); ReferencedEnvelope getProjectedEnvelope(
            ReferencedEnvelope envelope, CoordinateReferenceSystem targetCRS); boolean requiresProcessing(Geometry geometry); Geometry preProcess(Geometry geometry); MathTransform getRenderingTransform(MathTransform mt); Geometry postProcess(MathTransform mt, Geometry geometry); ReferencedEnvelope getValidAreaBounds(); }
ProjectionHandler { public List<ReferencedEnvelope> getQueryEnvelopes() throws TransformException, FactoryException { CoordinateReferenceSystem renderingCRS = renderingEnvelope.getCoordinateReferenceSystem(); if (!queryAcrossDateline) { ReferencedEnvelope envelope = transformEnvelope(renderingEnvelope, sourceCRS); if (envelope == null) return Collections.emptyList(); return Collections.singletonList(envelope); } if (renderingCRS instanceof GeographicCRS && !CRS.equalsIgnoreMetadata(renderingCRS, WGS84)) { ReferencedEnvelope re = renderingEnvelope; List<ReferencedEnvelope> envelopes = new ArrayList<ReferencedEnvelope>(); addTransformedEnvelope(re, envelopes); if (CRS.getAxisOrder(renderingCRS) == CRS.AxisOrder.NORTH_EAST) { if (re.getMinY() >= -180.0 && re.getMaxY() <= 180) { return envelopes; } adjustEnvelope(re, envelopes, true); } else { if (re.getMinX() >= -180.0 && re.getMaxX() <= 180) { ReferencedEnvelope envelope = transformEnvelope(renderingEnvelope, sourceCRS); if (envelope == null) return Collections.emptyList(); return Collections.singletonList(envelope); } adjustEnvelope(re, envelopes, true); } mergeEnvelopes(envelopes); return envelopes; } else { if (!Double.isNaN(datelineX) && renderingEnvelope.getMinX() < datelineX && renderingEnvelope.getMaxX() > datelineX && renderingEnvelope.getWidth() < targetHalfCircle) { double minX = renderingEnvelope.getMinX(); double minY = renderingEnvelope.getMinY(); double maxX = renderingEnvelope.getMaxX(); double maxY = renderingEnvelope.getMaxY(); ReferencedEnvelope re1 = new ReferencedEnvelope(minX, datelineX - EPS, minY, maxY, renderingCRS); List<ReferencedEnvelope> result = new ArrayList<ReferencedEnvelope>(); ReferencedEnvelope tx1 = transformEnvelope(re1, WGS84); if (tx1 != null) { tx1.expandToInclude(180, tx1.getMinY()); addTransformedEnvelope(tx1, result); } ReferencedEnvelope re2 = new ReferencedEnvelope(datelineX + EPS, maxX, minY, maxY, renderingCRS); ReferencedEnvelope tx2 = transformEnvelope(re2, WGS84); if (tx2 != null) { if (tx2.getMinX() > 180) { tx2.translate(-360, 0); } tx2.expandToInclude(-180, tx1.getMinY()); addTransformedEnvelope(tx2, result); } mergeEnvelopes(result); return result; } else { return getSourceEnvelopes(renderingEnvelope); } } } ProjectionHandler(
            CoordinateReferenceSystem sourceCRS,
            Envelope validAreaBounds,
            ReferencedEnvelope renderingEnvelope);  ProjectionHandler(
            CoordinateReferenceSystem sourceCRS,
            Geometry validArea,
            ReferencedEnvelope renderingEnvelope); void setProjectionParameters(Map projectionParameters); ReferencedEnvelope getRenderingEnvelope(); CoordinateReferenceSystem getSourceCRS(); List<ReferencedEnvelope> getQueryEnvelopes(); ReferencedEnvelope getProjectedEnvelope(
            ReferencedEnvelope envelope, CoordinateReferenceSystem targetCRS); boolean requiresProcessing(Geometry geometry); Geometry preProcess(Geometry geometry); MathTransform getRenderingTransform(MathTransform mt); Geometry postProcess(MathTransform mt, Geometry geometry); ReferencedEnvelope getValidAreaBounds(); static final String ADVANCED_PROJECTION_DENSIFY; }