GeometryWrapper implements CommonIndexValue { @Override public boolean overlaps(final NumericDimensionField[] fields, final NumericData[] rangeData) { final int latPosition = fields[0] instanceof LatitudeField ? 0 : 1; final int longPosition = fields[0] instanceof LatitudeField ? 1 : 0; if (fields.length == 1) { final Envelope env = geometry.getEnvelopeInternal(); final NumericRange r = latPosition == 0 ? new NumericRange(env.getMinY(), env.getMaxY()) : new NumericRange(env.getMinX(), env.getMaxX()); return ((rangeData[0].getMin() < r.getMax()) || DoubleMath.fuzzyEquals(rangeData[0].getMin(), r.getMax(), DOUBLE_TOLERANCE)) && ((rangeData[0].getMax() > r.getMin()) || DoubleMath.fuzzyEquals(rangeData[0].getMax(), r.getMin(), DOUBLE_TOLERANCE)); } return geometry.getFactory().createPolygon( new Coordinate[] { new Coordinate( rangeData[longPosition].getMin() - DOUBLE_TOLERANCE, rangeData[latPosition].getMin() - DOUBLE_TOLERANCE), new Coordinate( rangeData[longPosition].getMin() - DOUBLE_TOLERANCE, rangeData[latPosition].getMax() + DOUBLE_TOLERANCE), new Coordinate( rangeData[longPosition].getMax() + DOUBLE_TOLERANCE, rangeData[latPosition].getMax() + DOUBLE_TOLERANCE), new Coordinate( rangeData[longPosition].getMax() + DOUBLE_TOLERANCE, rangeData[latPosition].getMin() - DOUBLE_TOLERANCE), new Coordinate( rangeData[longPosition].getMin() - DOUBLE_TOLERANCE, rangeData[latPosition].getMin() - DOUBLE_TOLERANCE)}).intersects(geometry); } GeometryWrapper(final org.locationtech.jts.geom.Geometry geometry);  GeometryWrapper(
      final org.locationtech.jts.geom.Geometry geometry,
      final byte[] visibility); @Override void setVisibility(final byte[] visibility); @Override byte[] getVisibility(); org.locationtech.jts.geom.Geometry getGeometry(); @Override boolean overlaps(final NumericDimensionField[] fields, final NumericData[] rangeData); static final String DEFAULT_GEOMETRY_FIELD_NAME; }
@Test public void testLatitutde() { final NumericDimensionField[] fields = new NumericDimensionField[] {new LatitudeField(GeometryUtils.MAX_GEOMETRY_PRECISION)}; final Geometry geo = factory.createLineString( new Coordinate[] { new Coordinate(-99.22, 33.75000000000001), new Coordinate(-99.15, 33.75000000000001) }); final GeometryWrapper wrapper = new GeometryWrapper(geo); NumericRange rangeData = new NumericRange(33.7442334433, 33.75 + (1E-10d)); assertTrue(wrapper.overlaps(fields, new NumericData[] {rangeData})); rangeData = new NumericRange(33.7442334433, 33.75 - (1E-10d)); assertFalse(wrapper.overlaps(fields, new NumericData[] {rangeData})); rangeData = new NumericRange(33.75 - (1E-10d), 33.751); assertTrue(wrapper.overlaps(fields, new NumericData[] {rangeData})); rangeData = new NumericRange(33.75 + (1E-10d), 33.751); assertFalse(wrapper.overlaps(fields, new NumericData[] {rangeData})); }
@Test public void testLongitude() { final NumericDimensionField[] fields = new NumericDimensionField[] {new LongitudeField(GeometryUtils.MAX_GEOMETRY_PRECISION)}; final Geometry geo = factory.createLineString( new Coordinate[] { new Coordinate(-99.22, 33.75000000000001), new Coordinate(-99.15, 33.75000000000001) }); final GeometryWrapper wrapper = new GeometryWrapper(geo); NumericRange rangeData = new NumericRange(-99.15 - (1E-10d), -99.140348473); assertTrue(wrapper.overlaps(fields, new NumericData[] {rangeData})); rangeData = new NumericRange(-99.15 + (1E-10d), -99.140348473); assertFalse(wrapper.overlaps(fields, new NumericData[] {rangeData})); rangeData = new NumericRange(-99.23, -99.22 + (1E-9d)); assertTrue(wrapper.overlaps(fields, new NumericData[] {rangeData})); rangeData = new NumericRange(-99.23, -99.22 - (1E-10d)); assertFalse(wrapper.overlaps(fields, new NumericData[] {rangeData})); }