Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.LinearRing


  }

  @Test
  public void dtoLinearRingToJts() throws GeomajasException {
    // Test DTO LinearRing to JTS:
    LinearRing linearRing = (LinearRing) converter.toInternal(createDtoLinearRing());
    Assert.assertEquals(dtoC3.getX(), linearRing.getCoordinateN(2).x);
  }
View Full Code Here


    return factory.createLinearRing(new com.vividsolutions.jts.geom.Coordinate[] { jtsC1, jtsC2, jtsC3, jtsC4,
        jtsC1 });
  }

  private Polygon createJtsPolygon() {
    LinearRing shell = factory.createLinearRing(new com.vividsolutions.jts.geom.Coordinate[] { jtsC1, jtsC2, jtsC3,
        jtsC4, jtsC1 });
    LinearRing hole = factory.createLinearRing(new com.vividsolutions.jts.geom.Coordinate[] { jtsC5, jtsC6, jtsC7,
        jtsC8, jtsC5 });
    return factory.createPolygon(shell, new LinearRing[] { hole });
  }
View Full Code Here

        jtsC8 });
    return factory.createMultiLineString(new LineString[] { l1, l2 });
  }

  private MultiPolygon createJtsMultiPolygon() {
    LinearRing shell = factory.createLinearRing(new com.vividsolutions.jts.geom.Coordinate[] { jtsC1, jtsC2, jtsC3,
        jtsC4, jtsC1 });
    LinearRing hole = factory.createLinearRing(new com.vividsolutions.jts.geom.Coordinate[] { jtsC5, jtsC6, jtsC7,
        jtsC8, jtsC5 });
    Polygon polygon1 = factory.createPolygon(shell, new LinearRing[] {});
    Polygon polygon2 = factory.createPolygon(shell, new LinearRing[] { hole });
    return factory.createMultiPolygon(new Polygon[] { polygon1, polygon2 });
  }
View Full Code Here

    GeometrySerializer ser = new GeometrySerializer();
    GeometryFactory factory = new GeometryFactory(new PrecisionModel(100.0), 31300);
    CoordinateArraySequence coords = new CoordinateArraySequence(new Coordinate[] {
        new Coordinate(12.0, 34.23), new Coordinate(12.000, 54.555), new Coordinate(7, 8),
        new Coordinate(12.0, 34.23)});
    LinearRing ring = new LinearRing(coords, factory);
    Polygon p = new Polygon(ring, new LinearRing[] {}, factory);
    JSONObject jo = (JSONObject) ser.marshall(null, p);
    assertEquals("Polygon", jo.get("type").toString());
    assertEquals("[]", jo.get("holes").toString());
    assertEquals("31300", jo.get("srid").toString());
View Full Code Here

    GeometrySerializer ser = new GeometrySerializer();
    GeometryFactory factory = new GeometryFactory(new PrecisionModel(100.0), 31300);
    CoordinateArraySequence coords = new CoordinateArraySequence(new Coordinate[] {
        new Coordinate(12.0, 34.23), new Coordinate(12.000, 54.555), new Coordinate(7, 8),
        new Coordinate(12.0, 34.23)});
    LinearRing ring = new LinearRing(coords, factory);
    Polygon p = new Polygon(ring, new LinearRing[] {}, factory);
    MultiPolygon m = new MultiPolygon(new Polygon[] {p}, factory);
    JSONObject jo = (JSONObject) ser.marshall(null, m);
    assertEquals("MultiPolygon", jo.get("type").toString());
    assertEquals("31300", jo.get("srid").toString());
View Full Code Here

    request.setRatio(0.5f);
    request.setLayerIds(new String[] {LAYER_ID});

    // create a rectangle that overlaps 50 %
    GeometryFactory factory = new GeometryFactory();
    LinearRing half1 = factory.createLinearRing(new Coordinate[] {new Coordinate(0, 0), new Coordinate(1, 0),
        new Coordinate(1, 0.5), new Coordinate(0, 0.5), new Coordinate(0, 0)});
    Polygon polygon = factory.createPolygon(half1, null);
    request.setLocation(converter.toDto(polygon));

    // execute
View Full Code Here

    request.setRatio(0.5f);
    request.setLayerIds(new String[] {LAYER_ID});

    // create a rectangle that overlaps 49 %
    GeometryFactory factory = new GeometryFactory();
    LinearRing half1 = factory.createLinearRing(new Coordinate[] {new Coordinate(0, 0), new Coordinate(1, 0),
        new Coordinate(1, 0.49), new Coordinate(0, 0.49), new Coordinate(0, 0)});
    Polygon polygon = factory.createPolygon(half1, null);
    request.setLocation(converter.toDto(polygon));

    // execute
View Full Code Here

        geometry = factory.createLineString(getCoordinates(linestring.getCoordinates()));
      }
    } else if (geom instanceof PolygonTypeInfo) {
      PolygonTypeInfo polygon = (PolygonTypeInfo) geom;
      OuterBoundaryIsInfo outer = polygon.getOuterBoundaryIs();
      LinearRing shell = toLinearRing(factory, outer.getLinearRing());
      LinearRing[] holes = new LinearRing[polygon.getInnerBoundaryIList().size()];
      int i = 0;
      for (InnerBoundaryIsInfo inner : polygon.getInnerBoundaryIList()) {
        holes[i++] = toLinearRing(factory, inner.getLinearRing());
      }
View Full Code Here

    }
    return geometry;
  }

  private LinearRing toLinearRing(GeometryFactory factory, LinearRingTypeInfo linearRing) {
    LinearRing ring = null;
    if (linearRing.ifCoordList()) {
      ring = factory.createLinearRing(getCoordinates(linearRing.getCoordList()));
    } else if (linearRing.ifCoordinates()) {
      ring = factory.createLinearRing(getCoordinates(linearRing.getCoordinates()));
    }
View Full Code Here

    } else if (Geometry.LINEAR_RING.equals(geometryType)) {
      jts = factory.createLinearRing(convertCoordinates(geometry));
    } else if (Geometry.LINE_STRING.equals(geometryType)) {
      jts = factory.createLineString(convertCoordinates(geometry));
    } else if (Geometry.POLYGON.equals(geometryType)) {
      LinearRing exteriorRing = (LinearRing) toInternal(geometry.getGeometries()[0]);
      LinearRing[] interiorRings = new LinearRing[geometry.getGeometries().length - 1];
      for (int i = 0; i < interiorRings.length; i++) {
        interiorRings[i] = (LinearRing) toInternal(geometry.getGeometries()[i + 1]);
      }
      jts = factory.createPolygon(exteriorRing, interiorRings);
View Full Code Here

TOP

Related Classes of com.vividsolutions.jts.geom.LinearRing

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.