use of org.postgis.Point in project sqlg by pietermartin.
the class TestGisBulkWithin method testBulkWithinPoint.
@Test
public void testBulkWithinPoint() {
Point point1 = new Point(26.2044, 28.0456);
Point point2 = new Point(26.2045, 28.0457);
Point point3 = new Point(26.2046, 28.0458);
Point point4 = new Point(26.2047, 28.0459);
Vertex v1 = this.sqlgGraph.addVertex(T.label, "Gis", "point", point1);
Vertex v2 = this.sqlgGraph.addVertex(T.label, "Gis", "point", point2);
Vertex v3 = this.sqlgGraph.addVertex(T.label, "Gis", "point", point3);
Vertex v4 = this.sqlgGraph.addVertex(T.label, "Gis", "point", point4);
this.sqlgGraph.tx().commit();
List<Vertex> vertices = this.sqlgGraph.traversal().V().hasLabel("Gis").has("point", P.within(point1, point3, point4)).toList();
Assert.assertEquals(3, vertices.size());
Assert.assertTrue(Arrays.asList(v1, v3, v4).containsAll(vertices));
}
use of org.postgis.Point in project chuidiang-ejemplos by chuidiang.
the class TrackDao method firstTrajectoryInsert.
public void firstTrajectoryInsert(Map<Long, Track> tracks) throws SQLException {
if (null == firstInsertPs) {
firstInsertPs = conn.prepareStatement("insert into geometry_tracks(fusion_id,start_timestamp,stop_timestamp,trajectory) values (?,?,?,?)");
}
tracks.values().forEach(track -> {
try {
if (null != track.getLastPoint()) {
return;
}
Point trackLocation = track.getActualPoint();
firstInsertPs.setLong(1, track.getId());
firstInsertPs.setTimestamp(2, new Timestamp(System.currentTimeMillis()));
firstInsertPs.setTimestamp(3, new Timestamp(System.currentTimeMillis()));
PGgeometry geometry = new PGgeometry(trackLocation);
firstInsertPs.setObject(4, geometry);
firstInsertPs.addBatch();
firstInserted.add(track.getId());
} catch (Exception e) {
e.printStackTrace();
}
});
firstInsertPs.executeLargeBatch();
}
use of org.postgis.Point in project chuidiang-ejemplos by chuidiang.
the class MainCommons method fillModel.
protected void fillModel() {
for (int i = 0; i < 10000; i++) {
Track track = new Track();
track.setId(i);
track.setCog(Math.random() * 360);
track.setActualPoint(new Point(Math.random() * 90 - 45, Math.random() * 90 - 45));
model.getTracks().put(Long.valueOf(i), track);
}
}
use of org.postgis.Point 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.Point in project chuidiang-ejemplos by chuidiang.
the class PostigsMain method insertStart.
private void insertStart() throws SQLException {
float longitude = 10;
float latitude = 20;
PreparedStatement ps = conn.prepareStatement("insert into geometry_tracks(id,timestamp,trajectory) values (?,?,?)");
for (int i = 1; i < 10000; i++) {
ps.setLong(1, i);
ps.setTimestamp(2, new Timestamp(System.currentTimeMillis()));
Point[] points = new Point[2];
points[0] = new Point(longitude, latitude);
points[1] = new Point(longitude, latitude);
PGgeometry geometry = new PGgeometry(new LineString(points));
ps.setObject(3, geometry);
ps.executeUpdate();
longitude++;
latitude++;
}
}
Aggregations