private ShapePoint doMap(org.onebusaway.gtfs.model.ShapePoint rhs) { ShapePoint lhs = new ShapePoint(); lhs.setShapeId(AgencyAndIdMapper.mapAgencyAndId(rhs.getShapeId())); lhs.setSequence(rhs.getSequence()); lhs.setLat(rhs.getLat()); lhs.setLon(rhs.getLon()); lhs.setDistTraveled(rhs.getDistTraveled()); // Skip mapping of proxy // private transient StopTimeProxy proxy; if (rhs.getProxy() != null) { throw new IllegalStateException("Did not expect proxy to be set! Data: " + rhs); } return lhs; } }
private List<ShapePoint> deduplicateShapePoints(List<ShapePoint> shapePoints) { List<ShapePoint> deduplicated = new ArrayList<ShapePoint>(); ShapePoint prev = null; for (ShapePoint shapePoint : shapePoints) { if (prev == null || !(prev.getLat() == shapePoint.getLat() && prev.getLon() == shapePoint.getLon())) { deduplicated.add(shapePoint); } prev = shapePoint; } return deduplicated; } }
ShapePoint nsp = new ShapePoint(); nsp.setShapeId(newShapeId); nsp.setSequence(newIndex++); nsp.setLat(sp.getLat()); nsp.setLon(sp.getLon());
public static ShapePoint shapePoint(String id, int sequence, double lat, double lon) { ShapePoint point = new ShapePoint(); point.setId(sequence); point.setSequence(sequence); point.setLat(lat); point.setLon(lon); point.setShapeId(aid(id)); return point; }
private LineString getLineStringForShapeId(AgencyAndId shapeId) { LineString geometry = _geometriesByShapeId.get(shapeId); if (geometry != null) return geometry; List<ShapePoint> points = _dao.getShapePointsForShapeId(shapeId); Coordinate[] coordinates = new Coordinate[points.size()]; double[] distances = new double[points.size()]; boolean hasAllDistances = true; int i = 0; for (ShapePoint point : points) { coordinates[i] = new Coordinate(point.getLon(), point.getLat()); distances[i] = point.getDistTraveled(); if (!point.isDistTraveledSet()) hasAllDistances = false; i++; } /** * If we don't have distances here, we can't calculate them ourselves because we can't * assume the units will match */ if (!hasAllDistances) { distances = null; } CoordinateSequence sequence = new PackedCoordinateSequence.Float(coordinates, 2); geometry = _factory.createLineString(sequence); _geometriesByShapeId.put(shapeId, geometry); _distancesByShapeId.put(shapeId, distances); return geometry; }
int shapePointTo = getClosestShapePointToStop(points, lastStop); for (int index = shapePointFrom; index <= shapePointTo; ++index) { ShapePoint point = new ShapePoint(points.get(index)); point.setId(0); point.setShapeId(newShapeId); dao.saveEntity(point);
@Override public int compare(ShapePoint o1, ShapePoint o2) { int c = o1.getShapeId().compareTo(o2.getShapeId()); if (c == 0) c = o1.getSequence() - o2.getSequence(); return c; }
@Override protected void saveElementsForKey(GtfsMergeContext context, AgencyAndId shapeId) { GtfsRelationalDao source = context.getSource(); GtfsMutableRelationalDao target = context.getTarget(); for (ShapePoint shapePoint : source.getShapePointsForShapeId(shapeId)) { shapePoint.setId(0); shapePoint.setSequence(context.getNextSequenceCounter()); target.saveEntity(shapePoint); } }
@Override public ShapePoint get(int index) { if (index < 0 || index >= size) { throw new NoSuchElementException(); } ShapePoint shapePoint = new ShapePoint(); shapePoint.setProxy(new ShapePointProxyImpl(index)); return shapePoint; }
private List<ShapePoint> decode(String pointString) { double lat = 0; double lon = 0; int strIndex = 0; List<ShapePoint> points = new ArrayList<ShapePoint>(); while (strIndex < pointString.length()) { int[] rLat = decodeSignedNumberWithIndex(pointString, strIndex); lat = lat + rLat[0] * 1e-5; strIndex = rLat[1]; int[] rLon = decodeSignedNumberWithIndex(pointString, strIndex); lon = lon + rLon[0] * 1e-5; strIndex = rLon[1]; ShapePoint point = new ShapePoint(); point.setLat(lat); point.setLon(lon); points.add(point); } return points; }
point.setDistTraveled(ShapePoint.MISSING_VALUE); point.setSequence(index++); point.setShapeId(ashapeId);
@Override protected void renameKey(GtfsMergeContext context, AgencyAndId oldId, AgencyAndId newId) { GtfsRelationalDao source = context.getSource(); for (ShapePoint shapePoint : source.getShapePointsForShapeId(oldId)) { shapePoint.setShapeId(newId); } for (Trip trip : source.getTripsForShapeId(oldId)) { trip.setShapeId(newId); } }
@Override public int compareTo(ShapePoint o) { return this.getSequence() - o.getSequence(); } }
shapePoint.getShapeId().setAgencyId(reader.getDefaultAgencyId());
private List<ShapePoint> deduplicateShapePoints(List<ShapePoint> shapePoints) { List<ShapePoint> deduplicated = new ArrayList<ShapePoint>(); ShapePoint prev = null; for (ShapePoint shapePoint : shapePoints) { if (prev == null || !(prev.getLat() == shapePoint.getLat() && prev.getLon() == shapePoint.getLon())) { deduplicated.add(shapePoint); } prev = shapePoint; } return deduplicated; } }
public static ShapePoint shapePoint(String id, int sequence, double lat, double lon) { ShapePoint point = new ShapePoint(); point.setId(sequence); point.setSequence(sequence); point.setLat(lat); point.setLon(lon); point.setShapeId(aid(id)); return point; }
int shapePointTo = getClosestShapePointToStop(points, lastStop); for (int index = shapePointFrom; index <= shapePointTo; ++index) { ShapePoint point = new ShapePoint(points.get(index)); point.setId(0); point.setShapeId(newShapeId); dao.saveEntity(point);
@Override public int compare(ShapePoint o1, ShapePoint o2) { int c = o1.getShapeId().compareTo(o2.getShapeId()); if (c == 0) c = o1.getSequence() - o2.getSequence(); return c; }
@Override protected void saveElementsForKey(GtfsMergeContext context, AgencyAndId shapeId) { GtfsRelationalDao source = context.getSource(); GtfsMutableRelationalDao target = context.getTarget(); for (ShapePoint shapePoint : source.getShapePointsForShapeId(shapeId)) { shapePoint.setId(0); shapePoint.setSequence(context.getNextSequenceCounter()); target.saveEntity(shapePoint); } }
@Override public ShapePoint get(int index) { if (index < 0 || index >= size) { throw new NoSuchElementException(); } ShapePoint shapePoint = new ShapePoint(); shapePoint.setProxy(new ShapePointProxyImpl(index)); return shapePoint; }