Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.Geometry


        GeometryDescriptor geomAttr = store.getSchema().getGeometryDescriptor();
        Class< ? extends Geometry> expectedClass = (Class< ? extends Geometry>) geomAttr.getType()
                .getBinding();

        Geometry adaptedGeom = GeometryUtil.adapt(newGeometry, expectedClass);

        FilterFactory ff = CommonFactoryFinder.getFilterFactory(null);
        FeatureId fid = ff.featureId(fidToUpdate);
        Set<FeatureId> ids = new HashSet<FeatureId>(1);
        ids.add(fid);
View Full Code Here


            public SimpleFeatureType getFeatureType() {
                return newSchema;
            }
           
            private Geometry diff(SimpleFeature f) {
                Geometry geom = (Geometry) f.getDefaultGeometry();
                FeatureIterator<SimpleFeature> i = diffFeatures.features();
                try {
                    while (i.hasNext()) {
                        SimpleFeature diff = i.next();
                        Geometry g = geom.difference((Geometry) diff.getDefaultGeometry());
                        if (g.isEmpty()) {
                            return null;
                        }
                        geom = g;
                    }
                } finally {
                    i.close();
                }
                return geom;
            }
           
            public SimpleFeature next() throws IOException, IllegalAttributeException, NoSuchElementException {
                SimpleFeature source=iter.next();
                Geometry geom = diff(source);
                if (geom == null || !hasNextCalled) {
                    throw new NoSuchElementException("Use hasNext()."); //$NON-NLS-1$
                }
               
                if (geom instanceof LineString) {
                    geom = geom.getFactory().createMultiLineString(new LineString[] {(LineString) geom});
                }
                if (geom instanceof Polygon) {
                    geom = geom.getFactory().createMultiPolygon(new Polygon[]{(Polygon) geom});
                }
                source.setDefaultGeometry(geom);
               
                hasNextCalled = false;
                return source;
            }

            public boolean hasNext() throws IOException {
                if (hasNextCalled) {
                    return iter.hasNext();
                }

                // pointer chase forward to the next different geometry
                try {
                    Geometry g = null;
                    while (g == null) {
                        if (!peek.hasNext()) {
                            return false;
                        }
                        SimpleFeature f = peek.next();
View Full Code Here

    assert this.line != null : "the line can't be null"; //$NON-NLS-1$
    assert this.gf != null : "the geometry factory can't be null"; //$NON-NLS-1$

    // use the Polygonizer to get the rings.
    List<Geometry> ringList = new ArrayList<Geometry>();
    Geometry multiLines =this.line.union();
    Polygonizer polygonizer = new Polygonizer();
    polygonizer.add(multiLines);
    Collection<Polygon> polyCollection = polygonizer.getPolygons();

    // add the rings to the ringList.
    for (Polygon pol : polyCollection) {

      Coordinate[] polCoord = pol.getExteriorRing().getCoordinates();

      LinearRing polygonRing = this.gf.createLinearRing(polCoord);
      ringList.add(polygonRing);
    }

    // get the remaining line.
    Geometry result = getRemainingLine(line.getCoordinates(), ringList);

    // create the output data.
    ResultRingExtractor outputData = new ResultRingExtractor(result, ringList);
    return outputData;
  }
View Full Code Here

   */
  private Geometry getRemainingLine(Coordinate[] originalCoord, List<Geometry> ringList) {

    List<Geometry> segmentsToAdd = new LinkedList<Geometry>();
    // apply the difference operation.
    Geometry result = this.line;
    for (Geometry ring : ringList) {

      result = result.difference(ring);
    }
    // union for nodded multilineStrings.
    result = SplitUtil.buildLineUnion(result);
    // seek for overlapped segments.
    for (int i = 0; i < originalCoord.length - 1; i++) {
View Full Code Here

   * @return The segments nodded to the actualResultLine if they can be
   *         nodded.
   */
  private Geometry nodSegments(List<Geometry> segmentsToAdd, List<Geometry> ringList, Geometry actualResultLine) {

    Geometry result = actualResultLine;
    // check if that lineString exist or is contained in any of
    // the rings.
    for (Geometry segment : segmentsToAdd) {

      assert segment.getCoordinates().length == 2 : "the segment should have 2 coordinates."; //$NON-NLS-1$
View Full Code Here

    assert line instanceof LineString || line instanceof MultiLineString : "Split line must be a line."; //$NON-NLS-1$
    assert geomToAddVertex instanceof Polygon || geomToAddVertex instanceof LineString
          || geomToAddVertex instanceof MultiPolygon || geomToAddVertex instanceof MultiLineString : "Input geometry has unexpected class."; //$NON-NLS-1$

    Geometry result = null;

    if (geomToAddVertex instanceof Polygon || geomToAddVertex instanceof MultiPolygon) {

      Polygon polygon;
      // cast to polygon, we know that geomToAddVertex only has one
View Full Code Here

   */
  private static Geometry addIntersectionVertexToPolygonGeometry polygonToAddVertex,
                              Geometry line,
                              List<Geometry> geomNeighborList) {

    Geometry result = null;

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

   *            The split line.
   * @return the geomToAddVertex with the intersection vertex added.
   */
  private static Geometry addIntersectionVertexToLine(Geometry lineToAddVertex, Geometry line) {

    Geometry result = null;

    List<Coordinate> shellCoordinates = null;
    GeometryFactory fc = lineToAddVertex.getFactory();
    Geometry boundary = lineToAddVertex.getBoundary();

    Coordinate[] boundaryCoordinates = boundary.getCoordinates();

    // add the intersection vertex to the shellCoordinates.
    shellCoordinates = addIntersection(boundaryCoordinates, line, fc, line);

    Coordinate[] shellClosed = shellCoordinates.toArray(new Coordinate[shellCoordinates.size()]);
View Full Code Here

    List<LinearRing> holesRing = new ArrayList<LinearRing>();
    List<Coordinate> holeCoordinates = null;
    for (int i = 0; i < holes.length; i++) {

      Geometry eachHole = fc.createLinearRing(holes[i].getCoordinates());
      Coordinate[] boundaryCoordinates = eachHole.getCoordinates();
      Coordinate[] holeClosed = null;

      for (Geometry neighbor : geomNeighborList) {

        // if it touch, add the intersection vertex.
        if (eachHole.touches(neighbor)) {

          // store the modified boundaryCoordinates for add more
          // vertex if there are.
          holeCoordinates = addIntersection(boundaryCoordinates, line, fc, neighbor);
          boundaryCoordinates = holeCoordinates.toArray(new Coordinate[holeCoordinates.size()]);
View Full Code Here

      LineString segment = fc.createLineString(segmentCoordinates);
      // if intersect, this is the vertex we need to add, so add it to the
      // result coordinates list.
      if (segment.intersects(line)) {

        Geometry point = segment.intersection(line);

        Geometry[] sorted = sortPoints(point, segment);
        // add all the points.
        for (int j = 0; j < sorted.length; j++) {
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.