use of org.locationtech.jts.geom.LineString in project series-rest-api by 52North.
the class GeoJSONTest method testLineStringWithZCoordinate.
@Test
public void testLineStringWithZCoordinate() throws GeoJSONException {
LineString geometry = randomLineString(CRSUtils.EPSG_WGS84);
geometry.apply(new RandomZCoordinateFilter());
geometry.geometryChanged();
readWriteTest(geometry);
}
use of org.locationtech.jts.geom.LineString in project graphhopper by graphhopper.
the class GTFSFeed method getTripGeometry.
/**
* Returns a trip geometry object (LineString) for a given trip id.
* If the trip has a shape reference, this will be used for the geometry.
* Otherwise, the ordered stoptimes will be used.
*
* @param trip_id trip id of desired trip geometry
* @return the LineString representing the trip geometry.
* @see LineString
*/
public LineString getTripGeometry(String trip_id) {
CoordinateList coordinates = new CoordinateList();
LineString ls = null;
Trip trip = trips.get(trip_id);
// If trip has shape_id, use it to generate geometry.
if (trip.shape_id != null) {
Shape shape = getShape(trip.shape_id);
if (shape != null)
ls = shape.geometry;
}
// Use the ordered stoptimes.
if (ls == null) {
ls = getStraightLineForStops(trip_id);
}
return ls;
}
use of org.locationtech.jts.geom.LineString in project graphhopper by graphhopper.
the class GTFSFeed method getStraightLineForStops.
public LineString getStraightLineForStops(String trip_id) {
CoordinateList coordinates = new CoordinateList();
LineString ls = null;
Trip trip = trips.get(trip_id);
Iterable<StopTime> stopTimes;
stopTimes = getOrderedStopTimesForTrip(trip.trip_id);
if (Iterables.size(stopTimes) > 1) {
for (StopTime stopTime : stopTimes) {
Stop stop = stops.get(stopTime.stop_id);
Double lat = stop.stop_lat;
Double lon = stop.stop_lon;
coordinates.add(new Coordinate(lon, lat));
}
ls = gf.createLineString(coordinates.toCoordinateArray());
} else // set ls equal to null if there is only one stopTime to avoid an exception when creating linestring
{
ls = null;
}
return ls;
}
use of org.locationtech.jts.geom.LineString in project graphhopper by graphhopper.
the class AnotherAgencyIT method readWktLineString.
private LineString readWktLineString(String wkt) {
WKTReader wktReader = new WKTReader();
LineString expectedGeometry = null;
try {
expectedGeometry = (LineString) wktReader.read(wkt);
} catch (ParseException e) {
e.printStackTrace();
}
return expectedGeometry;
}
use of org.locationtech.jts.geom.LineString in project graphhopper by graphhopper.
the class FreeWalkIT method readWktLineString.
private LineString readWktLineString(String wkt) {
WKTReader wktReader = new WKTReader();
LineString expectedGeometry = null;
try {
expectedGeometry = (LineString) wktReader.read(wkt);
} catch (ParseException e) {
e.printStackTrace();
}
return expectedGeometry;
}
Aggregations