@Test public void testQueryWrappingWGS84() throws Exception { ReferencedEnvelope wgs84Envelope = new ReferencedEnvelope(-190, 60, -90, 45, WGS84); ProjectionHandler handler = ProjectionHandlerFinder.getHandler(wgs84Envelope, true); assertNull(handler.validArea); List<ReferencedEnvelope> envelopes = handler.getQueryEnvelopes(DefaultGeographicCRS.WGS84); assertEquals(2, envelopes.size()); ReferencedEnvelope expected = new ReferencedEnvelope(170, 180, -90, 45, WGS84); assertTrue(envelopes.remove(wgs84Envelope)); assertEquals(expected, envelopes.get(0)); }
public List<ReferencedEnvelope> getQueryEnvelopes(CoordinateReferenceSystem queryCRS) throws TransformException, FactoryException { ReferencedEnvelope re = renderingEnvelope.transform(WGS84, true, 10); if (re.getMinX() >= -180.0 && re.getMaxX() <= 180) return Collections.singletonList(renderingEnvelope.transform(queryCRS, true, 10)); List<ReferencedEnvelope> envelopes = new ArrayList<ReferencedEnvelope>(); envelopes.add(re); if (re.getMinX() < -180) { envelopes.add(new ReferencedEnvelope(re.getMinX() + 360, 180, re.getMinY(), re .getMaxY(), re.getCoordinateReferenceSystem())); } if (re.getMaxX() > 180) { envelopes.add(new ReferencedEnvelope(-180, re.getMaxX() - 360, re.getMinY(), re .getMaxY(), re.getCoordinateReferenceSystem())); } boolean merged = true; while (merged && envelopes.size() > 1) { merged = false; for (int i = 0; i < envelopes.size() - 1; i++) { ReferencedEnvelope curr = envelopes.get(i); for (int j = i + 1; j < envelopes.size();) { ReferencedEnvelope next = envelopes.get(j); if (curr.intersects((Envelope) next)) { curr.expandToInclude(next); envelopes.remove(j); merged = true; } else { j++; } } } } for (int i = 0; i < envelopes.size(); i++) { envelopes.set(i, envelopes.get(i).transform(queryCRS, true, 10)); } return envelopes; }
ProjectionHandler { public List<ReferencedEnvelope> getQueryEnvelopes(CoordinateReferenceSystem queryCRS) throws TransformException, FactoryException { ReferencedEnvelope re = renderingEnvelope.transform(WGS84, true, 10); if (re.getMinX() >= -180.0 && re.getMaxX() <= 180) return Collections.singletonList(renderingEnvelope.transform(queryCRS, true, 10)); List<ReferencedEnvelope> envelopes = new ArrayList<ReferencedEnvelope>(); envelopes.add(re); if (re.getMinX() < -180) { envelopes.add(new ReferencedEnvelope(re.getMinX() + 360, 180, re.getMinY(), re .getMaxY(), re.getCoordinateReferenceSystem())); } if (re.getMaxX() > 180) { envelopes.add(new ReferencedEnvelope(-180, re.getMaxX() - 360, re.getMinY(), re .getMaxY(), re.getCoordinateReferenceSystem())); } boolean merged = true; while (merged && envelopes.size() > 1) { merged = false; for (int i = 0; i < envelopes.size() - 1; i++) { ReferencedEnvelope curr = envelopes.get(i); for (int j = i + 1; j < envelopes.size();) { ReferencedEnvelope next = envelopes.get(j); if (curr.intersects((Envelope) next)) { curr.expandToInclude(next); envelopes.remove(j); merged = true; } else { j++; } } } } for (int i = 0; i < envelopes.size(); i++) { envelopes.set(i, envelopes.get(i).transform(queryCRS, true, 10)); } return envelopes; } }
ProjectionHandler { public List<ReferencedEnvelope> getQueryEnvelopes(CoordinateReferenceSystem queryCRS) throws TransformException, FactoryException { ReferencedEnvelope re = renderingEnvelope.transform(WGS84, true, 10); if (re.getMinX() >= -180.0 && re.getMaxX() <= 180) return Collections.singletonList(renderingEnvelope.transform(queryCRS, true, 10)); List<ReferencedEnvelope> envelopes = new ArrayList<ReferencedEnvelope>(); envelopes.add(re); if (re.getMinX() < -180) { envelopes.add(new ReferencedEnvelope(re.getMinX() + 360, 180, re.getMinY(), re .getMaxY(), re.getCoordinateReferenceSystem())); } if (re.getMaxX() > 180) { envelopes.add(new ReferencedEnvelope(-180, re.getMaxX() - 360, re.getMinY(), re .getMaxY(), re.getCoordinateReferenceSystem())); } boolean merged = true; while (merged && envelopes.size() > 1) { merged = false; for (int i = 0; i < envelopes.size() - 1; i++) { ReferencedEnvelope curr = envelopes.get(i); for (int j = i + 1; j < envelopes.size();) { ReferencedEnvelope next = envelopes.get(j); if (curr.intersects((Envelope) next)) { curr.expandToInclude(next); envelopes.remove(j); merged = true; } else { j++; } } } } for (int i = 0; i < envelopes.size(); i++) { envelopes.set(i, envelopes.get(i).transform(queryCRS, true, 10)); } return envelopes; } ProjectionHandler(ReferencedEnvelope renderingEnvelope, ReferencedEnvelope validArea); }
ProjectionHandler { public List<ReferencedEnvelope> getQueryEnvelopes(CoordinateReferenceSystem queryCRS) throws TransformException, FactoryException { ReferencedEnvelope re = renderingEnvelope.transform(WGS84, true, 10); if (re.getMinX() >= -180.0 && re.getMaxX() <= 180) return Collections.singletonList(renderingEnvelope.transform(queryCRS, true, 10)); List<ReferencedEnvelope> envelopes = new ArrayList<ReferencedEnvelope>(); envelopes.add(re); if (re.getMinX() < -180) { envelopes.add(new ReferencedEnvelope(re.getMinX() + 360, 180, re.getMinY(), re .getMaxY(), re.getCoordinateReferenceSystem())); } if (re.getMaxX() > 180) { envelopes.add(new ReferencedEnvelope(-180, re.getMaxX() - 360, re.getMinY(), re .getMaxY(), re.getCoordinateReferenceSystem())); } boolean merged = true; while (merged && envelopes.size() > 1) { merged = false; for (int i = 0; i < envelopes.size() - 1; i++) { ReferencedEnvelope curr = envelopes.get(i); for (int j = i + 1; j < envelopes.size();) { ReferencedEnvelope next = envelopes.get(j); if (curr.intersects((Envelope) next)) { curr.expandToInclude(next); envelopes.remove(j); merged = true; } else { j++; } } } } for (int i = 0; i < envelopes.size(); i++) { envelopes.set(i, envelopes.get(i).transform(queryCRS, true, 10)); } return envelopes; } ProjectionHandler(ReferencedEnvelope renderingEnvelope, ReferencedEnvelope validArea); ReferencedEnvelope getRenderingEnvelope(); void setRenderingEnvelope(ReferencedEnvelope renderingEnvelope); List<ReferencedEnvelope> getQueryEnvelopes(CoordinateReferenceSystem queryCRS); boolean requiresProcessing(CoordinateReferenceSystem geomCRS, Geometry geometry); Geometry preProcess(CoordinateReferenceSystem geomCRS, Geometry geometry); Geometry postProcess(Geometry geometry); }
ProjectionHandler { public List<ReferencedEnvelope> getQueryEnvelopes(CoordinateReferenceSystem queryCRS) throws TransformException, FactoryException { ReferencedEnvelope re = renderingEnvelope.transform(WGS84, true, 10); if (re.getMinX() >= -180.0 && re.getMaxX() <= 180) return Collections.singletonList(renderingEnvelope.transform(queryCRS, true, 10)); List<ReferencedEnvelope> envelopes = new ArrayList<ReferencedEnvelope>(); envelopes.add(re); if (re.getMinX() < -180) { envelopes.add(new ReferencedEnvelope(re.getMinX() + 360, 180, re.getMinY(), re .getMaxY(), re.getCoordinateReferenceSystem())); } if (re.getMaxX() > 180) { envelopes.add(new ReferencedEnvelope(-180, re.getMaxX() - 360, re.getMinY(), re .getMaxY(), re.getCoordinateReferenceSystem())); } boolean merged = true; while (merged && envelopes.size() > 1) { merged = false; for (int i = 0; i < envelopes.size() - 1; i++) { ReferencedEnvelope curr = envelopes.get(i); for (int j = i + 1; j < envelopes.size();) { ReferencedEnvelope next = envelopes.get(j); if (curr.intersects((Envelope) next)) { curr.expandToInclude(next); envelopes.remove(j); merged = true; } else { j++; } } } } for (int i = 0; i < envelopes.size(); i++) { envelopes.set(i, envelopes.get(i).transform(queryCRS, true, 10)); } return envelopes; } ProjectionHandler(ReferencedEnvelope renderingEnvelope, ReferencedEnvelope validArea); ReferencedEnvelope getRenderingEnvelope(); void setRenderingEnvelope(ReferencedEnvelope renderingEnvelope); List<ReferencedEnvelope> getQueryEnvelopes(CoordinateReferenceSystem queryCRS); boolean requiresProcessing(CoordinateReferenceSystem geomCRS, Geometry geometry); Geometry preProcess(CoordinateReferenceSystem geomCRS, Geometry geometry); Geometry postProcess(Geometry geometry);  }