@Override public boolean is3D() { return wrappedPointList.is3D(); }
public static String encodePolyline(PointList poly) { if (poly.isEmpty()) return ""; return encodePolyline(poly, poly.is3D()); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); for (int i = 0; i < getSize(); i++) { if (i > 0) sb.append(", "); sb.append('('); sb.append(getLatitude(i)); sb.append(','); sb.append(getLongitude(i)); if (this.is3D()) { sb.append(','); sb.append(getElevation(i)); } sb.append(')'); } return sb.toString(); }
/** * This method does a deep copy of this object for the specified range. * * @param from the copying of the old PointList starts at this index * @param end the copying of the old PointList ends at the index before (i.e. end is exclusive) */ public PointList copy(int from, int end) { if (from > end) throw new IllegalArgumentException("from must be smaller or equal to end"); if (from < 0 || end > getSize()) throw new IllegalArgumentException("Illegal interval: " + from + ", " + end + ", size:" + getSize()); PointList thisPL = this; if (this instanceof ShallowImmutablePointList) { ShallowImmutablePointList spl = (ShallowImmutablePointList) this; thisPL = spl.wrappedPointList; from = spl.fromOffset + from; end = spl.fromOffset + end; } int len = end - from; PointList copyPL = new PointList(len, is3D()); copyPL.size = len; copyPL.isImmutable = isImmutable(); System.arraycopy(thisPL.latitudes, from, copyPL.latitudes, 0, len); System.arraycopy(thisPL.longitudes, from, copyPL.longitudes, 0, len); if (is3D()) System.arraycopy(thisPL.elevations, from, copyPL.elevations, 0, len); return copyPL; }
public String createGPX(String trackName, long startTimeMillis, String version) { boolean includeElevation = size() > 0 && get(0).getPoints().is3D(); return createGPX(trackName, startTimeMillis, includeElevation, true, true, true, version); }
@Override public boolean equals(Object obj) { if (obj == null) return false; PointList other = (PointList) obj; if (this.isEmpty() && other.isEmpty()) return true; if (this.getSize() != other.getSize() || this.is3D() != other.is3D()) return false; for (int i = 0; i < size(); i++) { if (!equalsEps(getLatitude(i), other.getLatitude(i))) return false; if (!equalsEps(getLongitude(i), other.getLongitude(i))) return false; if (this.is3D() && !equalsEps(getElevation(i), other.getElevation(i))) return false; } return true; }
public double calcDistance(DistanceCalc calc) { double prevLat = Double.NaN; double prevLon = Double.NaN; double prevEle = Double.NaN; double dist = 0; for (int i = 0; i < size(); i++) { if (i > 0) { if (is3D()) dist += distCalc3D.calcDist(prevLat, prevLon, prevEle, getLat(i), getLon(i), getEle(i)); else dist += calc.calcDist(prevLat, prevLon, getLat(i), getLon(i)); } prevLat = getLat(i); prevLon = getLon(i); if (is3D()) prevEle = getEle(i); } return dist; }
/** * @return converted tower node */ private int handlePillarNode(int tmpNode, long osmId, PointList pointList, boolean convertToTowerNode) { tmpNode = tmpNode - 3; double lat = pillarInfo.getLatitude(tmpNode); double lon = pillarInfo.getLongitude(tmpNode); double ele = pillarInfo.getElevation(tmpNode); if (lat == Double.MAX_VALUE || lon == Double.MAX_VALUE) throw new RuntimeException("Conversion pillarNode to towerNode already happended!? " + "osmId:" + osmId + " pillarIndex:" + tmpNode); if (convertToTowerNode) { // convert pillarNode type to towerNode, make pillar values invalid pillarInfo.setNode(tmpNode, Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE); tmpNode = addTowerNode(osmId, lat, lon, ele); } else if (pointList.is3D()) pointList.add(lat, lon, ele); else pointList.add(lat, lon); return (int) tmpNode; }
/** * Clones this PointList. If this PointList was immutable, the cloned will be mutable. If this PointList was a * ShallowImmutablePointList, the cloned PointList will be a regular PointList. */ public PointList clone(boolean reverse) { PointList clonePL = new PointList(getSize(), is3D()); if (is3D()) for (int i = 0; i < getSize(); i++) { clonePL.add(getLatitude(i), getLongitude(i), getElevation(i)); } else for (int i = 0; i < getSize(); i++) { clonePL.add(getLatitude(i), getLongitude(i)); } if (reverse) clonePL.reverse(); return clonePL; }
/** * @return This method returns a list of gpx entries where the time (in millis) is relative to * the first which is 0. */ public List<GPXEntry> createGPXList() { if (isEmpty()) return Collections.emptyList(); List<GPXEntry> gpxList = new ArrayList<>(); long timeOffset = 0; for (int i = 0; i < size() - 1; i++) { Instruction prevInstr = (i > 0) ? get(i - 1) : null; boolean instrIsFirst = prevInstr == null; Instruction nextInstr = get(i + 1); nextInstr.checkOne(); // current instruction does not contain last point which is equals to first point of next instruction: timeOffset = get(i).fillGPXList(gpxList, timeOffset, prevInstr, nextInstr, instrIsFirst); } Instruction lastI = get(size() - 1); if (lastI.points.size() != 1) throw new IllegalStateException("Last instruction must have exactly one point but was " + lastI.points.size()); double lastLat = lastI.getFirstLat(), lastLon = lastI.getFirstLon(), lastEle = lastI.getPoints().is3D() ? lastI.getFirstEle() : Double.NaN; gpxList.add(new GPXEntry(lastLat, lastLon, lastEle, timeOffset)); return gpxList; }
double prevLat = pointList.getLatitude(0); double prevLon = pointList.getLongitude(0); double prevEle = pointList.is3D() ? pointList.getElevation(0) : Double.NaN; double lat, lon, ele = Double.NaN; PointList pillarNodes = new PointList(pointList.getSize() - 2, nodeAccess.is3D()); if (pointList.is3D()) { ele = pointList.getElevation(i); if (!distCalc.isCrossBoundary(lon, prevLon)) prevLon = lon; if (nodes > 2 && i < nodes - 1) { if (pillarNodes.is3D()) pillarNodes.add(lat, lon, ele); else
double lon = points.getLongitude(0); double ele = Double.NaN; boolean is3D = points.is3D(); if (is3D) ele = points.getElevation(0);
PointList tmpPoints = path.calcPoints(); if (fullPoints.isEmpty()) fullPoints = new PointList(tmpPoints.size(), tmpPoints.is3D());
@Override public void applyWayTags(ReaderWay way, EdgeIteratorState edge) { PointList pl = edge.fetchWayGeometry(3); if (!pl.is3D()) throw new IllegalStateException("To support speed calculation based on elevation data it is necessary to enable import of it.");
@Override public boolean is3D() { return wrappedPointList.is3D(); }
public static String encodePolyline(PointList poly) { if (poly.isEmpty()) return ""; return encodePolyline(poly, poly.is3D()); }
public String createGPX( String trackName, long startTimeMillis ) { boolean includeElevation = getSize() > 0 ? get(0).getPoints().is3D() : false; return createGPX(trackName, startTimeMillis, includeElevation, true, true, true); }
public String createGPX(String trackName, long startTimeMillis) { boolean includeElevation = getSize() > 0 ? get(0).getPoints().is3D() : false; return createGPX(trackName, startTimeMillis, includeElevation, true, true, true); }
public String createGPX(String trackName, long startTimeMillis, String version) { boolean includeElevation = size() > 0 && get(0).getPoints().is3D(); return createGPX(trackName, startTimeMillis, includeElevation, true, true, true, version); }
/** * Clones this PointList. If this PointList was immutable, the cloned will be mutable. If this PointList was a * ShallowImmutablePointList, the cloned PointList will be a regular PointList. */ public PointList clone(boolean reverse) { PointList clonePL = new PointList(getSize(), is3D()); if (is3D()) for (int i = 0; i < getSize(); i++) { clonePL.add(getLatitude(i), getLongitude(i), getElevation(i)); } else for (int i = 0; i < getSize(); i++) { clonePL.add(getLatitude(i), getLongitude(i)); } if (reverse) clonePL.reverse(); return clonePL; }