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

Java Polyline类代码示例

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

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



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

示例1: BaseRoad

import com.esri.core.geometry.Polyline; //导入依赖的package包/类
/**
 * Constructs {@link BaseRoad} object.
 *
 * @param id Unique road identifier.
 * @param source Source vertex identifier (in road topology representation).
 * @param target Target vertex identifier (in road topology representation).
 * @param refid Identifier of road referring to some source data.
 * @param oneway Indicator if this road is a one-way road.
 * @param type Identifier of this road's type.
 * @param priority Road priority factor, which is greater or equal than one.
 * @param maxspeedForward Maximum speed limit for passing this road from source to target.
 * @param maxspeedBackward Maximum speed limit for passing this road from target to source.
 * @param length Length of road geometry in meters.
 * @param geometry Road's geometry from source to target as {@link Polyline} object.
 */
public BaseRoad(long id, long source, long target, long refid, boolean oneway, short type,
        float priority, float maxspeedForward, float maxspeedBackward, float length,
        Polyline geometry) {
    this.id = id;
    this.source = source;
    this.target = target;
    this.refid = refid;
    this.oneway = oneway;
    this.type = type;
    this.priority = priority;
    this.maxspeedForward = maxspeedForward;
    this.maxspeedBackward = maxspeedBackward;
    this.length = length;
    this.geometry = OperatorExportToWkb.local()
            .execute(WkbExportFlags.wkbExportLineString, geometry, null).array();
}
 
开发者ID:bmwcarit,项目名称:barefoot,代码行数:32,代码来源:BaseRoad.java


示例2: monitorRoute

import com.esri.core.geometry.Polyline; //导入依赖的package包/类
private Polyline monitorRoute(MatcherCandidate candidate) {
    Polyline routes = new Polyline();
    MatcherCandidate predecessor = candidate;
    while (predecessor != null) {
        MatcherTransition transition = predecessor.transition();
        if (transition != null) {
            Polyline route = transition.route().geometry();
            routes.startPath(route.getPoint(0));
            for (int i = 1; i < route.getPointCount(); ++i) {
                routes.lineTo(route.getPoint(i));
            }
        }
        predecessor = predecessor.predecessor();
    }
    return routes;
}
 
开发者ID:bmwcarit,项目名称:barefoot,代码行数:17,代码来源:MatcherKState.java


示例3: testPathAzimuth

import com.esri.core.geometry.Polyline; //导入依赖的package包/类
@Test
public void testPathAzimuth() {
    Point reyk = new Point(-21.933333, 64.15);
    Point berl = new Point(13.408056, 52.518611);
    Point mosk = new Point(37.616667, 55.75);

    Polyline p = new Polyline();
    p.startPath(berl);
    p.lineTo(mosk);
    p.lineTo(reyk);

    assertEquals(azimuth(berl, mosk, true), spatial.azimuth(p, 0f), 1E-9);
    assertEquals(azimuth(mosk, reyk, false), spatial.azimuth(p, 1f), 1E-9);
    assertEquals(azimuth(berl, mosk, false),
            spatial.azimuth(p, spatial.distance(berl, mosk) / spatial.length(p)), 1E-9);
    Point c = spatial.interpolate(berl, mosk, 0.5);
    assertEquals(azimuth(berl, c, false),
            spatial.azimuth(p, spatial.distance(berl, c) / spatial.length(p)), 1E-9);
    Point d = spatial.interpolate(mosk, reyk, 0.5);
    assertEquals(azimuth(mosk, d, false), spatial.azimuth(p,
            (spatial.distance(berl, mosk) + spatial.distance(mosk, d)) / spatial.length(p)),
            1E-9);
}
 
开发者ID:bmwcarit,项目名称:barefoot,代码行数:24,代码来源:GeographyTest.java


示例4: testJSON

