Search in sources :

Example 1 with Gis

use of org.umlg.sqlg.gis.Gis in project sqlg by pietermartin.

the class PostgresDialect method getGis.

@Override
public <T> T getGis(SqlgGraph sqlgGraph) {
    Gis gis = Gis.GIS;
    gis.setSqlgGraph(sqlgGraph);
    return (T) gis;
}
Also used : Gis(org.umlg.sqlg.gis.Gis) T(org.apache.tinkerpop.gremlin.structure.T)

Example 2 with Gis

use of org.umlg.sqlg.gis.Gis in project sqlg by pietermartin.

the class TestGis method testPoint.

@Test
public void testPoint() {
    Point johannesburgPoint = new Point(26.2044, 28.0456);
    Vertex johannesburg = this.sqlgGraph.addVertex(T.label, "Gis", "point", johannesburgPoint);
    Point pretoriaPoint = new Point(25.7461, 28.1881);
    Vertex pretoria = this.sqlgGraph.addVertex(T.label, "Gis", "point", pretoriaPoint);
    this.sqlgGraph.tx().commit();
    Assert.assertEquals(johannesburgPoint, this.sqlgGraph.traversal().V(johannesburg.id()).next().value("point"));
    Assert.assertEquals(pretoriaPoint, this.sqlgGraph.traversal().V(pretoria.id()).next().value("point"));
    Gis gis = this.sqlgGraph.gis();
    System.out.println(gis.distanceBetween(johannesburgPoint, pretoriaPoint));
    johannesburgPoint = new Point(26.2055, 28.0477);
    johannesburg.property("point", johannesburgPoint);
    this.sqlgGraph.tx().commit();
    Assert.assertEquals(johannesburgPoint, this.sqlgGraph.traversal().V(johannesburg.id()).next().value("point"));
}
Also used : Gis(org.umlg.sqlg.gis.Gis) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) Point(org.postgis.Point) GeographyPoint(org.umlg.sqlg.gis.GeographyPoint) BaseTest(org.umlg.sqlg.test.BaseTest) Test(org.junit.Test)

Example 3 with Gis

use of org.umlg.sqlg.gis.Gis in project sqlg by pietermartin.

the class TestGis method testGeographyPoint.

@Test
public void testGeographyPoint() {
    GeographyPoint geographyPointJohannesburg = new GeographyPoint(26.2044, 28.0456);
    Vertex johannesburg = this.sqlgGraph.addVertex(T.label, "Gis", "geographyPoint", geographyPointJohannesburg);
    GeographyPoint geographyPointPretoria = new GeographyPoint(25.7461, 28.1881);
    Vertex pretoria = this.sqlgGraph.addVertex(T.label, "Gis", "geographyPoint", geographyPointPretoria);
    this.sqlgGraph.tx().commit();
    Object geographyPoint = this.sqlgGraph.traversal().V(johannesburg.id()).next().value("geographyPoint");
    Assert.assertEquals(geographyPointJohannesburg, geographyPoint);
    geographyPoint = this.sqlgGraph.traversal().V(pretoria.id()).next().value("geographyPoint");
    Assert.assertEquals(geographyPointPretoria, geographyPoint);
    Gis gis = this.sqlgGraph.gis();
    System.out.println(gis.distanceBetween(geographyPointJohannesburg, geographyPointPretoria));
    geographyPointPretoria = new GeographyPoint(25.7461, 28.1881);
    pretoria.property("geographyPoint", geographyPointPretoria);
    this.sqlgGraph.tx().commit();
    geographyPoint = this.sqlgGraph.traversal().V(pretoria.id()).next().value("geographyPoint");
    Assert.assertEquals(geographyPointPretoria, geographyPoint);
}
Also used : Gis(org.umlg.sqlg.gis.Gis) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) GeographyPoint(org.umlg.sqlg.gis.GeographyPoint) BaseTest(org.umlg.sqlg.test.BaseTest) Test(org.junit.Test)

Aggregations

Gis (org.umlg.sqlg.gis.Gis)3 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)2 Test (org.junit.Test)2 GeographyPoint (org.umlg.sqlg.gis.GeographyPoint)2 BaseTest (org.umlg.sqlg.test.BaseTest)2 T (org.apache.tinkerpop.gremlin.structure.T)1 Point (org.postgis.Point)1