Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.GeometryFactory


        "org/geomajas/spring/geomajasContext.xml", "org/geomajas/spring/emptyApplication.xml" });
    converter = applicationContext.getBean("service.DtoConverterService", DtoConverterService.class);
  }

  public void testPoint() throws MarshallException, GeomajasException {
    GeometryFactory factory = new GeometryFactory(new PrecisionModel(10000.0), 31300);
    CoordinateArraySequence coords = new CoordinateArraySequence(new Coordinate[] { new Coordinate(12.3456,
        34567.3456) });
    Point p = new Point(coords, factory);
    JSONObject jtsJson = (JSONObject) jtsSerializer.marshall(null, p);
    Geometry dto = converter.toDto(p);
View Full Code Here


    JSONObject dtoJson = (JSONObject) dtoSerializer.marshall(null, dto);
    Assert.assertEquals(jtsJson.toString(), dtoJson.toString());
  }

  public void testLineString() throws MarshallException, GeomajasException {
    GeometryFactory factory = new GeometryFactory(new PrecisionModel(10000.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 jtsJson = (JSONObject) jtsSerializer.marshall(null, p);
    Geometry dto = converter.toDto(p);
View Full Code Here

    JSONObject dtoJson = (JSONObject) dtoSerializer.marshall(null, dto);
    Assert.assertEquals(jtsJson.toString(), dtoJson.toString());
  }

  public void testPolygon() throws MarshallException, GeomajasException {
    GeometryFactory factory = new GeometryFactory(new PrecisionModel(10000.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, null, factory);
    Geometry dto = converter.toDto(p);
View Full Code Here

    Assert.assertEquals(jtsShell.get("precision").toString(), dtoShell.get("precision").toString());
    Assert.assertEquals(jtsShell.get("coordinates").toString(), dtoShell.get("coordinates").toString());
  }

  public void testMultiPolygon() throws MarshallException, GeomajasException {
    GeometryFactory factory = new GeometryFactory(new PrecisionModel(10000.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);
View Full Code Here

    Assert.assertEquals(jtsShell.get("precision").toString(), dtoShell.get("precision").toString());
    Assert.assertEquals(jtsShell.get("coordinates").toString(), dtoShell.get("coordinates").toString());
  }

  public void testMultiLineString() throws MarshallException, GeomajasException {
    GeometryFactory factory = new GeometryFactory(new PrecisionModel(10000.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 jtsJson = (JSONObject) jtsSerializer.marshall(null, m);
View Full Code Here

    if (type == null) {
      throw new UnmarshallException("no type hint");
    }
    int srid = jso.getInt(ATTRIBUTE_SRID);
    int precision = jso.getInt(ATTRIBUTE_PRECISION);
    GeometryFactory factory = new GeometryFactory(new PrecisionModel(Math.pow(10, precision)), srid);

    Geometry geometry = null;
    if (type.equals(org.geomajas.geometry.Geometry.POINT)) {
      geometry = createPoint(factory, jso);
    } else if (type.equals(org.geomajas.geometry.Geometry.LINE_STRING)) {
View Full Code Here

        throw new GeomajasException(e, ExceptionCode.MERGE_NO_POLYGON);
      }
    }
    int precision = polygons[0].getPrecisionModel().getMaximumSignificantDigits() - 1;
    PrecisionModel precisionModel = new PrecisionModel(Math.pow(10.0, precision));
    GeometryFactory factory = new GeometryFactory(precisionModel, polygons[0].getSRID());

    Geometry temp = factory.createGeometry(polygons[0]);
    for (int i = 1; i < polygons.length; i++) {
      Geometry polygon = factory.createGeometry(polygons[i]);
      temp = temp.union(polygon.buffer(Math.pow(10.0, -(precision - 1))));
    }
    if (temp instanceof Polygon) {
      MultiPolygon mp = factory.createMultiPolygon(new Polygon[] { (Polygon) temp });
      response.setGeometry(converter.toDto(mp));
    } else if (temp instanceof MultiPolygon && temp.getNumGeometries() != 0
        && (request.isAllowMultiPolygon() || temp.getNumGeometries() == 1)) {
      response.setGeometry(converter.toDto(temp));
    } else {
View Full Code Here

    // create a geometry by specifying the coordinates directly
    Coordinate[] coordinates = new Coordinate[]{new Coordinate(0, 0),
      new Coordinate(10, 10), new Coordinate(20, 20)};
    // use the default factory, which gives full double-precision
    Geometry g2 = new GeometryFactory().createLineString(coordinates);
    System.out.println("Geometry 2: " + g2);

    // compute the intersection of the two geometries
    Geometry g3 = g1.intersection(g2);
    System.out.println("G1 intersection G2: " + g3);
View Full Code Here

        Coordinate[] ringPts = new Coordinate[]{
            v[0].getCoordinate(),
            v[1].getCoordinate(),
            v[2].getCoordinate(),
            v[0].getCoordinate()};
        GeometryFactory fact = new GeometryFactory();
        LinearRing ring = fact.createLinearRing(ringPts);
        Polygon tri = fact.createPolygon(ring, null);
        return tri;
    }
View Full Code Here

        Coordinate[] ringPts = new Coordinate[]{
            e[0].orig().getCoordinate(),
            e[1].orig().getCoordinate(),
            e[2].orig().getCoordinate(),
            e[0].orig().getCoordinate()};
        GeometryFactory fact = new GeometryFactory();
        LinearRing ring = fact.createLinearRing(ringPts);
        Polygon tri = fact.createPolygon(ring, null);
        return tri;
    }
View Full Code Here

TOP

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

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.