import com.esri.core.geometry.Polyline; //导入依赖的package包/类
@Test
public void testJSON() throws JSONException {
    String wkt = "LINESTRING(11.3136273 48.0972002,11.3138846 48.0972999)";
    BaseRoad osm = new BaseRoad(0L, 1L, 2L, 4L, true, (short) 5, 5.1F, 6.1F, 6.2F, 7.1F,
            (Polyline) GeometryEngine.geometryFromWkt(wkt, WktImportFlags.wktImportDefaults,
                    Geometry.Type.Polyline));

    RoadMap map = new RoadMap();
    map.add(new Road(osm, Heading.forward));

    RoadPoint point1 = new RoadPoint(map.get(0L), 0.2);

    String json = point1.toJSON().toString();
    RoadPoint point2 = RoadPoint.fromJSON(new JSONObject(json), map);

    assertEquals(point1.edge().id(), point2.edge().id());
    assertEquals(point1.fraction(), point2.fraction(), 1E-6);
    assertEquals(point1.edge().source(), point2.edge().source());
    assertEquals(point1.edge().target(), point2.edge().target());
}
 
开发者ID:bmwcarit,项目名称:barefoot,代码行数:21,代码来源:RoadPointTest.java


示例5: testJSON

import com.esri.core.geometry.Polyline; //导入依赖的package包/类
@Test
public void testJSON() throws JSONException {
    String wkt = "LINESTRING(11.3136273 48.0972002,11.3138846 48.0972999)";
    BaseRoad osm = new BaseRoad(0L, 1L, 2L, 4L, true, (short) 5, 5.1F, 6.1F, 6.2F, 7.1F,
            (Polyline) GeometryEngine.geometryFromWkt(wkt, WktImportFlags.wktImportDefaults,
                    Geometry.Type.Polyline));

    Road road = new Road(osm, Heading.forward);
    RoadMap map = new RoadMap();
    map.add(road);

    String json = road.toJSON().toString();
    Road road2 = Road.fromJSON(new JSONObject(json), map);

    assertEquals(road, road2);
}
 
开发者ID:bmwcarit,项目名称:barefoot,代码行数:17,代码来源:RoadTest.java


示例6: makeLine

import com.esri.core.geometry.Polyline; //导入依赖的package包/类
private static Geom makeLine(Geom... geoms) {
  final Polyline g = new Polyline();
  Point p = null;
  for (Geom geom : geoms) {
    if (geom.g() instanceof Point) {
      final Point prev = p;
      p = (Point) geom.g();
      if (prev != null) {
        final Line line = new Line();
        line.setStart(prev);
        line.setEnd(p);
        g.addSegment(line, false);
      }
    }
  }
  return new SimpleGeom(g);
}
 
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:GeoFunctions.java


示例7: type

