Refine search
final GeometryFactory gf = new GeometryFactory(); 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));
public Geometry computeIsoline(long z0) { fzInterpolateCount = 0; GeometryFactory geomFactory = new GeometryFactory(); Coordinate B = getCoordinate(e.B.index); Coordinate C = interpolate(A, B, e.A.z, e.B.z, z0); Coordinate C1 = new Coordinate(C.x + (B.y - A.y) * 0.1, C.y + (B.x - A.x) * 0.1); Coordinate C2 = new Coordinate(C.x - (B.y - A.y) * 0.1, C.y - (B.x - A.x) * 0.1); debugGeom .add(geomFactory.createLineString(new Coordinate[] { A, C, C1, C2, C, B }));
GeometryFactory gf = new GeometryFactory(); Coordinate dropPoint = new Coordinate(lon, lat);
GeometryFactory geomFactory = new GeometryFactory(); vvAttrs.color = null; vvAttrs.label = null; Point point = geomFactory.createPoint(new Coordinate(vertex.getLon(), vertex.getLat())); boolean render = evRenderer.renderVertex(vertex, vvAttrs); if (!render)
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); } }
public static void main(String[] args) throws Exception { // read a geometry from a WKT string (using the default geometry factory) Geometry g1 = new WKTReader().read("LINESTRING (0 0, 10 10, 20 20)"); System.out.println("Geometry 1: " + g1); // create a geometry by specifying the coordinates directly Coordinate[] coordinates = new Coordinate[]{new Coordinate(0, 0), new Coordinate(10, 10), new Coordinate(20, 20)}; // use the default factory, which gives full double-precision Geometry g2 = new GeometryFactory().createLineString(coordinates); System.out.println("Geometry 2: " + g2); // compute the intersection of the two geometries Geometry g3 = g1.intersection(g2); System.out.println("G1 intersection G2: " + g3); } }
import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.GeometryFactory; import com.vividsolutions.jts.geom.Point; import javax.persistence.Query; Coordinate coord = new Coordinate(52.5, 13.3); Point point = new GeometryFactory().createPoint(coord); Query query = em.createQuery("FROM Cities WHERE WITHIN(:location, polygon) = true", Cities.class); query.setParameter("location", point);
public static Geometry makePoint(double x1, double y1) { GeometryFactory gFactory = new GeometryFactory(); Coordinate coordinate = new Coordinate(x1, y1); return gFactory.createPoint(coordinate); }
public static Geometry makePoint(double x1, double y1) { /** * FIXME * We should probably have a static one (checking thread safety) or store it somewhere; see how it works * for now. */ GeometryFactory gFactory = new GeometryFactory(); Coordinate coordinate = new Coordinate(x1, y1); return gFactory.createPoint(coordinate); }
import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.GeometryFactory; import com.vividsolutions.jts.geom.Point; Coordinate coord = new Coordinate(52.5, 13.3); Point point = new GeometryFactory().createPoint(coord); Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); Query query = session.createQuery("FROM datos WHERE WITHIN(:location, polygon) = true", Datos.class); query.setParameter("location", point); session.getTransaction().commit();
public Point getPoint() { GeometryFactory gf = new GeometryFactory(); return gf.createPoint(new Coordinate(lon, lat)); }
// create polygons Polygon p1 = new GeometryFactory().createPolygon(new Coordinate[]{new Coordinate(0, 0), new Coordinate(0,10), new Coordinate(10,10), new Coordinate(10,0), new Coordinate(0,0)}); Polygon p2 = new GeometryFactory().createPolygon(new Coordinate[]{new Coordinate(5,5), new Coordinate(15,5), new Coordinate(15,15), new Coordinate(5,15), new Coordinate(5,5)}); // calculate union Geometry union = p1.union(p2); // print as WKT System.out.println(union.toText());
// build polygon p1 Polygon p1 = new GeometryFactory().createPolygon(new Coordinate[]{new Coordinate(0,0), new Coordinate(0,10), new Coordinate(10,10), new Coordinate(10,0), new Coordinate(0,0)}); // build polygon p2 Polygon p2 = new GeometryFactory().createPolygon(new Coordinate[]{new Coordinate(0,0), new Coordinate(0,30), new Coordinate(5,30), new Coordinate(5,0), new Coordinate(0,0)}); // calculate polygon3 as the union of p1 and p2 Polygon p3 = (Polygon) p1.union(p2); // print simple WKT System.out.println(p3.toText());
public GPSSegment(GPSPoint p0, GPSPoint p1) { Coordinate[] coords = new Coordinate[2]; coords[0] = new Coordinate(p0.lon, p0.lat); coords[1] = new Coordinate(p1.lon, p1.lat); this.geom = new GeometryFactory().createLineString(coords); if (p0.vehicleId != p1.vehicleId) { throw new IllegalArgumentException("vehicle ids don't match"); } this.p0 = p0; this.p1 = p1; this.vehicleId = p0.vehicleId; }
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); } }
// build polygon p1 LinearRing p1 = new GeometryFactory().createLinearRing(new Coordinate[]{new Coordinate(0,0), new Coordinate(0,10), new Coordinate(10,10), new Coordinate(10,0), new Coordinate(0,0)}); // build polygon p2 LinearRing p2 = new GeometryFactory().createLinearRing(new Coordinate[]{new Coordinate(5,5), new Coordinate(15,5), new Coordinate(15,15), new Coordinate(5,15), new Coordinate(5,5)}); // calculate intersecting points Geometry intersectingPoints = p1.intersection(p2); // print result for(Coordinate c : intersectingPoints.getCoordinates()){ System.out.println(c.toString()); }
// create ring: P1(0,0) - P2(0,10) - P3(10,10) - P4(0,10) LinearRing lr = new GeometryFactory().createLinearRing(new Coordinate[]{new Coordinate(0,0), new Coordinate(0,10), new Coordinate(10,10), new Coordinate(10,0), new Coordinate(0,0)}); // create line: P5(5, -1) - P6(5, 11) -> crossing the ring vertically in the middle LineString ls = new GeometryFactory().createLineString(new Coordinate[]{new Coordinate(5,-1), new Coordinate(5,11)}); // calculate intersection points Geometry intersectionPoints = lr.intersection(ls); // simple output of points for(Coordinate c : intersectionPoints.getCoordinates()){ System.out.println(c.toString()); }
private Geometry shape(String latitude, String longitude) { GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel(), Subject.SRID); return geometryFactory .createPoint(new Coordinate(Double.parseDouble(longitude), Double.parseDouble(latitude))); }
@Override public void setPosition(double longitude, double latitude) { Coordinate[] coordinates = new Coordinate[]{new Coordinate(longitude, latitude)}; CoordinateSequence coordSequence = new CoordinateArraySequence(coordinates); Point point = new Point(coordSequence, new GeometryFactory()); setGeometry(point); }
/** * Creates a JTS point from a device location. * * @param location * @return */ public static Point createPointForLocation(IDeviceLocation location) { GeometryFactory fact = new GeometryFactory(); return fact.createPoint(new Coordinate(location.getLongitude(), location.getLatitude())); }