本文整理汇总了Java中org.postgis.LineString类的典型用法代码示例。如果您正苦于以下问题:Java LineString类的具体用法?Java LineString怎么用?Java LineString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LineString类属于org.postgis包,在下文中一共展示了LineString类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBulkWithinLineString
import org.postgis.LineString; //导入依赖的package包/类
@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));
}
示例2: getMultiCurve
import org.postgis.LineString; //导入依赖的package包/类
@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;
}
示例3: getGeometry
import org.postgis.LineString; //导入依赖的package包/类
@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;
}
示例4: before
import org.postgis.LineString; //导入依赖的package包/类
@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);
}
示例5: createLinestring
import org.postgis.LineString; //导入依赖的package包/类
public static LineString createLinestring(List<FCDEntry> fcdEntries) {
List<Point> points = new ArrayList<Point>();
for(FCDEntry fcdEntry : fcdEntries) {
Point point = new Point(fcdEntry.lon, fcdEntry.lat, (double) fcdEntry.getSpeed());
point.setM(fcdEntry.getTime()/1000); // we don't need milliseconds
point.setSrid(4326);
points.add(point);
}
LineString lineString = new LineString(points.toArray(new Point[]{}));
lineString.srid = 4326;
return lineString;
}
示例6: toLineString
import org.postgis.LineString; //导入依赖的package包/类
static LineString toLineString(List<LatLng> latLngs, int srid) {
List<Point> points = new ArrayList<>(latLngs.size() + 1);
for (int i = 0; i < latLngs.size(); i++) {
LatLng latLng = latLngs.get(i);
points.add(new Point(latLng.getLng(), latLng.getLat()));
}
//close the ring
if(latLngs.size() == 1) {
points.add(points.get(0));
}
LineString lineString = new LineString(points.toArray(new Point[points.size()]));
lineString.setSrid(srid);
return lineString;
}
示例7: mapRow
import org.postgis.LineString; //导入依赖的package包/类
@Override
public List<LatLng> mapRow(ResultSet rs, int rowNum) throws SQLException {
PGgeometry pggeom = (PGgeometry) rs.getObject(colName);
LineString line = (LineString) pggeom.getGeometry();
Point[] points = line.getPoints();
if(points.length == 2 && points[0].equals(points[1])) {
return Arrays.asList(new LatLng(points[0].getY(), points[1].getX()));
}
List<LatLng> path = new ArrayList<>(points.length);
for (Point p : points) {
path.add(new LatLng(p.getY(), p.getX()));
}
return path;
}
示例8: reverseMap
import org.postgis.LineString; //导入依赖的package包/类
@Override
public Map<String, Object> reverseMap(List<LatLng> latLngs, Action action) {
LineString lineString = Mappers.toLineString(latLngs);
PGgeometry pggeom = new PGgeometry(lineString);
Map<String, Object> params = new HashMap<>(1);
params.put(colName, pggeom);
return params;
}
示例9: getCurve
import org.postgis.LineString; //导入依赖的package包/类
@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;
}
示例10: getTypeHandler
import org.postgis.LineString; //导入依赖的package包/类
@Override
protected TypeHandler<LineString> getTypeHandler() {
return TYPE_HANDLER;
}
示例11: doImport
import org.postgis.LineString; //导入依赖的package包/类
private boolean doImport(long startTime, long endTime, List<FCDEntry> fcdPoints) throws SQLException {
List<GPXEntry> unmatchedPoints = new ArrayList<GPXEntry>();
List<FCDEntry> matchedPoints = new ArrayList<FCDEntry>();
// prepare GPX list for MapMatcher
for (FCDEntry fcdEntry : fcdPoints)
unmatchedPoints.add(fcdEntry.toGPXEntry());
// first: map match the FCD subset
List<GPXEntry> matchedGPX = mapMatcher.doMapMatching(unmatchedPoints);
if (matchedGPX == null)
return false;
else
// convert GPX list to FCDEntry list for TimeMatcher
for (GPXEntry gpxEntry : matchedGPX)
matchedPoints.add(new FCDEntry(gpxEntry,0));
// second: transfer timestamp of gpxPoints to matchedPoints
matchedPoints = FCDMatcher.doFCDMatching(fcdPoints, matchedPoints);
// third: fill gaps in linestring
matchedPoints = FCDMatcher.fillGaps(matchedPoints);
// if there are still enough points after filling the gaps proceed with database import
if (matchedPoints.size() > 1) {
// fourth: transform list of FCD entries into a PostGIS LineString
LineString lineString = DBUtil.createLinestring(matchedPoints);
// fifth: prepare insert statement
PGgeometry lineStringGeo = new PGgeometry(lineString.toString());
insertStmt.setTimestamp(1, new Timestamp(startTime));
insertStmt.setTimestamp(2, new Timestamp(endTime));
insertStmt.setObject(3, lineStringGeo);
// sixth: add statement to batch
insertStmt.addBatch();
if (++batchCounter == batchLimit)
executeBatch();
return true;
}
else
return false;
}