import com.esri.core.geometry.Polyline; //导入依赖的package包/类
/** Returns the OGC type of a geometry. */
private static Type type(Geometry g) {
  switch (g.getType()) {
  case Point:
    return Type.POINT;
  case Polyline:
    return Type.LINESTRING;
  case Polygon:
    return Type.POLYGON;
  case MultiPoint:
    return Type.MULTIPOINT;
  case Envelope:
    return Type.POLYGON;
  case Line:
    return Type.LINESTRING;
  case Unknown:
    return Type.Geometry;
  default:
    throw new AssertionError(g);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:GeoFunctions.java


示例8: bufferLine

import com.esri.core.geometry.Polyline; //导入依赖的package包/类
/**
 * Create a buffer for a line.
 * @param lineJsonString A JSON string defining the line.
 * @param distance The buffer distance.
 * @return A JSON string with the buffer polygon.
 */
public static String bufferLine(String lineJsonString, double distance){
	String geoJson = null;
	try{
		Polyline polyline = new Polyline();
		JSONObject lineJson = new JSONObject(lineJsonString);
		JSONArray paths = lineJson.getJSONArray("paths");
		JSONArray line = paths.getJSONArray(0);
		for(int k = 0; k < line.length(); k++){
			JSONArray point = line.getJSONArray(k);
			double x = point.getDouble(0);
			double y = point.getDouble(1);
			if(k == 0){
				polyline.startPath(x, y);
			}else{
				polyline.lineTo(x, y);
			}
		}
		SpatialReference srsWGS84 = SpatialReference.create(SpatialReference.WKID_WGS84);
		SpatialReference srsWebMercator = SpatialReference.create(SpatialReference.WKID_WGS84_WEB_MERCATOR);
		Geometry mercatorPolyline = GeometryEngine.project(polyline, srsWGS84, srsWebMercator);
		Polygon mercatorPolygon = GeometryEngine.buffer(mercatorPolyline, srsWebMercator, distance, srsWebMercator.getUnit());
		Polygon polygon = (Polygon) GeometryEngine.project(mercatorPolygon, srsWebMercator, srsWGS84);
		geoJson = GeometryEngine.geometryToJson(srsWGS84, polygon);			
	}catch(Exception e){
		log.error("Error creating line buffer: "+e.getMessage());
	}
	return geoJson;
}
 
开发者ID:EsriDE,项目名称:PTM-OSMGeotrigger,代码行数:35,代码来源:Util.java


示例9: evaluate

import com.esri.core.geometry.Polyline; //导入依赖的package包/类
public BytesWritable evaluate(DoubleWritable ... xyPairs) throws UDFArgumentException{
	
	if (xyPairs == null || xyPairs.length == 0 ||  xyPairs.length%2 != 0) {
		return null;
	}

	try {		
		Polyline linestring = new Polyline();
		linestring.startPath(xyPairs[0].get(), xyPairs[1].get());
	
		for (int i=2; i<xyPairs.length; i+=2) {
			linestring.lineTo(xyPairs[i].get(), xyPairs[i+1].get());
		}
	
		return GeometryUtils.geometryToEsriShapeBytesWritable(OGCGeometry.createFromEsriGeometry(linestring, null));
	} catch (Exception e) {
	    LogUtils.Log_InternalError(LOG, "ST_LineString: " + e);
	    return null;
	}
}
 
开发者ID:Esri,项目名称:spatial-framework-for-hadoop,代码行数:21,代码来源:ST_LineString.java


示例10: testGeomFromLineShape

import com.esri.core.geometry.Polyline; //导入依赖的package包/类
@Test
public void testGeomFromLineShape() throws UDFArgumentException {
	Polyline line = createLine();
	byte[] esriShape = GeometryEngine.geometryToEsriShape(line);
	assertNotNull("The shape must not be null!", esriShape);

	BytesWritable shapeAsWritable = new BytesWritable(esriShape);
	assertNotNull("The shape writable must not be null!", shapeAsWritable);

	final int wkid = 4326;
	ST_GeomFromShape fromShape = new ST_GeomFromShape();
	BytesWritable geometryAsWritable = fromShape.evaluate(shapeAsWritable, wkid);
	assertNotNull("The geometry writable must not be null!", geometryAsWritable);

	OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geometryAsWritable);
	assertNotNull("The OGC geometry must not be null!", ogcGeometry);

	Geometry esriGeometry = ogcGeometry.getEsriGeometry();
	assertNotNull("The Esri geometry must not be null!", esriGeometry);
	assertTrue("The geometries are different!",
			GeometryEngine.equals(line, esriGeometry, SpatialReference.create(wkid)));
}
 
开发者ID:Esri,项目名称:spatial-framework-for-hadoop,代码行数:23,代码来源:TestStGeomFromShape.java


示例11: testGeomFromPolylineShape

import com.esri.core.geometry.Polyline; //导入依赖的package包/类
@Test
public void testGeomFromPolylineShape() throws UDFArgumentException {
	Polyline line = createPolyline();
	byte[] esriShape = GeometryEngine.geometryToEsriShape(line);
	assertNotNull("The shape must not be null!", esriShape);

	BytesWritable shapeAsWritable = new BytesWritable(esriShape);
	assertNotNull("The shape writable must not be null!", shapeAsWritable);

	final int wkid = 4326;
	ST_GeomFromShape fromShape = new ST_GeomFromShape();
	BytesWritable geometryAsWritable = fromShape.evaluate(shapeAsWritable, wkid);
	assertNotNull("The geometry writable must not be null!", geometryAsWritable);

	OGCGeometry ogcGeometry = GeometryUtils.geometryFromEsriShape(geometryAsWritable);
	assertNotNull("The OGC geometry must not be null!", ogcGeometry);

	Geometry esriGeometry = ogcGeometry.getEsriGeometry();
	assertNotNull("The Esri geometry must not be null!", esriGeometry);
	assertTrue("The geometries are different!",
			GeometryEngine.equals(line, esriGeometry, SpatialReference.create(wkid)));
}
 
开发者ID:Esri,项目名称:spatial-framework-for-hadoop,代码行数:23,代码来源:TestStGeomFromShape.java


示例12: parseLineStringCoordinates

import com.esri.core.geometry.Polyline; //导入依赖的package包/类
/**
 * Parses a line string
 * Example:
 * [ [100.0, 0.0], [101.0, 1.0] ].
 * @param parser
 * @return a polyline.
 * @throws Exception
 */
private Polyline parseLineStringCoordinates(JsonNode node) {
  Polyline g = new Polyline();
  boolean first = true;
  ArrayNode points = (ArrayNode) node;
  for (JsonNode point : points) {
    Point p = parsePointCoordinates(point);
    if (first) {
      g.startPath(p);
      first = false;
    } else {
      g.lineTo(p);
    }  
  }
  return g;
}
 
开发者ID:Esri,项目名称:arcgis-runtime-demo-java,代码行数:24,代码来源:GeoJsonParser.java


示例13: getEndPoint

import com.esri.core.geometry.Polyline; //导入依赖的package包/类
private Point getEndPoint(Polyline polyln)
{
	try {
		int pathCount = polyln.getPathCount();
		int endIndex = polyln.getPathEnd(pathCount - 1);
		return polyln.getPoint(endIndex-1);
	} catch (Exception e) {
		LOGGER.error(e.getMessage());
		throw (e);
	}
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:12,代码来源:Line2PtProcessor.java


示例14: GenerateGeometry

import com.esri.core.geometry.Polyline; //导入依赖的package包/类
private MapGeometry GenerateGeometry(Double ox, Double oy, Double dx, Double dy, SpatialReference sr)
{
	Point origin = new Point();
	Point destination = new Point();
	origin.setXY(ox, oy);
	destination.setXY(dx, dy);
	Polyline ln = new Polyline();
	ln.startPath(origin);
	ln.lineTo(destination);
	MapGeometry mapGeo = new MapGeometry(ln, sr);
	return mapGeo;
	
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:14,代码来源:BearingProcessor.java


示例15: processVertices

import com.esri.core.geometry.Polyline; //导入依赖的package包/类
private void processVertices(GeoEvent ge, Polyline polyln, double distTotal, long start, long end, LinearUnit lu, Boolean projected) throws MessagingException, FieldException
{
	int count = polyln.getPointCount();
	double currentDist = 0;
	long currentTime = start;
	long totalTime = end - start;
	Geometry outGeo = null;
	Point projGeo = null;
	Point lastPoint = null;
	for(int i = 0; i < count; ++i)
	{
		projGeo = polyln.getPoint(i);
		
		if(i!=0)
		{
			Polyline seg = new Polyline();
			seg.startPath(lastPoint);
			seg.lineTo(projGeo);
			double segDist = GeometryEngine.geodesicLength(seg, processSr, lu);
			currentDist += segDist;
			double percent = currentDist/distTotal;
			currentTime = (long) Math.floor((start + (totalTime*percent)));
			
		}
		if(projected)
		{
			outGeo = GeometryEngine.project(projGeo, processSr, outSr);
		}
		else
		{
			outGeo=projGeo;
		}
		MapGeometry outMapGeo = new MapGeometry(outGeo, outSr);
		double minutesFromStart = (currentTime - start)/60000;
		GeoEvent msg = createVertexGeoevent(ge, outMapGeo, currentDist, currentTime, minutesFromStart, i);
		send(msg);
		lastPoint = projGeo;
	}
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:40,代码来源:IncrementalPointProcessor.java


示例16: getNextPoint

import com.esri.core.geometry.Polyline; //导入依赖的package包/类
private IncrementPoint getNextPoint(Polyline polyln, Point startPt, Integer i, Double dist)
{
	Point startVertex = polyln.getPoint(i);
	Double currentDist = GeometryEngine.distance(startPt, startVertex, processSr);
	Point segStart = null;
	Point segEnd = null;
	Boolean multipleVertices = true;
	if(currentDist > dist)
	{
		segStart = startPt;
		segEnd = startVertex;
		multipleVertices = false;
	}
	while(currentDist < dist)
	{
		Point start = polyln.getPoint(i);
		Point end = polyln.getPoint(i+1);
		currentDist += GeometryEngine.distance(start, end, processSr);
		++i;
	}
	if(multipleVertices)
	{
		segStart = polyln.getPoint(i-1);
		segEnd = polyln.getPoint(i);
	}
	Double segLen = GeometryEngine.distance(segStart, segEnd, processSr);
	Double distOver = currentDist - dist;
	Double distOnSeg = segLen - distOver;
	Point p = findPtOnSegment(segStart, segEnd, distOnSeg);
	IncrementPoint ip = new IncrementPoint(p, i);
	return ip;
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:33,代码来源:IncrementalPointProcessor.java


示例17: toMonitorJSON

import com.esri.core.geometry.Polyline; //导入依赖的package包/类
public JSONObject toMonitorJSON() throws JSONException {
    JSONObject json = new JSONObject();
    json.put("time", sample().time());
    json.put("point", GeometryEngine.geometryToWkt(estimate().point().geometry(),
            WktExportFlags.wktExportPoint));
    Polyline routes = monitorRoute(estimate());
    if (routes.getPathCount() > 0) {
        json.put("route",
                GeometryEngine.geometryToWkt(routes, WktExportFlags.wktExportMultiLineString));
    }

    JSONArray candidates = new JSONArray();
    for (MatcherCandidate candidate : vector()) {
        JSONObject jsoncandidate = new JSONObject();
        jsoncandidate.put("point", GeometryEngine.geometryToWkt(candidate.point().geometry(),
                WktExportFlags.wktExportPoint));
        jsoncandidate.put("prob",
                Double.isInfinite(candidate.filtprob()) ? "Infinity" : candidate.filtprob());

        routes = monitorRoute(candidate);
        if (routes.getPathCount() > 0) {
            jsoncandidate.put("route", GeometryEngine.geometryToWkt(routes,
                    WktExportFlags.wktExportMultiLineString));
        }
        candidates.put(jsoncandidate);
    }
    json.put("candidates", candidates);
    return json;
}
 
开发者ID:bmwcarit,项目名称:barefoot,代码行数:30,代码来源:MatcherKState.java


示例18: length

import com.esri.core.geometry.Polyline; //导入依赖的package包/类
@Override
public double length(Polyline p) {
    double d = 0;

    for (int i = 1; i < p.getPointCount(); ++i) {
        d += distance(p.getPoint(i - 1), p.getPoint(i));
    }

    return d;
}
 
开发者ID:bmwcarit,项目名称:barefoot,代码行数:11,代码来源:Geography.java


示例19: intercept

import com.esri.core.geometry.Polyline; //导入依赖的package包/类
@Override
public double intercept(Polyline p, Point c) {
    double d = Double.MAX_VALUE;
    Point a = p.getPoint(0);
    double s = 0, sf = 0, ds = 0;

    for (int i = 1; i < p.getPointCount(); ++i) {
        Point b = p.getPoint(i);

        ds = distance(a, b);

        double f_ = intercept(a, b, c);
        f_ = (f_ > 1) ? 1 : (f_ < 0) ? 0 : f_;
        Point x = interpolate(a, b, f_);
        double d_ = distance(c, x);

        if (d_ < d) {
            sf = (f_ * ds) + s;
            d = d_;
        }

        s = s + ds;
        a = b;
    }

    return s == 0 ? 0 : sf / s;
}
 
开发者ID:bmwcarit,项目名称:barefoot,代码行数:28,代码来源:Geography.java


示例20: interpolate

import com.esri.core.geometry.Polyline; //导入依赖的package包/类
@Override
public Point interpolate(Polyline p, double l, double f) {
    assert (f >= 0 && f <= 1);

    Point a = p.getPoint(0);
    double d = l * f;
    double s = 0, ds = 0;

    if (f < 0 + 1E-10) {
        return p.getPoint(0);
    }

    if (f > 1 - 1E-10) {
        return p.getPoint(p.getPointCount() - 1);
    }

    for (int i = 1; i < p.getPointCount(); ++i) {
        Point b = p.getPoint(i);
        ds = distance(a, b);

        if ((s + ds) >= d) {
            return interpolate(a, b, (d - s) / ds);
        }

        s = s + ds;
        a = b;
    }

    return null;
}
 
开发者ID:bmwcarit,项目名称:barefoot,代码行数:31,代码来源:Geography.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java OrderedBytes类代码示例发布时间:2022-05-22
下一篇:
Java RMAppImpl类代码示例发布时间: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