コード例 #1
0
ファイル: GeometryEditor.java プロジェクト: ebocher/jts
  private Polygon editPolygon(Polygon polygon, GeometryEditorOperation operation) {
    Polygon newPolygon = (Polygon) operation.edit(polygon, factory);
    // create one if needed
    if (newPolygon == null) newPolygon = factory.createPolygon((CoordinateSequence) null);
    if (newPolygon.isEmpty()) {
      // RemoveSelectedPlugIn relies on this behaviour. [Jon Aquino]
      return newPolygon;
    }

    LinearRing shell = (LinearRing) edit(newPolygon.getExteriorRing(), operation);
    if (shell == null || shell.isEmpty()) {
      // RemoveSelectedPlugIn relies on this behaviour. [Jon Aquino]
      return factory.createPolygon(null, null);
    }

    ArrayList holes = new ArrayList();
    for (int i = 0; i < newPolygon.getNumInteriorRing(); i++) {
      LinearRing hole = (LinearRing) edit(newPolygon.getInteriorRingN(i), operation);
      if (hole == null || hole.isEmpty()) {
        continue;
      }
      holes.add(hole);
    }

    return factory.createPolygon(shell, (LinearRing[]) holes.toArray(new LinearRing[] {}));
  }
コード例 #2
0
 private int getPolygonSize(Polygon geom) {
   // to hold the number of linear rings
   int size = ByteBuffer.UINT_SIZE;
   // for each linear ring, a UINT holds the number of points
   size += geom.isEmpty() ? 0 : ByteBuffer.UINT_SIZE * (geom.getNumInteriorRing() + 1);
   size += getPointByteSize(geom) * geom.getNumPoints();
   return size;
 }
コード例 #3
0
 @Override
 public void visit(Polygon<P> geom) {
   writeByteOrder(output);
   writeTypeCodeAndSrid(geom, output);
   if (geom.isEmpty()) {
     output.putUInt(0);
   } else {
     writeNumRings(geom, output);
     for (LinearRing<P> ring : geom) {
       writeRing(ring);
     }
   }
 }
コード例 #4
0
 private void writeNumRings(Polygon geom, ByteBuffer byteBuffer) {
   byteBuffer.putUInt(geom.isEmpty() ? 0 : geom.getNumInteriorRing() + 1);
 }
コード例 #5
0
 protected void writeNumRings(Polygon<P> geom, ByteBuffer byteBuffer) {
   byteBuffer.putUInt(geom.isEmpty() ? 0 : geom.getNumInteriorRing() + 1);
 }