Java Code Examples for org.postgis.LineString
The following examples show how to use
org.postgis.LineString. These examples are extracted from open source projects.
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 Project: sqlg Source File: TestGisBulkWithin.java License: MIT License | 6 votes |
@Test public void testBulkWithinLineString() { Point point1 = new Point(26.2044, 28.0456); Point point2 = new Point(26.2045, 28.0457); LineString lineString1 = new LineString(new Point[] {point1, point2}); Point point3 = new Point(26.2046, 28.0458); LineString lineString2 = new LineString(new Point[] {point1, point3}); LineString lineString3 = new LineString(new Point[] {point2, point3}); Point point4 = new Point(26.2047, 28.0459); LineString lineString4 = new LineString(new Point[] {point1, point4}); Vertex v1 = this.sqlgGraph.addVertex(T.label, "Gis", "line", lineString1); Vertex v2 = this.sqlgGraph.addVertex(T.label, "Gis", "line", lineString2); Vertex v3 = this.sqlgGraph.addVertex(T.label, "Gis", "line", lineString3); Vertex v4 = this.sqlgGraph.addVertex(T.label, "Gis", "line", lineString4); this.sqlgGraph.tx().commit(); List<Vertex> vertices = this.sqlgGraph.traversal().V().hasLabel("Gis").has("line", P.within(lineString1, lineString3, lineString4)).toList(); Assert.assertEquals(3, vertices.size()); Assert.assertTrue(Arrays.asList(v1, v3, v4).containsAll(vertices)); }
Example 2
Source Project: importer-exporter Source File: GeometryConverterAdapter.java License: Apache License 2.0 | 6 votes |
@Override public GeometryObject getMultiCurve(Object geomObj) throws SQLException { GeometryObject multiCurve = null; if (geomObj instanceof PGgeometry) { Geometry geometry = ((PGgeometry)geomObj).getGeometry(); if (geometry.getType() == Geometry.MULTILINESTRING) { multiCurve = getMultiCurve((MultiLineString)geometry); } else if (geometry.getType() == Geometry.LINESTRING) { LineString lineStringObj = (LineString)geometry; double[][] coordiantes = new double[1][]; coordiantes[0] = getCurveCoordinates(lineStringObj); multiCurve = GeometryObject.createMultiPoint(coordiantes, lineStringObj.getDimension(), lineStringObj.getSrid()); } } return multiCurve; }
Example 3
Source Project: importer-exporter Source File: GeometryConverterAdapter.java License: Apache License 2.0 | 6 votes |
@Override public GeometryObject getGeometry(Object geomObj) throws SQLException { if (geomObj instanceof PGgeometry) { Geometry geometry = ((PGgeometry)geomObj).getGeometry(); switch (geometry.getType()) { case Geometry.POINT: return getPoint((Point)geometry); case Geometry.MULTIPOINT: return getMultiPoint((MultiPoint)geometry); case Geometry.LINESTRING: return getCurve((LineString)geometry); case Geometry.MULTILINESTRING: return getMultiCurve((MultiLineString)geometry); case Geometry.POLYGON: return getPolygon((Polygon)geometry); case Geometry.MULTIPOLYGON: return getMultiPolygon((MultiPolygon)geometry); default: throw new SQLException("Cannot convert PostGIS geometry type '" + geometry.getType() + "' to internal representation: Unsupported type."); } } return null; }
Example 4
Source Project: mybatis-typehandlers-postgis Source File: LineStringTypeHandlerTest.java License: Do What The F*ck You Want To Public License | 5 votes |
@Before public void before() { table = "test_linestring"; Point[] points = new Point[4]; 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); t = new LineString(points); t.setSrid(SRID); }
Example 5
Source Project: importer-exporter Source File: GeometryConverterAdapter.java License: Apache License 2.0 | 5 votes |
@Override public GeometryObject getCurve(Object geomObj) throws SQLException { GeometryObject curve = null; if (geomObj instanceof PGgeometry) { Geometry geometry = ((PGgeometry)geomObj).getGeometry(); if (geometry.getType() != Geometry.LINESTRING) return null; curve = getCurve((LineString)geometry); } return curve; }
Example 6
Source Project: mybatis-typehandlers-postgis Source File: LineStringTypeHandlerTest.java License: Do What The F*ck You Want To Public License | 4 votes |
@Override protected TypeHandler<LineString> getTypeHandler() { return TYPE_HANDLER; }
Example 7
Source Project: importer-exporter Source File: GeometryConverterAdapter.java License: Apache License 2.0 | 4 votes |
private GeometryObject getCurve(LineString lineString) { return GeometryObject.createCurve(getCurveCoordinates(lineString), lineString.getDimension(), lineString.getSrid()); }