org.postgis.LinearRing Java Examples

The following examples show how to use org.postgis.LinearRing. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestGisBulkWithin.java    From sqlg with MIT License 6 votes vote down vote up
@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));
}
 
Example #2
Source File: TestGisBulkWithin.java    From sqlg with MIT License 6 votes vote down vote up
@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));
}
 
Example #3
Source File: PolygonTypeHandlerTest.java    From mybatis-typehandlers-postgis with Do What The F*ck You Want To Public License 5 votes vote down vote up
@Before
public void before() {
    table = "test_polygon";

    Point[] points = new Point[5];
    points[0] = new Point(123.45d, 23.45d);
    points[1] = new Point(124.45d, 23.45d);
    points[2] = new Point(124.45d, 24.45d);
    points[3] = new Point(123.45d, 24.45d);
    points[4] = new Point(123.45d, 23.45d);
    LinearRing linearRing = new LinearRing(points);
    t = new Polygon(new LinearRing[]{linearRing});
    t.setSrid(SRID);
}
 
Example #4
Source File: GeographyPolygon.java    From sqlg with MIT License 4 votes vote down vote up
public GeographyPolygon(LinearRing[] rings) {
    super(rings);
    this.srid = Gis.SRID;
}