use of org.postgis.LinearRing in project sqlg by pietermartin.
the class TestGis method testGeographyPolygon.
@Test
public void testGeographyPolygon() throws SQLException {
LinearRing linearRing = new LinearRing("0 0, 1 1, 1 2, 1 1, 0 0");
GeographyPolygon polygon1 = new GeographyPolygon(new LinearRing[] { linearRing });
Vertex johannesburg = this.sqlgGraph.addVertex(T.label, "Gis", "polygon", polygon1);
this.sqlgGraph.tx().commit();
GeographyPolygon geographyPolygon = this.sqlgGraph.traversal().V(johannesburg.id()).next().value("polygon");
Assert.assertEquals(polygon1, geographyPolygon);
linearRing = new LinearRing("0 1, 2 3, 1 3, 1 3, 0 1");
polygon1 = new GeographyPolygon(new LinearRing[] { linearRing });
johannesburg.property("polygon", polygon1);
this.sqlgGraph.tx().commit();
geographyPolygon = this.sqlgGraph.traversal().V(johannesburg.id()).next().value("polygon");
Assert.assertEquals(polygon1, geographyPolygon);
}
use of org.postgis.LinearRing in project sqlg by pietermartin.
the class TestGisBulkWithin method testBulkWithinGeographyPolygon.
@Test
public void testBulkWithinGeographyPolygon() throws SQLException {
LinearRing linearRing1 = new LinearRing("0 0, 1 1, 1 2, 1 1, 0 0");
GeographyPolygon polygon1 = new GeographyPolygon(new LinearRing[] { linearRing1 });
LinearRing linearRing2 = new LinearRing("1 1, 1 1, 1 2, 1 1, 1 1");
GeographyPolygon polygon2 = new GeographyPolygon(new LinearRing[] { linearRing2 });
LinearRing linearRing3 = new LinearRing("2 2, 1 1, 1 2, 1 1, 2 2");
GeographyPolygon polygon3 = new GeographyPolygon(new LinearRing[] { linearRing3 });
LinearRing linearRing4 = new LinearRing("1 3, 1 2, 2 2, 1 1, 1 3");
GeographyPolygon polygon4 = new GeographyPolygon(new LinearRing[] { linearRing4 });
Vertex v1 = this.sqlgGraph.addVertex(T.label, "Gis", "polygon", polygon1);
Vertex v2 = this.sqlgGraph.addVertex(T.label, "Gis", "polygon", polygon2);
Vertex v3 = this.sqlgGraph.addVertex(T.label, "Gis", "polygon", polygon3);
Vertex v4 = this.sqlgGraph.addVertex(T.label, "Gis", "polygon", polygon4);
this.sqlgGraph.tx().commit();
List<Vertex> vertices = this.sqlgGraph.traversal().V().hasLabel("Gis").has("polygon", P.within(polygon1, polygon3, polygon4)).toList();
Assert.assertEquals(3, vertices.size());
Assert.assertTrue(Arrays.asList(v1, v3, v4).containsAll(vertices));
}
use of org.postgis.LinearRing in project sqlg by pietermartin.
the class TestGisBulkWithin method testBulkWithinPolygon.
@Test
public void testBulkWithinPolygon() throws SQLException {
LinearRing linearRing1 = new LinearRing("0 0, 1 1, 1 2, 1 1, 0 0");
Polygon polygon1 = new Polygon(new LinearRing[] { linearRing1 });
LinearRing linearRing2 = new LinearRing("1 1, 1 1, 1 2, 1 1, 1 1");
Polygon polygon2 = new Polygon(new LinearRing[] { linearRing2 });
LinearRing linearRing3 = new LinearRing("2 2, 1 1, 1 2, 1 1, 2 2");
Polygon polygon3 = new Polygon(new LinearRing[] { linearRing3 });
LinearRing linearRing4 = new LinearRing("1 3, 1 2, 2 2, 1 1, 1 3");
Polygon polygon4 = new Polygon(new LinearRing[] { linearRing4 });
Vertex v1 = this.sqlgGraph.addVertex(T.label, "Gis", "polygon", polygon1);
Vertex v2 = this.sqlgGraph.addVertex(T.label, "Gis", "polygon", polygon2);
Vertex v3 = this.sqlgGraph.addVertex(T.label, "Gis", "polygon", polygon3);
Vertex v4 = this.sqlgGraph.addVertex(T.label, "Gis", "polygon", polygon4);
this.sqlgGraph.tx().commit();
List<Vertex> vertices = this.sqlgGraph.traversal().V().hasLabel("Gis").has("polygon", P.within(polygon1, polygon3, polygon4)).toList();
Assert.assertEquals(3, vertices.size());
Assert.assertTrue(Arrays.asList(v1, v3, v4).containsAll(vertices));
}
use of org.postgis.LinearRing in project voltdb by VoltDB.
the class WayPolygonGeometryBuilder method createRing.
public LinearRing createRing(Way way) {
List<Point> points = new ArrayList<Point>();
for (WayNode wayNode : way.getWayNodes()) {
NodeLocation nodeLocation;
double longitude;
double latitude;
nodeLocation = locationStore.getNodeLocation(wayNode.getNodeId());
longitude = nodeLocation.getLongitude();
latitude = nodeLocation.getLatitude();
if (nodeLocation.isValid()) {
Point point = new Point(longitude, latitude);
points.add(point);
}
}
return new LinearRing(points.toArray(new Point[0]));
}
use of org.postgis.LinearRing in project voltdb by VoltDB.
the class WayPolygonGeometryBuilder method createPolygon.
/**
* OSM stores each ring of a polygon independently, the rings of a polygon
* need to be combined through relationships. This method only returns a
* single ring of a Polygon,
*
* @param way
* @return
*/
public Polygon createPolygon(Way way) {
LinearRing[] rings = new LinearRing[1];
rings[0] = createRing(way);
Polygon pg = new Polygon(rings);
return pg;
}
Aggregations