qeDistances.put(qe, qe.toLineSegment().getLength()); eV.setBorder(true); edge = new Edge(i, s, oV, eV, true); if (s.getLength() < this.threshold) { this.shortLengths.put(i, edge); } else { Entry<Integer, Edge> entry = this.lengths.firstEntry(); int ind = entry.getKey(); if (entry.getValue().getGeometry().getLength() > this.threshold) { index = ind; e = entry.getValue(); if (eB.getGeometry().getLength() < this.threshold) { this.shortLengths.put(eB.getId(), eB); } else { this.lengths.put(eB.getId(), eB); if (eC.getGeometry().getLength() < this.threshold) { this.shortLengths.put(eC.getId(), eC); } else { if (eA.getGeometry().getLength() < this.threshold) { this.shortLengths.put(eA.getId(), eA); } else { this.lengths.put(eA.getId(), eA); if (eC.getGeometry().getLength() < this.threshold) {
public SplitSegment(LineSegment seg) { this.seg = seg; segLen = seg.getLength(); }
private double segmentNearestMeasure(LineSegment seg, Coordinate inputPt, double segmentStartMeasure) { // found new minimum, so compute location distance of point double projFactor = seg.projectionFactor(inputPt); if (projFactor <= 0.0) return segmentStartMeasure; if (projFactor <= 1.0) return segmentStartMeasure + projFactor * seg.getLength(); // projFactor > 1.0 return segmentStartMeasure + seg.getLength(); } }
public Geometry getGeometry() { int level = recursionLevelForSize(numPts); LineSegment baseLine = getSquareBaseLine(); Coordinate[] pts = getBoundary(level, baseLine.getCoordinate(0), baseLine.getLength()); return geomFactory.createPolygon( geomFactory.createLinearRing(pts), null); }
public SplitSegment(LineSegment seg) { this.seg = seg; segLen = seg.getLength(); }
/** * A basic strategy for finding split points when nothing extra is known about the geometry of * the situation. * * @param seg the encroached segment * @param encroachPt the encroaching point * @return the point at which to split the encroached segment */ public Coordinate findSplitPoint(Segment seg, Coordinate encroachPt) { LineSegment lineSeg = seg.getLineSegment(); double segLen = lineSeg.getLength(); double midPtLen = segLen / 2; SplitSegment splitSeg = new SplitSegment(lineSeg); Coordinate projPt = projectedSplitPoint(seg, encroachPt); /** * Compute the largest diameter (length) that will produce a split segment which is not * still encroached upon by the encroaching point (The length is reduced slightly by a * safety factor) */ double nonEncroachDiam = projPt.distance(encroachPt) * 2 * 0.8; // .99; double maxSplitLen = nonEncroachDiam; if (maxSplitLen > midPtLen) { maxSplitLen = midPtLen; } splitSeg.setMinimumLength(maxSplitLen); splitSeg.splitAt(projPt); return splitSeg.getSplitPoint(); }
/** * Densifies a coordinate sequence. * * @param pts * @param distanceTolerance * @return the densified coordinate sequence */ private static Coordinate[] densifyPoints(Coordinate[] pts, double distanceTolerance, PrecisionModel precModel) { LineSegment seg = new LineSegment(); CoordinateList coordList = new CoordinateList(); for (int i = 0; i < pts.length - 1; i++) { seg.p0 = pts[i]; seg.p1 = pts[i + 1]; coordList.add(seg.p0, false); double len = seg.getLength(); int densifiedSegCount = (int) (len / distanceTolerance) + 1; if (densifiedSegCount > 1) { double densifiedSegLen = len / densifiedSegCount; for (int j = 1; j < densifiedSegCount; j++) { double segFract = (j * densifiedSegLen) / len; Coordinate p = seg.pointAlong(segFract); precModel.makePrecise(p); coordList.add(p, false); } } } coordList.add(pts[pts.length - 1], false); return coordList.toCoordinateArray(); }
private double indexOfFromStart(Coordinate inputPt, double minIndex) { double minDistance = Double.MAX_VALUE; double ptMeasure = minIndex; double segmentStartMeasure = 0.0; LineSegment seg = new LineSegment(); LinearIterator it = new LinearIterator(linearGeom); while (it.hasNext()) { if (! it.isEndOfLine()) { seg.p0 = it.getSegmentStart(); seg.p1 = it.getSegmentEnd(); double segDistance = seg.distance(inputPt); double segMeasureToPt = segmentNearestMeasure(seg, inputPt, segmentStartMeasure); if (segDistance < minDistance && segMeasureToPt > minIndex) { ptMeasure = segMeasureToPt; minDistance = segDistance; } segmentStartMeasure += seg.getLength(); } it.next(); } return ptMeasure; }
private double segmentNearestMeasure(LineSegment seg, Coordinate inputPt, double segmentStartMeasure) { // found new minimum, so compute location distance of point double projFactor = seg.projectionFactor(inputPt); if (projFactor <= 0.0) return segmentStartMeasure; if (projFactor <= 1.0) return segmentStartMeasure + projFactor * seg.getLength(); // projFactor > 1.0 return segmentStartMeasure + seg.getLength(); } }
private Coordinate getControlPoint(LineSegment lineSeg) { double radius = lineSeg.getLength() * fraction; double radian = lineSeg.angle() + Math.toRadians(offsetDegree); double dx = lineSeg.p0.x + (Math.cos(radian) * radius); double dy = lineSeg.p0.y + (Math.sin(radian) * radius); return new Coordinate(dx, dy); } }
private void updateLength(LineSegment seg, Coordinate inputPt, double segStartLocationDistance) { double dist = seg.distance(inputPt); if (dist > minDistanceToPoint) return; minDistanceToPoint = dist; // found new minimum, so compute location distance of point double projFactor = seg.projectionFactor(inputPt); if (projFactor <= 0.0) locationLength = segStartLocationDistance; else if (projFactor <= 1.0) locationLength = segStartLocationDistance + projFactor * seg.getLength(); else locationLength = segStartLocationDistance + seg.getLength(); } }
private void computeLength(LineString line, Coordinate inputPt) { minDistanceToPoint = Double.MAX_VALUE; double baseLocationDistance = 0.0; Coordinate[] pts = line.getCoordinates(); LineSegment seg = new LineSegment(); for (int i = 0; i < pts.length - 1; i++) { seg.p0 = pts[i]; seg.p1 = pts[i + 1]; updateLength(seg, inputPt, baseLocationDistance); baseLocationDistance += seg.getLength(); } }
public Geometry getGeometry() { int level = recursionLevelForSize(numPts); LineSegment baseLine = getSquareBaseLine(); Coordinate[] pts = getBoundary(level, baseLine.getCoordinate(0), baseLine.getLength()); return geomFactory.createPolygon( geomFactory.createLinearRing(pts), null); }
qeLengths.put(qe, qe.toLineSegment().getLength()); nodeDestination.setBorder(true); edge = new HullEdge(edgeId, ls, nodeOrigin, nodeDestination, true); if (ls.getLength() < this.threshold) { this.ignoredEdges.put(edgeId, edge); } else { if(eA.getGeometry().getLength() > this.threshold){ this.consideredEdges.put(eA.getId(), eA); } else{ if(eB.getGeometry().getLength() > this.threshold){ this.consideredEdges.put(eB.getId(), eB); } else{
/** * A basic strategy for finding split points when nothing extra is known about the geometry of * the situation. * * @param seg the encroached segment * @param encroachPt the encroaching point * @return the point at which to split the encroached segment */ public Coordinate findSplitPoint(Segment seg, Coordinate encroachPt) { LineSegment lineSeg = seg.getLineSegment(); double segLen = lineSeg.getLength(); double midPtLen = segLen / 2; SplitSegment splitSeg = new SplitSegment(lineSeg); Coordinate projPt = projectedSplitPoint(seg, encroachPt); /** * Compute the largest diameter (length) that will produce a split segment which is not * still encroached upon by the encroaching point (The length is reduced slightly by a * safety factor) */ double nonEncroachDiam = projPt.distance(encroachPt) * 2 * 0.8; // .99; double maxSplitLen = nonEncroachDiam; if (maxSplitLen > midPtLen) { maxSplitLen = midPtLen; } splitSeg.setMinimumLength(maxSplitLen); splitSeg.splitAt(projPt); return splitSeg.getSplitPoint(); }
/** * Densifies a coordinate sequence. * * @param pts * @param distanceTolerance * @return the densified coordinate sequence */ private static Coordinate[] densifyPoints(Coordinate[] pts, double distanceTolerance, PrecisionModel precModel) { LineSegment seg = new LineSegment(); CoordinateList coordList = new CoordinateList(); for (int i = 0; i < pts.length - 1; i++) { seg.p0 = pts[i]; seg.p1 = pts[i + 1]; coordList.add(seg.p0, false); double len = seg.getLength(); int densifiedSegCount = (int) (len / distanceTolerance) + 1; if (densifiedSegCount > 1) { double densifiedSegLen = len / densifiedSegCount; for (int j = 1; j < densifiedSegCount; j++) { double segFract = (j * densifiedSegLen) / len; Coordinate p = seg.pointAlong(segFract); precModel.makePrecise(p); coordList.add(p, false); } } } coordList.add(pts[pts.length - 1], false); return coordList.toCoordinateArray(); }
private double indexOfFromStart(Coordinate inputPt, double minIndex) { double minDistance = Double.MAX_VALUE; double ptMeasure = minIndex; double segmentStartMeasure = 0.0; LineSegment seg = new LineSegment(); LinearIterator it = new LinearIterator(linearGeom); while (it.hasNext()) { if (! it.isEndOfLine()) { seg.p0 = it.getSegmentStart(); seg.p1 = it.getSegmentEnd(); double segDistance = seg.distance(inputPt); double segMeasureToPt = segmentNearestMeasure(seg, inputPt, segmentStartMeasure); if (segDistance < minDistance && segMeasureToPt > minIndex) { ptMeasure = segMeasureToPt; minDistance = segDistance; } segmentStartMeasure += seg.getLength(); } it.next(); } return ptMeasure; }
i++; segmentStartDistance = segmentEndDistance; segmentEndDistance = segmentStartDistance + segment.getLength();