Пример #1
0
 void checkTransformation(String geomStr)
     throws IOException, ParseException, NoninvertibleTransformationException {
   Geometry geom = rdr.read(geomStr);
   AffineTransformation trans = AffineTransformation.rotationInstance(Math.PI / 2);
   AffineTransformation inv = trans.getInverse();
   Geometry transGeom = (Geometry) geom.clone();
   transGeom.apply(trans);
   // System.out.println(transGeom);
   transGeom.apply(inv);
   // check if transformed geometry is equal to original
   boolean isEqual = geom.equalsExact(transGeom, 0.0005);
   assertTrue(isEqual);
 }
Пример #2
0
 /**
  * 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;
 }
Пример #3
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());
 }
Пример #4
0
  public static Envelope3D of(final Geometry g) {
    if (g == null || g.isEmpty()) {
      return new Envelope3D();
    }
    final Envelope3D env = new Envelope3D();
    g.apply(
        new CoordinateFilter() {

          @Override
          public void filter(final Coordinate coord) {
            env.expandToInclude(coord);
          }
        });
    return env;
  }
Пример #5
0
 /**
  * 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();
 }
Пример #6
0
 /**
  * Add a geometry to the set of geometries whose common bits are being computed. After this method
  * has executed the common coordinate reflects the common bits of all added geometries.
  *
  * @param geom a Geometry to test for common bits
  */
 public void add(Geometry geom) {
   geom.apply(ccFilter);
   commonCoord = ccFilter.getCommonCoordinate();
 }