• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java LineString类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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));
}
 
开发者ID:pietermartin,项目名称:sqlg,代码行数:23,代码来源:TestGisBulkWithin.java


示例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;
}
 
开发者ID:3dcitydb,项目名称:importer-exporter,代码行数:22,代码来源:GeometryConverterAdapter.java


示例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;
}
 
开发者ID:3dcitydb,项目名称:importer-exporter,代码行数:25,代码来源:GeometryConverterAdapter.java


示例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);
}
 
开发者ID:eyougo,项目名称:mybatis-typehandlers-postgis,代码行数:14,代码来源:LineStringTypeHandlerTest.java


示例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;
}
 
开发者ID:MAGDa-BeuthHS,项目名称:fcd2pgsql,代码行数:13,代码来源:DBUtil.java


示例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;
}
 
开发者ID:vramirez122000,项目名称:trenurbanoapp,代码行数:15,代码来源:Mappers.java


示例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;
}
 
开发者ID:vramirez122000,项目名称:trenurbanoapp,代码行数:15,代码来源:PolyLineMapper.java


示例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;
}
 
开发者ID:vramirez122000,项目名称:trenurbanoapp,代码行数:9,代码来源:PolyLineMapper.java


示例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;
}
 
开发者ID:3dcitydb,项目名称:importer-exporter,代码行数:15,代码来源:GeometryConverterAdapter.java


示例10: getTypeHandler

import org.postgis.LineString; //导入依赖的package包/类
@Override
protected TypeHandler<LineString> getTypeHandler() {
    return TYPE_HANDLER;
}
 
开发者ID:eyougo,项目名称:mybatis-typehandlers-postgis,代码行数:5,代码来源:LineStringTypeHandlerTest.java


示例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;
}
 
开发者ID:MAGDa-BeuthHS,项目名称:fcd2pgsql,代码行数:47,代码来源:FCDImporter.java



注:本文中的org.postgis.LineString类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CGrid类代码示例发布时间:2022-05-22
下一篇:
Java XEvent类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap