Examples of GeometryFactory


Examples of com.vividsolutions.jts.geom.GeometryFactory

    PersistTransactionRequest request = new PersistTransactionRequest();
    request.setCrs(CRS);
    FeatureTransaction featureTransaction = new FeatureTransaction();
    featureTransaction.setLayerId(LAYER_ID);
    Feature feature = new Feature();
    GeometryFactory factory = new GeometryFactory();
    Geometry circle =
        dtoConverter.toDto(geoService.createCircle(factory.createPoint(new Coordinate(0, 0)), 10, 10));
    feature.setGeometry(circle);
    featureTransaction.setNewFeatures(new Feature[] {feature});
    request.setFeatureTransaction(featureTransaction);
    PersistTransactionResponse response = (PersistTransactionResponse) dispatcher.execute(
        PersistTransactionRequest.COMMAND, request, null, "en");
View Full Code Here

Examples of com.vividsolutions.jts.geom.GeometryFactory

  }

  @Test
  public void testCalcDefaultLabelPosition() throws Exception {
    Geometry geometry;
    GeometryFactory factory = new GeometryFactory(new PrecisionModel(), 4326);
    Coordinate coordinate;
    InternalFeature feature = new InternalFeatureImpl();
    feature.setId("x");
    feature.setLabel("Label x");
    coordinate = geoService.calcDefaultLabelPosition(feature);
    Assert.assertNull(coordinate);

    feature.setGeometry(factory.createMultiPolygon(new Polygon[] {}));
    coordinate = geoService.calcDefaultLabelPosition(feature);
    Assert.assertNull(coordinate);

    feature.setGeometry(JTS.toGeometry(new Envelope(10, 20, 30, 40)));
    coordinate = geoService.calcDefaultLabelPosition(feature);
    // this tests current behaviour, without claims that this is the "best" (or even "good") position
    Assert.assertEquals(15.0, coordinate.x, DELTA);
    Assert.assertEquals(35.0, coordinate.y, DELTA);

    geometry = factory.createLineString(new Coordinate[] { new Coordinate(5,4), new Coordinate(30,10) });
    feature.setGeometry(geometry);
    coordinate = geoService.calcDefaultLabelPosition(feature);
    // this tests current behaviour, without claims that this is the "best" (or even "good") position
    Assert.assertEquals(5.0, coordinate.x, DELTA);
    Assert.assertEquals(4.0, coordinate.y, DELTA);
View Full Code Here

Examples of com.vividsolutions.jts.geom.GeometryFactory

  }

  @Test
  public void testCreateCircle() throws Exception {
    Geometry geometry;
    GeometryFactory factory = new GeometryFactory(new PrecisionModel(), 4326);
    Point point = factory.createPoint(new Coordinate(0, 0));
    Point inside = factory.createPoint(new Coordinate(9.5, 0));
    Point insideFine = factory.createPoint(new Coordinate(6.8, 6.8));
    Point outsideAll = factory.createPoint(new Coordinate(9, 5));

    geometry = geoService.createCircle(point, 10, 4);
    Assert.assertEquals(5, geometry.getCoordinates().length);
    Assert.assertTrue(geometry.contains(inside));
    Assert.assertFalse(geometry.contains(insideFine));
View Full Code Here

Examples of com.vividsolutions.jts.geom.GeometryFactory

    assertTransformedLineString(geometry);
  }

  @Test
  public void transformGeometryEmptyResultOnException() throws Exception {
    GeometryFactory geometryFactory = new GeometryFactory();
    WKTReader reader = new WKTReader( geometryFactory );
   
    Point point = (Point) reader.read("POINT (1 1)");
    Geometry geometry = geoService.transform(point, new ThrowingTransform());
    Assert.assertEquals(Point.class, geometry.getClass());
View Full Code Here

Examples of com.vividsolutions.jts.geom.GeometryFactory

    Assert.assertEquals(3219426.4637164664, coordinates[3].x, DELTA);
    Assert.assertEquals(1050557.6016714368, coordinates[3].y, DELTA);
  }

  private Geometry getLineString() {
    GeometryFactory factory = new GeometryFactory(new PrecisionModel(), 4326);
    return factory.createLineString(new Coordinate[] {
        new Coordinate(5, 4), new Coordinate(30, 10), new Coordinate(120, 150), new Coordinate(50, 50)});

  }
View Full Code Here

Examples of com.vividsolutions.jts.geom.GeometryFactory

*/
public class GeometrySerializerTest extends TestCase {

  public void testPoint() throws MarshallException {
    GeometrySerializer ser = new GeometrySerializer();
    GeometryFactory factory = new GeometryFactory(new PrecisionModel(100.0), 31300);
    CoordinateArraySequence coords = new CoordinateArraySequence(new Coordinate[] {new Coordinate(
        12.3456, 34567.3456)});
    Point p = new Point(coords, factory);
    JSONObject jo = (JSONObject) ser.marshall(null, p);
    assertEquals("Point", jo.get("type").toString());
View Full Code Here

Examples of com.vividsolutions.jts.geom.GeometryFactory

    assertEquals("[12.35,34567.35]", jo.get("coordinates").toString());
  }

  public void testLineString() throws MarshallException {
    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(-0.01, -0.0)});
    LineString p = new LineString(coords, factory);
    JSONObject jo = (JSONObject) ser.marshall(null, p);
    assertEquals("LineString", jo.get("type").toString());
View Full Code Here

Examples of com.vividsolutions.jts.geom.GeometryFactory

    assertEquals("[12,34.23,12,54.56,-0.01,0]", jo.get("coordinates").toString());
  }

  public void testPolygon() throws MarshallException {
    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);
View Full Code Here

Examples of com.vividsolutions.jts.geom.GeometryFactory

    assertEquals("[12,34.23,12,54.56,7,8,12,34.23]", shell.get("coordinates").toString());
  }

  public void testMultiPolygon() throws MarshallException {
    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);
View Full Code Here

Examples of com.vividsolutions.jts.geom.GeometryFactory

    assertEquals("[12,34.23,12,54.56,7,8,12,34.23]", shell.get("coordinates").toString());
  }

  public void testMultiLineString() throws MarshallException {
    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(-0.01, -0.0)});
    LineString l = new LineString(coords, factory);
    MultiLineString m = new MultiLineString(new LineString[] {l}, factory);
    JSONObject jo = (JSONObject) ser.marshall(null, m);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.