Example #1
0
 public static Geometry constructRectyPolygonGeometry(
     Point2D.Double aLeftUpperCorner, Point2D.Double aBottomRightCorner) {
   GeometryFactory gFactory = new GeometryFactory();
   CoordinateSequenceFactory csFactory = gFactory.getCoordinateSequenceFactory();
   Coordinate[] coordinates = new Coordinate[5];
   coordinates[0] = new Coordinate(aLeftUpperCorner.x, aLeftUpperCorner.y);
   coordinates[1] = new Coordinate(aBottomRightCorner.x, aLeftUpperCorner.y);
   coordinates[2] = new Coordinate(aBottomRightCorner.x, aBottomRightCorner.y);
   coordinates[3] = new Coordinate(aLeftUpperCorner.x, aBottomRightCorner.y);
   coordinates[4] = new Coordinate(aLeftUpperCorner.x, aLeftUpperCorner.y);
   CoordinateSequence cSeq = csFactory.create(coordinates);
   return gFactory.createPolygon(new LinearRing(cSeq, gFactory), null);
 }
 private CoordinateSequence readCoordinateSequence(int size) throws IOException {
   CoordinateSequence seq = csFactory.create(size, inputDimension);
   int targetDim = seq.getDimension();
   if (targetDim > inputDimension) targetDim = inputDimension;
   for (int i = 0; i < size; i++) {
     readCoordinate();
     for (int j = 0; j < targetDim; j++) {
       seq.setOrdinate(i, j, ordValues[j]);
     }
   }
   return seq;
 }