当前位置: 首页>>代码示例>>Java>>正文


Java Polyline类代码示例

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


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


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