Java Code Examples for com.vividsolutions.jts.geom.CoordinateList#add()
The following examples show how to use
com.vividsolutions.jts.geom.CoordinateList#add() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DiskLayout.java From Getaviz with Apache License 2.0 | 7 votes |
private void calculateRadiusForOuterCircles(Disk disk) { List<Disk> innerDisks = disk.getInnerDisks(); CoordinateList coordinates = new CoordinateList(); for (Disk d : innerDisks) { coordinates.add(d.getCoordinates(), false); } GeometryFactory geoFactory = new GeometryFactory(); MultiPoint innerCirclemultipoint = geoFactory.createMultiPoint(coordinates.toCoordinateArray()); MinimumBoundingCircle mbc = new MinimumBoundingCircle(innerCirclemultipoint); final double radius = mbc.getRadius(); disk.updatePosition(mbc.getCentre().x,mbc.getCentre().y); disk.setRadius(disk.getBorderWidth() + radius + calculateB(calculateD(disk.getMinArea(), radius), radius)); disk.setInnerRadius(radius); normalizePositionOfInnerCircles(disk); }
Example 2
Source File: RDLayout.java From Getaviz with Apache License 2.0 | 6 votes |
private static void calculateRadiusForOuterCircles(CircleWithInnerCircles outerCircle, List<CircleWithInnerCircles> innerCircles) { CoordinateList coordinates = new CoordinateList(); for (CircleWithInnerCircles circle : innerCircles) { coordinates.add(createCircle(circle.getCentre().x, circle.getCentre().y, circle.getRadius()).getCoordinates(), false); } GeometryFactory geoFactory = new GeometryFactory(); MultiPoint innerCirclemultipoint = geoFactory.createMultiPoint(coordinates.toCoordinateArray()); MinimumBoundingCircle mbc = new MinimumBoundingCircle(innerCirclemultipoint); // outerCircle.setCentre(centre); // outerCircle.setRadius(RING_WIDTH + radius + calculateB(calculateD(outerCircle.getMinArea(), radius), radius)); // normalizePositionOfInnerCircles(outerCircle, innerCircles); final double radius = mbc.getRadius(); final Point2D.Double centre = new Point2D.Double(mbc.getCentre().x, mbc.getCentre().y); outerCircle.setCentre(centre); if (((CircleWithInnerCircles)outerCircle).getLevel()==1){ outerCircle.setRadius(outerCircle.getRingWidth() + radius); }else{ outerCircle.setRadius(outerCircle.getRingWidth() + radius + calculateB(calculateD(outerCircle.getMinArea(), radius), radius)); } normalizePositionOfInnerCircles(outerCircle, innerCircles); }
Example 3
Source File: EdgeString.java From jts with GNU Lesser General Public License v2.1 | 6 votes |
private Coordinate[] getCoordinates() { if (coordinates == null) { int forwardDirectedEdges = 0; int reverseDirectedEdges = 0; CoordinateList coordinateList = new CoordinateList(); for (Iterator i = directedEdges.iterator(); i.hasNext();) { LineMergeDirectedEdge directedEdge = (LineMergeDirectedEdge) i.next(); if (directedEdge.getEdgeDirection()) { forwardDirectedEdges++; } else { reverseDirectedEdges++; } coordinateList.add(((LineMergeEdge) directedEdge.getEdge()).getLine() .getCoordinates(), false, directedEdge.getEdgeDirection()); } coordinates = coordinateList.toCoordinateArray(); if (reverseDirectedEdges > forwardDirectedEdges) { CoordinateArrays.reverse(coordinates); } } return coordinates; }
Example 4
Source File: LineDissolver.java From jts with GNU Lesser General Public License v2.1 | 6 votes |
private void buildRing(HalfEdge eStartRing) { CoordinateList line = new CoordinateList(); HalfEdge e = eStartRing; line.add(e.orig().copy(), false); // scan along the path until a node is found (if one exists) while (e.sym().degree() == 2) { HalfEdge eNext = e.next(); // check if edges form a ring - if so, we're done if (eNext == eStartRing) break; // add point to line, and move to next edge line.add(eNext.orig().copy(), false); e = eNext; } // add final node line.add(e.dest().copy(), false); // store the scanned line addLine(line); }
Example 5
Source File: VWLineSimplifier.java From jts with GNU Lesser General Public License v2.1 | 5 votes |
public Coordinate[] getCoordinates() { CoordinateList coords = new CoordinateList(); VWLineSimplifier.VWVertex curr = this; do { coords.add(curr.pt, false); curr = curr.next; } while (curr != null); return coords.toCoordinateArray(); }
Example 6
Source File: KdTree.java From jts with GNU Lesser General Public License v2.1 | 5 votes |
/** * Converts a collection of {@link KdNode}s * to an array of {@link Coordinate}s, * specifying whether repeated nodes should be represented * by multiple coordinates. * * @param kdnodes a collection of nodes * @param includeRepeated true if repeated nodes should * be included multiple times * @return an array of the coordinates represented by the nodes */ public static Coordinate[] toCoordinates(Collection kdnodes, boolean includeRepeated) { CoordinateList coord = new CoordinateList(); for (Iterator it = kdnodes.iterator(); it.hasNext();) { KdNode node = (KdNode) it.next(); int count = includeRepeated ? node.getCount() : 1; for (int i = 0; i < count; i++) { coord.add(node.getCoordinate(), true); } } return coord.toCoordinateArray(); }
Example 7
Source File: LineDissolver.java From jts with GNU Lesser General Public License v2.1 | 5 votes |
/** * Builds a line starting from the given edge. * The start edge origin is a node (valence = 1 or >= 3), * unless it is part of a pure ring. * A pure ring has no other incident lines. * In this case the start edge may occur anywhere on the ring. * * The line is built up to the next node encountered, * or until the start edge is re-encountered * (which happens if the edges form a ring). * * @param eStart */ private void buildLine(HalfEdge eStart) { CoordinateList line = new CoordinateList(); DissolveHalfEdge e = (DissolveHalfEdge) eStart; ringStartEdge = null; MarkHalfEdge.markBoth(e); line.add(e.orig().copy(), false); // scan along the path until a node is found (if one exists) while (e.sym().degree() == 2) { updateRingStartEdge(e); DissolveHalfEdge eNext = (DissolveHalfEdge) e.next(); // check if edges form a ring - if so, we're done if (eNext == eStart) { buildRing(ringStartEdge); return; } // add point to line, and move to next edge line.add(eNext.orig().copy(), false); e = eNext; MarkHalfEdge.markBoth(e); } // add final node line.add(e.dest().copy(), false); // queue up the final node edges stackEdges(e.sym()); // store the scanned line addLine(line); }