Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.GeometryFactory


      Coordinate c = new Coordinate(v.getLng(), v.getLat());
      coords[i] = c;
    }
   
    // now create a line string from the coordinates array where null = no holes in the polygon
    LinearRing ring = new GeometryFactory().createLinearRing(coords);
    Geometry geometry = new GeometryFactory().createPolygon(ring, null);
   
    // create a point from the mapCenter vertex
    // TODO: mapCenter is null when creating a new study region.
    Vertex mapCenterVertex = studyRegion.getMapCenter();
    logger.debug("mapCenter=" + studyRegion.getMapCenter());
    Coordinate mapCenterCoord = new Coordinate(mapCenterVertex.getLng(), mapCenterVertex.getLat());
    Geometry mapCenter = new GeometryFactory().createPoint(mapCenterCoord);
   
    StudyRegion savedStudyRegion = null;
   
    try {
      if( studyRegion.getId().indexOf("TEMP") != -1 )
View Full Code Here


            Geometry geometry = (Geometry) feature.getDefaultGeometry();
            geoms.add(geometry.reverse());

        }

        GeometryFactory factory = new GeometryFactory();
        Geometry combined = factory.buildGeometry(geoms);

        return combined.union();
    }
View Full Code Here

                    if( blackboard.get(AOI_GEOMETRY) == null ){
                        // try and restore from WKT
                        String wkt = map.getBlackboard().getString(AOI_GEOMETRY);
                        if( wkt != null ){
                            // we got one!
                            GeometryFactory gf = JTSFactoryFinder.getGeometryFactory(null);
                            WKTReader reader = new WKTReader(gf);
                            try {
                                Geometry geometry = reader.read(wkt);
                                blackboard.put(AOI_GEOMETRY, geometry );
                            } catch (ParseException e) {
View Full Code Here

        if (!bbox.getCoordinateReferenceSystem().equals(crs)) {
            bbox = bbox.transform(crs, true);
        }
        FilterFactory2 factory = (FilterFactory2) CommonFactoryFinder.getFilterFactory(GeoTools
                .getDefaultHints());
        Geometry geom = new GeometryFactory().toGeometry(bbox);
        Intersects filter = factory.intersects(factory.property(type.getGeometryDescriptor()
                .getName()), factory.literal(geom));

        layer.getQuery(false);
        final FeatureCollection<SimpleFeatureType, SimpleFeature> results = source
View Full Code Here

    fact.setValidating(false);

    SAXParser parser = fact.newSAXParser();

    if(geometryFactory == null)
      geometryFactory = new GeometryFactory();

    GMLHandler gh = new GMLHandler(geometryFactory,null);
    parser.parse(new InputSource(reader), (DefaultHandler)gh);

    return gh.getGeometry();
View Full Code Here

  @Override
  public Geometry getGeometry() {
    ReferencedEnvelope extent = this.getExtent();
    if (extent != null) {
      return new GeometryFactory().toGeometry(extent);
    }
    return null;
  }
View Full Code Here

  @Override
  public Geometry getGeometry() {
    ReferencedEnvelope extent = this.getExtent();
    if (extent != null) {
      return new GeometryFactory().toGeometry(extent);
    }
    return null;
  }
View Full Code Here

            if (!(coordArray.length <= 2) && !CGAlgorithms.isCCW(coordArray)) {
                hole = JTSUtilities.reverseRing((LinearRing) hole);
            }
            currentHoles.add(hole);
        }
        GeometryFactory factory = new GeometryFactory();
        LinearRing[] holes = currentHoles.toArray(new LinearRing[currentHoles.size()]);
        return factory.createPolygon(shell, holes);
    }
View Full Code Here

        if (!GeometryCollection.class.isAssignableFrom(schemaDeclaredType)
                && !schemaDeclaredType.isAssignableFrom(GeometryCollection.class))
            return geoms.get(0);

        Geometry geom;
        GeometryFactory factory = new GeometryFactory();
        Class< ? extends Geometry> geomType = geoms.get(0).getClass();
        if (geomType == Polygon.class) {
            geom = factory.createMultiPolygon(geoms.toArray(new Polygon[geoms.size()]));
        } else if (geomType == LinearRing.class) {
            geom = factory.createMultiLineString(geoms.toArray(new LineString[geoms.size()]));
        } else if (geomType == LineString.class) {
            geom = factory.createMultiLineString(geoms.toArray(new LineString[geoms.size()]));
        } else {
            geom = factory.createMultiPoint(geoms.toArray(new Point[geoms.size()]));
        }
        return geom;
    }
View Full Code Here

    Geometry[] holes = null;
    LinearRing[] holesRing = null;
    List<Coordinate> shellCoordinates = null;
    List<LinearRing> holesList = null;
    GeometryFactory fc = polygonToAddVertex.getFactory();

    // cast to polygon and get the exterior boundary.
    Polygon polygonGeom = (Polygon) polygonToAddVertex;
    Geometry boundary = polygonGeom.getExteriorRing();

    Coordinate[] shellClosed = null;
    Coordinate[] boundaryCoordinates = boundary.getCoordinates();

    // for each neighbor
    for (Geometry neighbor : geomNeighborList) {

      if (boundary.touches(neighbor)) {
        // store the modified boundaryCoordinates for add more vertex if
        // there are.
        shellCoordinates = addIntersection(boundaryCoordinates, line, fc, neighbor);
        boundaryCoordinates = shellCoordinates.toArray(new Coordinate[shellCoordinates.size()]);
        shellClosed = boundaryCoordinates;
      } else {
        shellClosed = boundaryCoordinates;
      }
    }

    holes = getInteriorHoles(polygonGeom);

    // if not null, the geometry has holes.
    if (holes.length > 0) {

      holesList = addIntersectionToHoles(holes, line, fc, geomNeighborList);
      holesRing = holesList.toArray(new LinearRing[holesList.size()]);
    }

    // form a closed linearRing.
    shellClosed = GeometryUtil.closeGeometry(shellClosed);
    LinearRing shellRing = fc.createLinearRing(shellClosed);

    result = fc.createPolygon(shellRing, holesRing);

    return result;
  }
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.