this.coordinates.put(v.getCoordinate(), iV); this.vertices.put(iV, new Vertex(iV, v.getCoordinate())); iV++;
/** * Tests whether the point pt is contained in the triangle defined by 3 * {@link Vertex}es. * * @param tri * an array containing at least 3 Vertexes * @param pt * the point to test * @return true if the point is contained in the triangle */ public static boolean contains(Vertex[] tri, Coordinate pt) { Coordinate[] ring = new Coordinate[] { tri[0].getCoordinate(), tri[1].getCoordinate(), tri[2].getCoordinate(), tri[0].getCoordinate() }; return CGAlgorithms.isPointInRing(pt, ring); }
public static Geometry toPolygon(Vertex[] v) { 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; }
private Coordinate[] getPointArray() { Coordinate[] pts = new Coordinate[initialVertices.size() + segVertices.size()]; int index = 0; for (Iterator i = initialVertices.iterator(); i.hasNext();) { Vertex v = (Vertex) i.next(); pts[index++] = v.getCoordinate(); } for (Iterator i2 = segVertices.iterator(); i2.hasNext();) { Vertex v = (Vertex) i2.next(); pts[index++] = v.getCoordinate(); } return pts; }
/** * Converts this edge to a WKT two-point <tt>LINESTRING</tt> indicating * the geometry of this edge. * * @return a String representing this edge's geometry */ public String toString() { Coordinate p0 = vertex.getCoordinate(); Coordinate p1 = dest().getCoordinate(); return WKTWriter.toLineString(p0, p1); } }
/** * Creates a {@link LineSegment} representing the * geometry of this edge. * * @return a LineSegment */ public LineSegment toLineSegment() { return new LineSegment(vertex.getCoordinate(), dest().getCoordinate()); }
public Coordinate[] getCoordinates() { Coordinate[] pts = new Coordinate[4]; for (int i = 0; i < 3; i++) { pts[i] = edge[i].orig().getCoordinate(); } pts[3] = new Coordinate(pts[0]); return pts; }
public void getEdgeSegment(int i, LineSegment seg) { seg.p0 = edge[i].orig().getCoordinate(); int nexti = (i + 1) % 3; seg.p1 = edge[nexti].orig().getCoordinate(); }
public boolean equals(Vertex _x, double tolerance) { if (p.distance(_x.getCoordinate()) < tolerance) { return true; } else { return false; } }
public Coordinate getCoordinate(int i) { return edge[i].orig().getCoordinate(); }
private static Envelope computeVertexEnvelope(Collection vertices) { Envelope env = new Envelope(); for (Iterator i = vertices.iterator(); i.hasNext();) { Vertex v = (Vertex) i.next(); env.expandToInclude(v.getCoordinate()); } return env; }
/** * Gets the length of the geometry of this quadedge. * * @return the length of the quadedge */ public double getLength() { return orig().getCoordinate().distance(dest().getCoordinate()); }
public static Geometry toPolygon(QuadEdge[] e) { 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; }
/** * Tests whether the point pt is contained in the triangle defined by 3 * {@link QuadEdge}es. * * @param tri * an array containing at least 3 QuadEdges * @param pt * the point to test * @return true if the point is contained in the triangle */ public static boolean contains(QuadEdge[] tri, Coordinate pt) { Coordinate[] ring = new Coordinate[] { tri[0].orig().getCoordinate(), tri[1].orig().getCoordinate(), tri[2].orig().getCoordinate(), tri[0].orig().getCoordinate() }; return CGAlgorithms.isPointInRing(pt, ring); }
/** * Tests if this quadedge and another have the same line segment geometry * with the same orientation. * * @param qe a quadege * @return true if the quadedges are based on the same line segment */ public boolean equalsOriented(QuadEdge qe) { if (orig().getCoordinate().equals2D(qe.orig().getCoordinate()) && dest().getCoordinate().equals2D(qe.dest().getCoordinate())) return true; return false; }
/** * Gets the geometry for the edges in the subdivision as a {@link MultiLineString} * containing 2-point lines. * * @param geomFact the GeometryFactory to use * @return a MultiLineString */ public Geometry getEdges(GeometryFactory geomFact) { List quadEdges = getPrimaryEdges(false); LineString[] edges = new LineString[quadEdges.size()]; int i = 0; for (Iterator it = quadEdges.iterator(); it.hasNext();) { QuadEdge qe = (QuadEdge) it.next(); edges[i++] = geomFact.createLineString(new Coordinate[] { qe.orig().getCoordinate(), qe.dest().getCoordinate() }); } return geomFact.createMultiLineString(edges); }
/** * Tests whether a {@link Coordinate} lies on a {@link QuadEdge}, up to a * tolerance determined by the subdivision tolerance. * * @param e * a QuadEdge * @param p * a point * @return true if the vertex lies on the edge */ public boolean isOnEdge(QuadEdge e, Coordinate p) { seg.setCoordinates(e.orig().getCoordinate(), e.dest().getCoordinate()); double dist = seg.distance(p); // heuristic (hack?) return dist < edgeCoincidenceTolerance; }
/** * Gets the primary edge of this quadedge and its <tt>sym</tt>. * The primary edge is the one for which the origin * and destination coordinates are ordered * according to the standard {@link Coordinate} ordering * * @return the primary quadedge */ public QuadEdge getPrimary() { if (orig().getCoordinate().compareTo(dest().getCoordinate()) <= 0) return this; else return sym(); }
public void visit(QuadEdge[] triEdges) { Coordinate a = triEdges[0].orig().getCoordinate(); Coordinate b = triEdges[1].orig().getCoordinate(); Coordinate c = triEdges[2].orig().getCoordinate(); // TODO: choose the most accurate circumcentre based on the edges Coordinate cc = Triangle.circumcentre(a, b, c); Vertex ccVertex = new Vertex(cc); // save the circumcentre as the origin for the dual edges originating in this triangle for (int i = 0; i < 3; i++) { triEdges[i].rot().setOrig(ccVertex); } } }
public void visit(QuadEdge[] triEdges) { coordList.clear(); for (int i = 0; i < 3; i++) { Vertex v = triEdges[i].orig(); coordList.add(v.getCoordinate()); } if (coordList.size() > 0) { coordList.closeRing(); Coordinate[] pts = coordList.toCoordinateArray(); if (pts.length != 4) { //checkTriangleSize(pts); return; } triCoords.add(pts); } }