Search in sources :

Example 16 with Point

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));
}
Also used : 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 17 with Point

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();
}
Also used : Point(org.postgis.Point) PGgeometry(org.postgis.PGgeometry)

Example 18 with Point

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);
    }
}
Also used : Point(org.postgis.Point) Point(org.postgis.Point)

Example 19 with Point

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]));
}
Also used : WayNode(org.openstreetmap.osmosis.core.domain.v0_6.WayNode) NodeLocation(org.openstreetmap.osmosis.pgsimple.common.NodeLocation) ArrayList(java.util.ArrayList) Point(org.postgis.Point) LinearRing(org.postgis.LinearRing)

Example 20 with Point

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++;
    }
}
Also used : LineString(org.postgis.LineString) Point(org.postgis.Point) Point(org.postgis.Point) PGgeometry(org.postgis.PGgeometry)

Aggregations

Point (org.postgis.Point)33 PersistenceManager (javax.jdo.PersistenceManager)22 Transaction (javax.jdo.Transaction)22 SamplePoint (org.datanucleus.samples.pggeometry.SamplePoint)21 List (java.util.List)18 Query (javax.jdo.Query)18 MultiPoint (org.postgis.MultiPoint)18 Datastore (org.datanucleus.tests.annotations.Datastore)7 Geometry (org.postgis.Geometry)7 LineString (org.postgis.LineString)6 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)5 SamplePolygon (org.datanucleus.samples.pggeometry.SamplePolygon)5 Test (org.junit.Test)5 GeographyPoint (org.umlg.sqlg.gis.GeographyPoint)5 BaseTest (org.umlg.sqlg.test.BaseTest)5 SampleLineString (org.datanucleus.samples.pggeometry.SampleLineString)4 SampleMultiPoint (org.datanucleus.samples.pggeometry.SampleMultiPoint)3 LinearRing (org.postgis.LinearRing)3 PGgeometry (org.postgis.PGgeometry)3 Connection (java.sql.Connection)1