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;
}
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"));
}
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);
}