/**
  * Removes the common coordinate bits from a Geometry. The coordinates of the Geometry are
  * changed.
  *
  * @param geom the Geometry from which to remove the common coordinate bits
  * @return the shifted Geometry
  */
 public Geometry removeCommonBits(Geometry geom) {
   if (commonCoord.x == 0.0 && commonCoord.y == 0.0) return geom;
   Coordinate invCoord = new Coordinate(commonCoord);
   invCoord.x = -invCoord.x;
   invCoord.y = -invCoord.y;
   Translater trans = new Translater(invCoord);
   geom.apply(trans);
   geom.geometryChanged();
   return geom;
 }
Example #2
0
 public void testInvalidateEnvelope() throws Exception {
   Geometry g = reader.read("POLYGON ((0 0, 0 50, 50 50, 50 0, 0 0))");
   assertEquals(new Envelope(0, 50, 0, 50), g.getEnvelopeInternal());
   g.apply(
       new CoordinateFilter() {
         public void filter(Coordinate coord) {
           coord.x += 1;
           coord.y += 1;
         }
       });
   assertEquals(new Envelope(0, 50, 0, 50), g.getEnvelopeInternal());
   g.geometryChanged();
   assertEquals(new Envelope(1, 51, 1, 51), g.getEnvelopeInternal());
 }
 /**
  * Adds the common coordinate bits back into a Geometry. The coordinates of the Geometry are
  * changed.
  *
  * @param geom the Geometry to which to add the common coordinate bits
  * @return the shifted Geometry
  */
 public void addCommonBits(Geometry geom) {
   Translater trans = new Translater(commonCoord);
   geom.apply(trans);
   geom.geometryChanged();
 }