Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.Geometry


    }
    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)) {
      geometry = createLineString(factory, jso);
    } else if (type.equals(org.geomajas.geometry.Geometry.POLYGON)) {
View Full Code Here


    return factory.createMultiLineString(lineStrings);
  }

  public Object marshall(SerializerState state, Object o) throws MarshallException {
    JSONObject obj;
    Geometry geometry = (Geometry) o;

    if (geometry instanceof Point) {
      obj = fromPoint((Point) geometry);
    } else if (geometry instanceof LineString) {
      obj = fromLineString((LineString) geometry);
    } else if (geometry instanceof Polygon) {
      obj = fromPolygon((Polygon) geometry);
    } else if (geometry instanceof MultiPolygon) {
      obj = fromMultiPolygon((MultiPolygon) geometry);
    } else if (geometry instanceof MultiLineString) {
      obj = fromMultiLineString((MultiLineString) geometry);
    } else if (geometry instanceof MultiPoint) {
      obj = fromMultiPoint((MultiPoint) geometry);
    } else {
      throw new MarshallException("cannot marshal " + geometry.getClass());
    }
    return obj;
  }
View Full Code Here

    }
    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
View Full Code Here

      Envelope target = geoService.transform(source, transform);
      response.setBounds(converter.toDto(target));
    }

    if (request.getGeometry() != null) {
      Geometry source = converter.toInternal(request.getGeometry());
      Geometry target = geoService.transform(source, transform);
      response.setGeometry(converter.toDto(target));
    }

    if (request.getGeometryCollection() != null) {
      for (org.geomajas.geometry.Geometry geometry : request.getGeometryCollection()) {
        Geometry source = converter.toInternal(geometry);
        Geometry target = geoService.transform(source, transform);
        response.getGeometryCollection().add(converter.toDto(target));
      }
    }
  }
View Full Code Here

    JSONObject jsonObject = (JSONObject) json;
    JSONArray features = (JSONArray) jsonObject.get("features");
    JSONObject feature = (JSONObject) features.get(0);
    JSONObject geometry = (JSONObject) feature.get("geometry");
    GeometryJSON g = new GeometryJSON(0);
    Geometry m = g.read(geometry.toJSONString());
    Envelope envelope = new Envelope(0, 1, 0, 1);
    Geometry orig = JTS.toGeometry(envelope);
    Geometry m2 = geoservice.transform(orig, "EPSG:4326", "EPSG:900913");
    // equality check on buffer, JTS equals does not do the trick !
    Assert.assertTrue(m.buffer(0.01).contains(m2));
    Assert.assertTrue(m2.buffer(0.01).contains(m));
  }
View Full Code Here

        new GeometryCollection(constraints.toArray(EMPTY_GEOM_ARRAY), GF));
    triangulationBuilder.setTolerance(0.01);
   
    /* run triangulation */
   
    Geometry triangulationResult = triangulationBuilder.getTriangles(GF);
   
    /* interpret the resulting polygons as triangles,
     * filter out those which are outside the polygon or in a hole */
   
    Collection<PolygonWithHolesXZ> trianglesAsPolygons =
View Full Code Here

     
      List<Geometry> newRemainingGeometry = new ArrayList<Geometry>(1);
     
      for (Geometry g : remainingGeometry) {
       
        Geometry newG = g.difference(
            polygonXZToJTSPolygon(subtractPolygon));
       
        if (newG instanceof GeometryCollection) {
          for (int i = 0; i < ((GeometryCollection)newG).getNumGeometries(); i++) {
            newRemainingGeometry.add(((GeometryCollection)newG).getGeometryN(i));
View Full Code Here

  public static final Collection<PolygonWithHolesXZ> intersectPolygons(
      List<? extends SimplePolygonXZ> intersectPolygons) {
   
    if (intersectPolygons.isEmpty()) { throw new IllegalArgumentException(); }
       
    Geometry remainingGeometry = null;
   
    for (SimplePolygonXZ poly : intersectPolygons) {
     
      Polygon jtsPoly = polygonXZToJTSPolygon(poly);
     
      if (remainingGeometry == null) {
        remainingGeometry = jtsPoly;
      } else {
        remainingGeometry = remainingGeometry.intersection(jtsPoly);
      }
     
    }
   
    return polygonsXZFromJTSGeometry(remainingGeometry);
View Full Code Here

    return lines;
  }

  Geometry read(String lineWKT) {
    try {
      Geometry geom = reader.read(lineWKT);

      return geom;
    } catch (Exception ex) {
      ex.printStackTrace();
    }
View Full Code Here

{
  public static void main(String[] args)
      throws Exception
  {
    // read a geometry from a WKT string (using the default geometry factory)
    Geometry g1 = new WKTReader().read("LINESTRING (0 0, 10 10, 20 20)");
    System.out.println("Geometry 1: " + g1);

    // 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

TOP

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

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.