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 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; }
/**** * {@link List} Interface ****/ @Override public boolean add(ShapePoint shapePoint) { int index = size; size++; ensureCapacity(size); shapeIds[index] = shapePoint.getShapeId(); sequences[index] = shapePoint.getSequence(); lats[index] = shapePoint.getLat(); lons[index] = shapePoint.getLon(); distTraveled[index] = shapePoint.getDistTraveled(); return true; }
/**** * {@link List} Interface ****/ @Override public boolean add(ShapePoint shapePoint) { int index = size; size++; ensureCapacity(size); shapeIds[index] = shapePoint.getShapeId(); sequences[index] = shapePoint.getSequence(); lats[index] = shapePoint.getLat(); lons[index] = shapePoint.getLon(); distTraveled[index] = shapePoint.getDistTraveled(); return true; }