Refine search
@Override public boolean filter(Individual individual) { Coordinate coord = new Coordinate(individual.lon, individual.lat); Point pt = gf.createPoint(coord); boolean accept = hull.contains(pt); //LOG.debug("label {} accept {}", individual.label, accept); return accept; }
points.add(new Coordinate(-10, -10)); points.add(new Coordinate(-10, 10)); points.add(new Coordinate(10, 10)); points.add(new Coordinate(10, -10)); points.add(new Coordinate(-10, -10)); final Coordinate coord = new Coordinate(0, 0); final Point point = gf.createPoint(coord);
/** * Compute an (approximated) distance between a point and a linestring expressed in standard geographical * coordinates (lon, lat in degrees). * @param point The coordinates of the point (longitude, latitude degrees). * @param lineString The set of points representing the polyline, in the same coordinate system. * @return The (approximated) distance, in meters, between the point and the linestring. */ public static final double fastDistance(Coordinate point, LineString lineString) { // Transform in equirectangular projection on sphere of radius 1, // centered at point double lat = Math.toRadians(point.y); double cosLat = FastMath.cos(lat); double lon = Math.toRadians(point.x) * cosLat; Point point2 = GeometryUtils.getGeometryFactory().createPoint(new Coordinate(lon, lat)); LineString lineString2 = equirectangularProject(lineString, cosLat); return lineString2.distance(point2) * RADIUS_OF_EARTH_IN_M; }
/** projected distance from stop to edge, in latitude degrees */ private static double distance (Vertex tstop, StreetEdge edge, double xscale) { // Despite the fact that we want to use a fast somewhat inaccurate projection, still use JTS library tools // for the actual distance calculations. LineString transformed = equirectangularProject(edge.getGeometry(), xscale); return transformed.distance(geometryFactory.createPoint(new Coordinate(tstop.getLon() * xscale, tstop.getLat()))); }
@Override public String resolve(double x, double y) { System.out.println("x="+x+", y="+y); FeatureIterator<Feature> iterator = collection.features(); while( iterator.hasNext() ){ SimpleFeature feature = (SimpleFeature) iterator.next(); Geometry geom = (Geometry) feature.getDefaultGeometry(); GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(); Coordinate coord = new Coordinate(x, y); Point point = geometryFactory.createPoint(coord); //System.out.println("checking "+point.toString()); if(geom.contains(point)) { return feature.getAttribute(this.nameField).toString(); } } return null; }
vvAttrs.color = null; vvAttrs.label = null; Point point = geomFactory.createPoint(new Coordinate(vertex.getLon(), vertex.getLat())); boolean render = evRenderer.renderVertex(vertex, vvAttrs); if (!render)
Coordinate dropPoint = new Coordinate(lon, lat); geomsArray = new Geometry[coords.length]; for (int j = 0; j < geomsArray.length; j++) { geomsArray[j] = gf.createPoint(coords[j]);
private final void generateDebugGeometry(TZ z0) { debug = false; for (DelaunayEdge<TZ> e : triangulation.edges()) { Coordinate cA = e.getA().getCoordinates(); Coordinate cB = e.getB().getCoordinates(); debugGeom.add(geometryFactory.createLineString(new Coordinate[] { cA, cB })); if (zMetric.cut(e.getA().getZ(), e.getB().getZ(), z0) != 0) { double k = zMetric.interpolate(e.getA().getZ(), e.getB().getZ(), z0); Coordinate cC = new Coordinate(cA.x * (1.0 - k) + cB.x * k, cA.y * (1.0 - k) + cB.y * k); debugGeom.add(geometryFactory.createPoint(cC)); } } }
if (geoJsonGeom instanceof org.geojson.Point) { org.geojson.Point geoJsonPoint = (org.geojson.Point) geoJsonGeom; return gf.createPoint(new Coordinate(geoJsonPoint.getCoordinates().getLongitude(), geoJsonPoint .getCoordinates().getLatitude()));
static Point createRandomPoint() { return geomFact.createPoint(new Coordinate(Math.random(), Math.random())); } }
static Point createRandomPoint() { return geomFact.createPoint(new Coordinate(Math.random(), Math.random())); }
public static void main(String[] args) throws Exception { // create a factory using default values (e.g. floating precision) GeometryFactory fact = new GeometryFactory(); Point p1 = fact.createPoint(new Coordinate(0,0)); System.out.println(p1); Point p2 = fact.createPoint(new Coordinate(1,1)); System.out.println(p2); MultiPoint mpt = fact.createMultiPoint(new Coordinate[] { new Coordinate(0,0), new Coordinate(1,1) } ); System.out.println(mpt); } }
static Geometry createCircle() { Geometry centrePt = geomFact.createPoint(new Coordinate(0.5, 0.5)); return centrePt.buffer(0.5, 20); }
@Override public Point apply(Request webRequest) throws BadRequestException { Point location; String lonParam = webRequest.queryParams("lon"); String latParam = webRequest.queryParams("lat"); if (!mandatory && lonParam == null && latParam == null) { return null; } try { Double lon = Double.valueOf(lonParam); if (lon > 180.0 || lon < -180.00) { throw new BadRequestException(400, "invalid search term 'lon', expected number >= -180.0 and <= 180.0"); } Double lat = Double.valueOf(latParam); if (lat > 90.0 || lat < -90.00) { throw new BadRequestException(400, "invalid search term 'lat', expected number >= -90.0 and <= 90.0"); } location = geometryFactory.createPoint(new Coordinate(lon, lat)); } catch (NullPointerException | NumberFormatException e) { throw new BadRequestException(400, "invalid search term 'lat' and/or 'lon', try instead lat=51.5&lon=8.0"); } return location; } }
File f = new File ( "world.shp" ); ShapefileDataStore dataStore = new ShapefileDataStore ( f.toURI ().toURL () ); FeatureSource<SimpleFeatureType, SimpleFeature> featureSource = dataStore.getFeatureSource (); String geomAttrName = featureSource.getSchema () .getGeometryDescriptor ().getLocalName (); ResourceInfo resourceInfo = featureSource.getInfo (); CoordinateReferenceSystem crs = resourceInfo.getCRS (); Hints hints = GeoTools.getDefaultHints (); hints.put ( Hints.JTS_SRID, 4326 ); hints.put ( Hints.CRS, crs ); FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2 ( hints ); GeometryFactory gf = JTSFactoryFinder.getGeometryFactory ( hints ); Coordinate land = new Coordinate ( -122.0087, 47.54650 ); Point pointLand = gf.createPoint ( land ); Coordinate water = new Coordinate ( 0, 0 ); Point pointWater = gf.createPoint ( water ); Intersects filter = ff.intersects ( ff.property ( geomAttrName ), ff.literal ( pointLand ) ); FeatureCollection<SimpleFeatureType, SimpleFeature> features = featureSource .getFeatures ( filter ); filter = ff.intersects ( ff.property ( geomAttrName ), ff.literal ( pointWater ) ); features = featureSource.getFeatures ( filter );
public Geometry toGeometry(GeometryFactory geomFactory) return geomFactory.createPoint((CoordinateSequence)null); Coordinate px00 = new Coordinate(minX, minA - minX); Coordinate px01 = new Coordinate(minX, minX - minB); Coordinate px10 = new Coordinate(maxX, maxX - maxB); Coordinate px11 = new Coordinate(maxX, maxA - maxX); return geomFactory.createPoint(px00);
return createPoint((CoordinateSequence)null); return createPoint(new Coordinate(envelope.getMinX(), envelope.getMinY())); || envelope.getMinY() == envelope.getMaxY()) { return createLineString(new Coordinate[]{ new Coordinate(envelope.getMinX(), envelope.getMinY()), new Coordinate(envelope.getMaxX(), envelope.getMaxY()) });
/** * Compute the point of the cell * * @return Center point of the cell */ private Point getCellPoint() { double x1 = (minX + cellI * deltaX) + (deltaX / 2d); double y1 = (minY + cellJ * deltaY) + (deltaY / 2d); cellI++; return GF.createPoint(new Coordinate(x1, y1)); }
/** * Generate Point from two dimensional ordinates * * @param x * @param y * @return Point */ public Point point( int x, int y ){ return gf.createPoint( new Coordinate( x, y ) ); } /**
@Override protected Geometry newGeometry(final double[][][] coords, final GeometryFactory geometryFactory) throws DataSourceException { final double x = coords[0][0][0]; final double y = coords[0][0][1]; return geometryFactory.createPoint(new Coordinate(x, y)); } }