private Stop doMap(org.onebusaway.gtfs.model.Stop rhs) { Stop lhs = new Stop(); lhs.setId(mapAgencyAndId(rhs.getId())); lhs.setName(rhs.getName()); lhs.setLat(rhs.getLat()); lhs.setLon(rhs.getLon()); lhs.setCode(rhs.getCode()); lhs.setDesc(rhs.getDesc()); lhs.setZoneId(rhs.getZoneId()); lhs.setUrl(rhs.getUrl()); lhs.setLocationType(rhs.getLocationType()); lhs.setParentStation(rhs.getParentStation()); lhs.setWheelchairBoarding(rhs.getWheelchairBoarding()); lhs.setDirection(rhs.getDirection()); lhs.setTimezone(rhs.getTimezone()); lhs.setVehicleType(rhs.getVehicleType()); lhs.setPlatformCode(rhs.getPlatformCode()); return lhs; } }
@Override public double score(GtfsMergeContext context, Stop source, Stop target) { double distance = distance(source.getLat(), source.getLon(), target.getLat(), target.getLon()); if (distance < 50) { return 1.0; } else if (distance < 100) { return 0.75; } else if (distance < 500) { return 0.5; } else { return 0.0; } }
@Override public double score(GtfsMergeContext context, Stop source, Stop target) { double distance = distance(source.getLat(), source.getLon(), target.getLat(), target.getLon()); if (distance < 50) { return 1.0; } else if (distance < 100) { return 0.75; } else if (distance < 500) { return 0.5; } else { return 0.0; } }
public Geometry getGeometry() { if (geometry == null) { GeometryFactory factory = new GeometryFactory(new PrecisionModel( PrecisionModel.FLOATING), 4326); Coordinate c1 = new Coordinate(start.getLon(), start.getLat()); Coordinate c2 = new Coordinate(end.getLon(), end.getLat()); geometry = factory.createLineString(new Coordinate[] { c1, c2 }); } return geometry; }
private int getClosestShapePointToStop(List<ShapePoint> points, Stop stop) { int minIndex = -1; double minDistance = Double.POSITIVE_INFINITY; for (int i = 0; i < points.size(); ++i) { ShapePoint point = points.get(i); double dx = point.getLon() - stop.getLon(); double dy = point.getLat() - stop.getLat(); double d = Math.sqrt(dx * dx + dy * dy); if (d < minDistance) { minIndex = i; minDistance = d; } } return minIndex; }
private int getClosestShapePointToStop(List<ShapePoint> points, Stop stop) { int minIndex = -1; double minDistance = Double.POSITIVE_INFINITY; for (int i = 0; i < points.size(); ++i) { ShapePoint point = points.get(i); double dx = point.getLon() - stop.getLon(); double dy = point.getLat() - stop.getLat(); double d = Math.sqrt(dx * dx + dy * dy); if (d < minDistance) { minIndex = i; minDistance = d; } } return minIndex; }
public Geometry getGeometry() { if (geometry == null) { GeometryFactory factory = new GeometryFactory(new PrecisionModel( PrecisionModel.FLOATING), 4326); Stop stop1 = start.getStop(); Stop stop2 = end.getStop(); Coordinate c1 = new Coordinate(stop1.getLon(), stop1.getLat()); Coordinate c2 = new Coordinate(stop2.getLon(), stop2.getLat()); geometry = factory.createLineString(new Coordinate[] { c1, c2 }); } return geometry; }
@PostConstruct public void initialize() { Collection<Stop> stops = _dao.getAllStops(); if (stops.size() == 0) { _tree = null; return; } _tree = new STRtree(stops.size()); for (Stop stop : stops) { float x = (float) stop.getLon(); float y = (float) stop.getLat(); Envelope env = new Envelope(x, x, y, y); _tree.insert(env, stop.getId()); } _tree.build(); }
private void loadStops(Graph graph) { for (Stop stop : _dao.getAllStops()) { graph.addVertex(new TransitStop(id(stop.getId()), stop.getLon(), stop.getLat(), stop.getName(), stop.getId().getId(), stop)); } } /**
private Stop createStop(Stop stop, int locationType, int wheelchairAccessible, String suffix) { if (stop == null) return null; Stop entrance = new Stop(); AgencyAndId id = new AgencyAndId(); id.setAgencyId(agencyId); id.setId(stop.getId().getId() + "-" + suffix); entrance.setId(id); entrance.setName(stop.getName()); entrance.setLat(stop.getLat()); entrance.setLon(stop.getLon()); entrance.setLocationType(locationType); entrance.setWheelchairBoarding(wheelchairAccessible); entrance.setParentStation(stop.getId().getId()); newStops.add(entrance); return entrance; }
private StopBean fillStopBean(Stop stop, StopBean bean) { bean.setId(ApplicationBeanLibrary.getId(stop.getId())); bean.setLat(stop.getLat()); bean.setLon(stop.getLon()); StopNarrative stopNarrative = _narrativeService.getStopForId(stop.getId()); if (stopNarrative != null) bean.setDirection(stopNarrative.getDireciton()); bean.setName(stop.getName()); bean.setCode(StringLibrary.getBestName(stop.getCode(), stop.getId().getId())); bean.setLocationType(stop.getLocationType()); return bean; }