use of org.onebusaway.geospatial.model.CoordinatePoint in project onebusaway-application-modules by camsys.
the class UTMProjectionTest method testMultiProjection.
@Test
public void testMultiProjection() {
assertUTMPoint(47.65458077, -122.30502529, 552186.99, 5278143.40);
assertUTMPoint(47.66933, -122.289114, 553366.76, 5279793.45);
List<CoordinatePoint> points = new ArrayList<CoordinatePoint>();
points.add(new CoordinatePoint(47.65458077, -122.30502529));
points.add(new CoordinatePoint(47.66933, -122.289114));
List<XYPoint> results = new ArrayList<XYPoint>();
UTMProjection projection = new UTMProjection(10);
projection.forward(points, results, 2);
XYPoint p0 = results.get(0);
XYPoint p1 = results.get(1);
assertEquals(552186.99, p0.getX(), 0.01);
assertEquals(5278143.40, p0.getY(), 0.01);
assertEquals(553366.76, p1.getX(), 0.01);
assertEquals(5279793.45, p1.getY(), 0.01);
}
use of org.onebusaway.geospatial.model.CoordinatePoint in project onebusaway-application-modules by camsys.
the class PolylineEncoder method createEncodings.
/**
* If level < 0, then {@link EncodedPolylineBean#getLevels()} will be null.
*
* @param points
* @param level
* @return
*/
public static EncodedPolylineBean createEncodings(Iterable<CoordinatePoint> points, int level) {
StringBuilder encodedPoints = new StringBuilder();
StringBuilder encodedLevels = new StringBuilder();
int plat = 0;
int plng = 0;
int count = 0;
for (CoordinatePoint trackpoint : points) {
int late5 = floor1e5(trackpoint.getLat());
int lnge5 = floor1e5(trackpoint.getLon());
int dlat = late5 - plat;
int dlng = lnge5 - plng;
plat = late5;
plng = lnge5;
encodedPoints.append(encodeSignedNumber(dlat)).append(encodeSignedNumber(dlng));
if (level >= 0)
encodedLevels.append(encodeNumber(level));
count++;
}
String pointsString = encodedPoints.toString();
String levelsString = level >= 0 ? encodedLevels.toString() : null;
return new EncodedPolylineBean(pointsString, levelsString, count);
}
use of org.onebusaway.geospatial.model.CoordinatePoint in project onebusaway-application-modules by camsys.
the class SphericalGeometryLibrary method projectPointToSegmentAppropximate.
/**
* Note that this is an approximate method at best that will perform
* increasingly worse as the distance between the points increases.
*
* @param point
* @param segmentStart
* @param segmentEnd
* @return
*/
public static CoordinatePoint projectPointToSegmentAppropximate(CoordinatePoint point, CoordinatePoint segmentStart, CoordinatePoint segmentEnd) {
XYPoint pPoint = new XYPoint(point.getLon(), point.getLat());
XYPoint pSegmentStart = new XYPoint(segmentStart.getLon(), segmentStart.getLat());
XYPoint pSegmentEnd = new XYPoint(segmentEnd.getLon(), segmentEnd.getLat());
XYPoint pResult = GeometryLibrary.projectPointToSegment(pPoint, pSegmentStart, pSegmentEnd);
return new CoordinatePoint(pResult.getY(), pResult.getX());
}
use of org.onebusaway.geospatial.model.CoordinatePoint in project onebusaway-application-modules by camsys.
the class DistanceAlongShapeLibrary method assignmentSanityCheck.
private void assignmentSanityCheck(ShapePoints shapePoints, List<StopTimeEntryImpl> stopTimes, List<List<PointAndIndex>> possibleAssignments) throws DistanceAlongShapeException {
int stIndex = 0;
for (List<PointAndIndex> assignments : possibleAssignments) {
if (assignments.isEmpty()) {
StopTimeEntry stopTime = stopTimes.get(stIndex);
throw new InvalidStopToShapeMappingException(stopTime.getTrip());
}
Min<PointAndIndex> m = new Min<PointAndIndex>();
for (PointAndIndex pindex : assignments) m.add(pindex.distanceFromTarget, pindex);
if (m.getMinValue() > _maxDistanceFromStopToShapePoint) {
StopTimeEntry stopTime = stopTimes.get(stIndex);
PointAndIndex pindex = m.getMinElement();
CoordinatePoint point = shapePoints.getPointForIndex(pindex.index);
throw new StopIsTooFarFromShapeException(stopTime, pindex, point);
}
stIndex++;
}
}
use of org.onebusaway.geospatial.model.CoordinatePoint in project onebusaway-application-modules by camsys.
the class GtfsComputePolylineBoundaryForStopsMain method printLineString.
private void printLineString(PrintWriter out, UTMProjection proj, LineString line, boolean latFirst) {
for (int i = 0; i < line.getNumPoints(); i++) {
Point point = line.getPointN(i);
XYPoint p = new XYPoint(point.getX(), point.getY());
CoordinatePoint c = proj.reverse(p);
if (latFirst)
out.println(c.getLat() + " " + c.getLon());
else
out.println(c.getLon() + " " + c.getLat());
}
}
Aggregations