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

Java LinearLocation类代码示例

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

本文整理汇总了Java中com.vividsolutions.jts.linearref.LinearLocation的典型用法代码示例。如果您正苦于以下问题:Java LinearLocation类的具体用法?Java LinearLocation怎么用?Java LinearLocation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



LinearLocation类属于com.vividsolutions.jts.linearref包,在下文中一共展示了LinearLocation类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: splitGeometryAtPoint

import com.vividsolutions.jts.linearref.LinearLocation; //导入依赖的package包/类
/**
 * Splits the input geometry into two LineStrings at the given point.
 */
public static P2<LineString> splitGeometryAtPoint(Geometry geometry, Coordinate nearestPoint) {
    // An index in JTS can actually refer to any point along the line. It is NOT an array index.
    LocationIndexedLine line = new LocationIndexedLine(geometry);
    LinearLocation l = line.indexOf(nearestPoint);
    
    LineString beginning = (LineString) line.extractLine(line.getStartIndex(), l);
    LineString ending = (LineString) line.extractLine(l, line.getEndIndex());
    
    return new P2<LineString>(beginning, ending);
}
 
开发者ID:trein,项目名称:gtfs-java,代码行数:14,代码来源:GeometryUtils.java


示例2: splitGeometryAtFraction

import com.vividsolutions.jts.linearref.LinearLocation; //导入依赖的package包/类
/**
 * Splits the input geometry into two LineStrings at a fraction of the distance covered.
 */
public static P2<LineString> splitGeometryAtFraction(Geometry geometry, double fraction) {
    LineString empty = new LineString(null, gf);
    Coordinate[] coordinates = geometry.getCoordinates();
    CoordinateSequence sequence = gf.getCoordinateSequenceFactory().create(coordinates);
    LineString total = new LineString(sequence, gf);
    
    if (coordinates.length < 2) { return new P2<LineString>(empty, empty); }
    if (fraction <= 0) { return new P2<LineString>(empty, total); }
    if (fraction >= 1) { return new P2<LineString>(total, empty); }
    
    double totalDistance = total.getLength();
    double requestedDistance = totalDistance * fraction;
    
    // An index in JTS can actually refer to any point along the line. It is NOT an array index.
    LocationIndexedLine line = new LocationIndexedLine(geometry);
    LinearLocation l = LengthLocationMap.getLocation(geometry, requestedDistance);
    
    LineString beginning = (LineString) line.extractLine(line.getStartIndex(), l);
    LineString ending = (LineString) line.extractLine(l, line.getEndIndex());
    
    return new P2<LineString>(beginning, ending);
}
 
开发者ID:trein,项目名称:gtfs-java,代码行数:26,代码来源:GeometryUtils.java


示例3: snapPointToLineStringByLIL

import com.vividsolutions.jts.linearref.LinearLocation; //导入依赖的package包/类
public static Point snapPointToLineStringByLIL(LineString line, Point point) {
	//new PrecisionModel(
	System.out.println("scale " + pm.getScale());
	LocationIndexedLine lil = new LocationIndexedLine(line);
	LinearLocation here = lil.project(point.getCoordinate());
	Coordinate coord = lil.extractPoint(here, 0);
	Point p = gf.createPoint(coord);
	
	System.out.println("LIL isContains : " + line.contains(p));
	System.out.println("point : " + point.toText());
	System.out.println("extracted poitn : " + p.toText());
	
	return p;
}
 
开发者ID:STEMLab,项目名称:JInedit,代码行数:15,代码来源:JTSUtil.java


示例4: evaluate

import com.vividsolutions.jts.linearref.LinearLocation; //导入依赖的package包/类
public <T> T evaluate(Object object, Class<T> context) {
    Expression pointExpression = parameters.get(0);
    Point point = pointExpression.evaluate(object, Point.class);

    Expression lineExpression = parameters.get(1);
    Geometry line = lineExpression.evaluate(object, Geometry.class);

    LocationIndexedLine index = new LocationIndexedLine(line);

    LinearLocation location = index.project(point.getCoordinate());

    Coordinate snap = index.extractPoint(location);

    Point pt = point.getFactory().createPoint(snap);

    return Converters.convert(pt, context); // convert to requested format
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:18,代码来源:SnapFunction.java


示例5: distanceOnLineStringInMeter

import com.vividsolutions.jts.linearref.LinearLocation; //导入依赖的package包/类
/**
 * ACHTUNG 
 * 
 * Diese Methode liefert bei Anwendung auf WGS84 Koordinaten falsche Ergebnisse, der Fehler wird 
 * umso größer, je weiter der zu projizierende Punkt von der Linie entfernt ist und je weiter der Punkt vom Aquator entfernt ist.
 *  Wenn der zu projizierende Punkt auf der Linie liegt sollte der Fehler 0 sein.
 *  
 *  Für Salzburg (ca 13E 48N) beträgt der Fehler auf einer 45° schrägen Linie 38.6% des Abstandes von der Linie. D.h. beträgt 
 *  der Abstand des Punktes von der Linie 5m beträgt der Fehler 1,93m.
 *  
 * @param p
 * @param lineString
 * @return
 */
public static double distanceOnLineStringInMeter(Point p, LineString lineString) {
	
	if (p.getSRID() != lineString.getSRID()) {
		throw new IllegalArgumentException("SRID of parameter p is not the same as from parameter lineString");
	}
	LocationIndexedLine indexedStartSeg = new LocationIndexedLine(lineString);
	LinearLocation startLoc = indexedStartSeg.project(p.getCoordinate());
	Geometry cutStartGeom = indexedStartSeg.extractLine(indexedStartSeg.getStartIndex(), startLoc);
	cutStartGeom.setSRID(lineString.getSRID());
	double lengthInMeter = calculateLengthMeterFromWGS84LineStringAndoyer((LineString) cutStartGeom);
	return lengthInMeter;
}
 
开发者ID:graphium-project,项目名称:graphium,代码行数:27,代码来源:GeometryUtils.java


示例6: projectPointOnLineString

import com.vividsolutions.jts.linearref.LinearLocation; //导入依赖的package包/类
/**
 * ACHTUNG 
 * 
 * Diese Methode liefert bei Anwendung auf WGS84 Koordinaten eventuell falsche Ergebnisse. 
 * Siehe distanceOnLineStringInMeter()
 * @param p
 * @param lineString
 * @return
 */
public static Point projectPointOnLineString(Point p, LineString lineString) {
	LocationIndexedLine line = new LocationIndexedLine(lineString);
	LinearLocation here = line.project(p.getCoordinate());
	Coordinate coord = line.extractPoint( here );
	Point point = createPoint(coord, lineString.getSRID());		
	return point;
}
 
开发者ID:graphium-project,项目名称:graphium,代码行数:17,代码来源:GeometryUtils.java


示例7: generateProtoRouteStop

import com.vividsolutions.jts.linearref.LinearLocation; //导入依赖的package包/类
private ProtoRouteStop generateProtoRouteStop(LineString ls, LinearLocation ix) {
	double dist = distAlongLineString( ls, ix );
	
	ProtoRouteStop prs = new ProtoRouteStop(ix.getCoordinate(ls), dist);
	
	return prs;
}
 
开发者ID:conveyal,项目名称:geom2gtfs,代码行数:8,代码来源:ShapefileStopGenerator.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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