private Coordinate moveEpsilonTowards(Coordinate coordinate, Coordinate distantFrameCoordinate) { return new Coordinate(coordinate.x + EPSILON * (distantFrameCoordinate.x - coordinate.x), coordinate.y + EPSILON * (distantFrameCoordinate.y - coordinate.y)); }
private static Coordinate readCoordinate(SliceInput input) { requireNonNull(input, "input is null"); return new Coordinate(input.readDouble(), input.readDouble()); }
void finish() { Stop stop = gtfsFeed.stops.get(stopTime.stop_id); stops.add(new Trip.Stop(stop.stop_id, stop.stop_name, geometryFactory.createPoint(new Coordinate(stop.stop_lon, stop.stop_lat)), updatedArrival.map(Date::from).orElse(Date.from(arrivalTimeFromHopEdge)), Date.from(arrivalTimeFromHopEdge), updatedArrival.map(Date::from).orElse(null), isArrivalCancelled(stopSequence), null, null, null, isDepartureCancelled(stopSequence))); for (Trip.Stop tripStop : stops) { logger.trace("{}", tripStop); } }
private static Geometry readEnvelope(SliceInput input) { verify(input.available() > 0); double xMin = input.readDouble(); double yMin = input.readDouble(); double xMax = input.readDouble(); double yMax = input.readDouble(); Coordinate[] coordinates = new Coordinate[5]; coordinates[0] = new Coordinate(xMin, yMin); coordinates[1] = new Coordinate(xMin, yMax); coordinates[2] = new Coordinate(xMax, yMax); coordinates[3] = new Coordinate(xMax, yMin); coordinates[4] = coordinates[0]; return GEOMETRY_FACTORY.createPolygon(coordinates); }
public Shape (GTFSFeed feed, String shape_id) { Map<Fun.Tuple2<String, Integer>, ShapePoint> points = feed.shape_points.subMap(new Fun.Tuple2(shape_id, null), new Fun.Tuple2(shape_id, Fun.HI)); Coordinate[] coords = points.values().stream() .map(point -> new Coordinate(point.shape_pt_lon, point.shape_pt_lat)) .toArray(i -> new Coordinate[i]); geometry = geometryFactory.createLineString(coords); shape_dist_traveled = points.values().stream().mapToDouble(point -> point.shape_dist_traveled).toArray(); } }
@Override public void apply(int nodeId, IsoLabel label) { int bucketIndex = (int) (getExploreValue(label) / bucketSize); if (bucketIndex < 0) { throw new IllegalArgumentException("edge cannot have negative explore value " + nodeId + ", " + label); } else if (bucketIndex > bucketCount) { return; } double lat = na.getLatitude(nodeId); double lon = na.getLongitude(nodeId); buckets.get(bucketIndex).add(new Coordinate(lon, lat)); // guess center of road to increase precision a bit for longer roads if (label.parent != null) { nodeId = label.parent.adjNode; double lat2 = na.getLatitude(nodeId); double lon2 = na.getLongitude(nodeId); buckets.get(bucketIndex).add(new Coordinate((lon + lon2) / 2, (lat + lat2) / 2)); } } });
private static List<Coordinate> toCoordinateArray(PointList pointList) { List<Coordinate> coordinates = new ArrayList<>(pointList.size()); for (int i = 0; i < pointList.size(); i++) { coordinates.add(pointList.getDimension() == 3 ? new Coordinate(pointList.getLon(i), pointList.getLat(i)) : new Coordinate(pointList.getLon(i), pointList.getLat(i), pointList.getEle(i))); } return coordinates; }
/** * Converts the specified {@code Envelope} to a {@code Polygon} having the specified srid. * * @param env The envelope to convert * @param srid The srid for the polygon * * @return The Polygon */ public static Polygon toPolygon(Envelope env, int srid) { final Coordinate[] coords = new Coordinate[5]; coords[0] = new Coordinate( env.getMinX(), env.getMinY() ); coords[1] = new Coordinate( env.getMinX(), env.getMaxY() ); coords[2] = new Coordinate( env.getMaxX(), env.getMaxY() ); coords[3] = new Coordinate( env.getMaxX(), env.getMinY() ); coords[4] = new Coordinate( env.getMinX(), env.getMinY() ); final LinearRing shell = geomFactory.createLinearRing( coords ); final Polygon pg = geomFactory.createPolygon( shell, null ); pg.setSRID( srid ); return pg; }
Optional<Instant> updatedDeparture = getDepartureDelay(stopSequence).map(delay -> plannedDeparture.plus(delay, SECONDS)); Stop stop = gtfsFeed.stops.get(stopTime.stop_id); stops.add(new Trip.Stop(stop.stop_id, stop.stop_name, geometryFactory.createPoint(new Coordinate(stop.stop_lon, stop.stop_lat)), null, null, null, isArrivalCancelled(stopSequence), updatedDeparture.map(Date::from).orElse(Date.from(plannedDeparture)), Date.from(plannedDeparture), Optional<Instant> updatedDeparture = getDepartureDelay(stopTime.stop_sequence).map(delay -> plannedDeparture.plus(delay, SECONDS)); Stop stop = gtfsFeed.stops.get(stopTime.stop_id); stops.add(new Trip.Stop(stop.stop_id, stop.stop_name, geometryFactory.createPoint(new Coordinate(stop.stop_lon, stop.stop_lat)), updatedArrival.map(Date::from).orElse(Date.from(arrivalTimeFromHopEdge)), Date.from(arrivalTimeFromHopEdge), updatedArrival.map(Date::from).orElse(null), isArrivalCancelled(stopSequence),
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()); } // set ls equal to null if there is only one stopTime to avoid an exception when creating linestring else{ ls = null; } return ls; }
Coordinate nodeCoordinate = new Coordinate(nodeAccess.getLongitude(nodeLabel.adjNode), nodeAccess.getLatitude(nodeLabel.adjNode)); z1.merge(nodeCoordinate, this.z.apply(nodeLabel), Math::min); };
public LineString toLineString(boolean includeElevation) { GeometryFactory gf = new GeometryFactory(); Coordinate[] coordinates = new Coordinate[getSize() == 1 ? 2 : getSize()]; for (int i = 0; i < getSize(); i++) { coordinates[i] = includeElevation ? new Coordinate( round6(getLongitude(i)), round6(getLatitude(i)), round2(getElevation(i))) : new Coordinate( round6(getLongitude(i)), round6(getLatitude(i))); } // special case as just 1 point is not supported in the specification #1412 if (getSize() == 1) coordinates[1] = coordinates[0]; return gf.createLineString(coordinates); }
/** * This method creates a new Coordinate object upon each call. * * @see XYNode#getCoordinate() */ public Coordinate getCoordinate() { return (new Coordinate(m_x, m_y)); }
event.setId( 1L); event.setName( "Hibernate ORM presentation"); Point point = geometryFactory.createPoint( new Coordinate( 10, 5 ) ); event.setLocation( point ); new Coordinate(1,1), new Coordinate(20,1), new Coordinate(20,20), new Coordinate(1,20), new Coordinate(1,1) };
Integer.valueOf(1), new Double(1.1), gf.createPoint(new Coordinate(1, 1)) }, "fid.1")); Integer.valueOf(2), new Double(2.2), gf.createPoint(new Coordinate(2, 2)) }, "fid.2")); Integer.valueOf(3), new Double(3.3), gf.createPoint(new Coordinate(3, 3)) }, "fid.3"));
/** * Creates JTS envelope from the current region. * * @return the JTS envelope wrapping the current region. */ public Envelope getEnvelope() { return new Envelope(new Coordinate(west, north), new Coordinate(east, south)); }
/** * set the center of the circle * @param lon longitude of the center * @param lat latitude of the center * @return this */ public CircleBuilder center(double lon, double lat) { return center(new Coordinate(lon, lat)); }
@Test public void testModify() throws Exception { final Query queryAll = new Query(RENAMED); SimpleFeatureStore store; store = (SimpleFeatureStore) rts.getFeatureSource(RENAMED); SimpleFeature original = store.getFeatures(fidFilter).features().next(); // test a non mapped attribute String newDescription = ((String) original.getAttribute("description")) + " xxx"; store.modifyFeatures( original.getFeatureType().getDescriptor("description"), newDescription, fidFilter); SimpleFeature modified = store.getFeatures(fidFilter).features().next(); assertEquals(newDescription, modified.getAttribute("description")); // test a mapped attribute MultiPoint mpo = (MultiPoint) original.getAttribute("pointProperty"); MultiPoint mpm = mpo.getFactory().createMultiPoint(new Coordinate[] {new Coordinate(10, 12)}); store.modifyFeatures( original.getFeatureType().getDescriptor("pointProperty"), mpm, fidFilter); modified = store.getFeatures(fidFilter).features().next(); assertTrue(mpm.equalsExact((Geometry) modified.getAttribute("pointProperty"))); }
public void testPos() throws Exception { document.appendChild(GML3MockData.linearRingWithPos(document, null)); LinearRing line = (LinearRing) parse(); assertNotNull(line); assertEquals(new Coordinate(1d, 2d), line.getPointN(0).getCoordinate()); assertEquals(new Coordinate(3d, 4d), line.getPointN(1).getCoordinate()); assertEquals(new Coordinate(5d, 6d), line.getPointN(2).getCoordinate()); assertEquals(new Coordinate(1d, 2d), line.getPointN(3).getCoordinate()); }
public void testPos3D() throws Exception { GML3MockData.point3D(document, document); Point p = (Point) parse(); assertNotNull(p); assertTrue(new Coordinate(1d, 2d, 10d).equals3D(p.getCoordinate())); assertTrue(p.getUserData() instanceof CoordinateReferenceSystem); }