Package org.osm2world.core.math

Examples of org.osm2world.core.math.PolygonWithHolesXZ


        holes.add(innerRing.closedNodeSequence);
        holesXZ.add(innerRing.getPolygon());
      }
     
      MapArea area = new MapArea(relation, outerRing.getNodeLoop(), holes,
          new PolygonWithHolesXZ(outerRing.getPolygon(), holesXZ));
     
      finishedPolygons.add(area);
     
      rings.remove(outerRing);
      rings.removeAll(innerRings);
View Full Code Here


      new ArrayList<SimplePolygonXZ>(holes.size());
    for (List<MapNode> hole : holes) {
      holePolygons.add(polygonFromMapNodeLoop(hole));
    }
   
    return new PolygonWithHolesXZ(outerPolygon, holePolygons);
       
  }
View Full Code Here

   
    boolean contains;
    boolean intersects;
   
    {
      final PolygonWithHolesXZ polygon = area.getPolygon();
     
      if (!line.isConnectedTo(area)) {
 
        intersects = polygon.intersects(segmentXZ);
        contains = !intersects && polygon.contains(segmentXZ);
       
      } else {
     
        /* check whether the line intersects the area somewhere
         * else than just at the common node(s).
         */
       
        intersects = false;
     
        double segmentLength = distance(segmentXZ.p1, segmentXZ.p2);
       
        for (VectorXZ pos : polygon.intersectionPositions(segmentXZ)) {
          if (distance(pos, segmentXZ.p1) > segmentLength / 100
              && distance(pos, segmentXZ.p2) > segmentLength / 100) {
            intersects = true;
            break;
          }
        }
 
        /* check whether the area contains the line's center.
         * Unless the line intersects the area outline,
         * this means that the area contains the line itself.
         */
             
        contains = !intersects && polygon.contains(segmentXZ.getCenter());
       
      }
     
    }
   
View Full Code Here

    boolean contains1 = false;
    boolean contains2 = false;
    boolean intersects = false;
   
    {
      final PolygonWithHolesXZ polygon1 = area1.getPolygon();
      final PolygonWithHolesXZ polygon2 = area2.getPolygon();
     
      /* determine common nodes */
     
      Set<VectorXZ> commonNodes = new HashSet<VectorXZ>();
      for (SimplePolygonXZ p : polygon1.getPolygons()) {
        commonNodes.addAll(p.getVertices());
      }
     
      Set<VectorXZ> nodes2 = new HashSet<VectorXZ>();
      for (SimplePolygonXZ p : polygon2.getPolygons()) {
        nodes2.addAll(p.getVertices());
      }
     
      commonNodes.retainAll(nodes2);
     
      /* check whether the areas' outlines intersects somewhere
       * else than just at the common node(s).
       */
     
      intersectionPosCheck:
      for (VectorXZ pos : polygon1.intersectionPositions(polygon2)) {
        boolean trueIntersection = true;
        for (VectorXZ commonNode : commonNodes) {
          if (distance(pos, commonNode) < 0.01) {
            trueIntersection = false;
          }
        }
        if (trueIntersection) {
          intersects = true;
          break intersectionPosCheck;
        }
      }

      /* check whether one area contains the other */
     
      if (polygon1.contains(polygon2.getOuter())) {
        contains1 = true;
      } else if (polygon2.contains(polygon1.getOuter())) {
        contains2 = true;
      }
                 
    }
   
View Full Code Here

        newOuter = insertIntoPolygon(newOuter, cap1part.p1, 0.2);
        newOuter = insertIntoPolygon(newOuter, cap1part.p2, 0.2);
        newOuter = insertIntoPolygon(newOuter, cap2part.p1, 0.2);
        newOuter = insertIntoPolygon(newOuter, cap2part.p2, 0.2);
       
        return new PolygonWithHolesXZ(
            newOuter.asSimplePolygon(),
            polygon.getHoles());
       
      }
View Full Code Here

        newOuter = insertIntoPolygon(newOuter, cap2part.p1, 0.2);
        newOuter = insertIntoPolygon(newOuter, cap2part.p2, 0.2);
       
        //TODO: add intersections of additional edges with outline?
       
        return new PolygonWithHolesXZ(
            newOuter.asSimplePolygon(),
            polygon.getHoles());
       
      }
View Full Code Here

          newOuter = insertIntoPolygon(newOuter, capPart.p1, 0.2);
          newOuter = insertIntoPolygon(newOuter, capPart.p2, 0.2);
        }

        //TODO: add intersections of additional edges with outline?
        return new PolygonWithHolesXZ(
            newOuter.asSimplePolygon(),
            polygon.getHoles());

      }
View Full Code Here

        }
       
        if (simplified.size() > 2) {
          try{
            simplified.add(simplified.get(0));
            simplePolygon = new PolygonWithHolesXZ(new SimplePolygonXZ(simplified),
                polygon.getHoles());
          } catch (InvalidGeometryException e) {
            System.err.print(e.getMessage());
            simplePolygon = polygon;
          }
View Full Code Here

        PolygonXZ newOuter = polygon.getOuter();
       
        newOuter = insertIntoPolygon(newOuter, ridge.p1, 0.2);
        newOuter = insertIntoPolygon(newOuter, ridge.p2, 0.2);
       
        return new PolygonWithHolesXZ(
            newOuter.asSimplePolygon(),
            polygon.getHoles());
       
      }
View Full Code Here

TOP

Related Classes of org.osm2world.core.math.PolygonWithHolesXZ

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.