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


Java LineString.getNumPoints方法代码示例

本文整理汇总了Java中com.vividsolutions.jts.geom.LineString.getNumPoints方法的典型用法代码示例。如果您正苦于以下问题:Java LineString.getNumPoints方法的具体用法?Java LineString.getNumPoints怎么用?Java LineString.getNumPoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.vividsolutions.jts.geom.LineString的用法示例。


在下文中一共展示了LineString.getNumPoints方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: polyStats

import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
private static FeatureStats polyStats(Geometry geom) {
  final FeatureStats featureStats = new FeatureStats();

  for (int i = 0; i < geom.getNumGeometries(); ++i) {
    final Polygon nextPoly = (Polygon) geom.getGeometryN(i);

    // Stats: exterior ring
    final LineString exteriorRing = nextPoly.getExteriorRing();
    featureStats.totalPts += exteriorRing.getNumPoints();
    featureStats.repeatedPts += checkRepeatedPoints2d(exteriorRing);

    // Stats: interior rings
    for (int ringIndex = 0; ringIndex < nextPoly.getNumInteriorRing(); ++ringIndex) {

      final LineString nextInteriorRing = nextPoly.getInteriorRingN(ringIndex);
      featureStats.totalPts += nextInteriorRing.getNumPoints();
      featureStats.repeatedPts += checkRepeatedPoints2d(nextInteriorRing);
    }
  }

  return featureStats;
}
 
开发者ID:OrdnanceSurvey,项目名称:vt-support,代码行数:23,代码来源:JtsGeomStats.java

示例2: toJSON

import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
public static JSONArray toJSON(Polygon poly)
{
	JSONArray coords = new JSONArray(1 + poly.getNumInteriorRing());

	LineString shell = poly.getExteriorRing();

	boolean inverse = shell.getNumPoints() > 1 ? !CoordinateSequences.isCCW(shell.getCoordinateSequence()) : false;
	coords.put(toJSON(shell, inverse));

	if (poly.getNumInteriorRing() > 0)
	{
		int nRings = poly.getNumInteriorRing();

		for (int j = 0; j < nRings; ++j)
		{
			LineString ring = poly.getInteriorRingN(j);
			inverse = ring.getNumPoints() > 1 ? CoordinateSequences.isCCW(ring.getCoordinateSequence()) : false;
			coords.put(toJSON(ring, inverse));
		}
	}

	return coords;
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:24,代码来源:GeometryJSON.java

示例3: getLength

import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
public static double getLength(Geometry geom, Boolean inMeters) throws Exception
{
	if (!(geom instanceof LineString))
		throw new Exception("Specified geometry type is not supported.");

	LineString ls = (LineString)geom;
	if (ls.getNumPoints() == 0)
		return 0.0;

	if (inMeters)
	{
		double length = 0.0;
		DistanceCalc dc = new DistanceCalcEarth();

		Coordinate c0  = ls.getCoordinateN(0);
		for (int i = 1; i < ls.getNumPoints(); ++i)
		{
			Coordinate c1 = ls.getCoordinateN(i);
			length += dc.calcDist(c0.y, c0.x, c1.y, c1.x);
			c0 = c1;
		}

		return length;
	}
	else
		return ls.getLength();
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:28,代码来源:GeomUtility.java

示例4: getLength

import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
public double getLength(DistanceCalc dc) {
	double res = 0;

	if (this.getGeometry() != null) {
		LineString ls = (LineString) this.getGeometry();
		int nPoints = ls.getNumPoints();

		if (nPoints > 1) {
			Coordinate c = ls.getCoordinateN(0);
			double x0 = c.x;
			double y0 = c.y;
			for (int i = 1; i < ls.getNumPoints(); i++) {
				c = ls.getCoordinateN(i);

				res += dc.calcDist(y0, x0, c.y, c.x);
				x0 = c.x;
				y0 = c.y;
			}
		}
	}

	return res;
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:24,代码来源:RouteSegmentInfo.java

示例5: computeBoundaryCoordinates

import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
private Coordinate[] computeBoundaryCoordinates(MultiLineString mLine) {
    List bdyPts = new ArrayList();
    this.endpointMap = new TreeMap();
    for (int i = 0; i < mLine.getNumGeometries(); i++) {
        LineString line = (LineString) mLine.getGeometryN(i);
        if (line.getNumPoints() == 0) {
            continue;
        }
        this.addEndpoint(line.getCoordinateN(0));
        this.addEndpoint(line.getCoordinateN(line.getNumPoints() - 1));
    }

    for (Object o : endpointMap.entrySet()) {
        Map.Entry entry = (Map.Entry) o;
        Counter counter = (Counter) entry.getValue();
        int valence = counter.count;
        if (this.bnRule.isInBoundary(valence)) {
            bdyPts.add(entry.getKey());
        }
    }

    return CoordinateArrays.toCoordinateArray(bdyPts);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:24,代码来源:BoundaryOp.java

示例6: isValid

import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
/**
 * Tests whether this location refers to a valid
 * location on the given linear {@link Geometry}.
 *
 * @param linearGeom a linear geometry
 * @return true if this location is valid
 */
public boolean isValid(Geometry linearGeom) {
    if (this.componentIndex < 0 || this.componentIndex >= linearGeom.getNumGeometries()) {
        return false;
    }

    LineString lineComp = (LineString) linearGeom.getGeometryN(this.componentIndex);
    if (this.segmentIndex < 0 || this.segmentIndex > lineComp.getNumPoints()) {
        return false;
    }
    if (this.segmentIndex == lineComp.getNumPoints() && this.segmentFraction != 0.0) {
        return false;
    }

    return !(segmentFraction < 0.0 || segmentFraction > 1.0);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:23,代码来源:LinearLocation.java

示例7: appendLineStringText

import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
/**
 * Converts a <code>LineString</code> to &lt;LineString Text&gt; format, then
 * appends it to the writer.
 *
 * @param lineString the <code>LineString</code> to process
 * @param writer the output writer to append to
 */
private void appendLineStringText(LineString lineString, int level, boolean doIndent, Writer writer)
        throws IOException {
    if (lineString.isEmpty()) {
        writer.write("EMPTY");
    } else {
        if (doIndent) {
            this.indent(level, writer);
        }
        writer.write("(");
        for (int i = 0; i < lineString.getNumPoints(); i++) {
            if (i > 0) {
                writer.write(", ");
                if (this.coordsPerLine > 0
                        && i % this.coordsPerLine == 0) {
                    this.indent(level + 1, writer);
                }
            }
            this.appendCoordinate(lineString.getCoordinateN(i), writer);
        }
        writer.write(")");
    }
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:30,代码来源:WKTWriter.java

示例8: addPolygon

import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
private void addPolygon(String name, Polygon poly, int color) {
    final PolygonOptions polyOptions = new PolygonOptions();
    final LineString exteriorRing = poly.getExteriorRing();
    for (int iPnt = 0; iPnt < exteriorRing.getNumPoints(); iPnt++) {
        final Point p = exteriorRing.getPointN(iPnt);
        polyOptions.add(new LatLng(p.getY(), p.getX()));
    }

    for (int iHole = 0; iHole < poly.getNumInteriorRing(); iHole++) {
        final LineString interiorRing = poly.getInteriorRingN(iHole);
        final List<LatLng> holePnts = new ArrayList<LatLng>();
        for (int iPnt = 0; iPnt < interiorRing.getNumPoints(); iPnt++) {
            final Point pnt = interiorRing.getPointN(iPnt);
            holePnts.add(new LatLng(pnt.getY(), pnt.getX()));
        }

        polyOptions.addHole(holePnts);
    }

    mMap.addPolygon(polyOptions
            .strokeWidth(1)
            .strokeColor(Color.DKGRAY)
            .fillColor(color));
}
 
开发者ID:sevar83,项目名称:SpatiAtlas,代码行数:25,代码来源:MapFragment.java

示例9: apply

import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
@Override
public Set<GeoHash> apply(@NonNull LineString segment, @NonNull Integer precision) {
	if (segment.getNumPoints() != 2) {
		throw new IllegalArgumentException();
	}
	final GeoHash destination = this.coordinateDiscretizer.apply(segment.getCoordinateN(1), precision);
	final Set<GeoHash> accumulator = new HashSet<>();
	Set<GeoHash> seed = Stream.of(this.coordinateDiscretizer.apply(segment.getCoordinateN(0), precision))
			.collect(toSet());
	while (!accumulator.contains(destination)) {
		accumulator.addAll(seed);
		seed = seed.stream()
				.flatMap(geoHash -> Stream.of(geoHash.getAdjacent()))
				.distinct()
				.filter(geoHash -> this.geoHash2Geometry.apply(geoHash, segment.getFactory())
						.intersects(segment))
				.collect(toSet());
	}
	return accumulator;
}
 
开发者ID:adrianulbona,项目名称:jts-discretizer,代码行数:21,代码来源:SegmentDiscretizer.java

示例10: performMove

import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
protected void performMove(Point imagePosition, OpenGLContext context) {
    if (selectedGeometry == null) {
        //super.mouseClicked(imagePosition, IClickable.BUTTON1, context);

        if (this.editedPoint == null && selectedGeometry != null) {
            if (type.equals(GeometryImage.POINT)) {
                this.editedPoint = selectedGeometry.getCoordinate();
            } else if (type.equals(GeometryImage.POLYGON)) {
                LineString ls = ((Polygon) selectedGeometry).getExteriorRing();
                for (int i = 0; i < ls.getNumPoints(); i++) {
                    Coordinate point = ls.getCoordinateN(i);
                    if (Math.abs(imagePosition.x - point.x) < 5 * context.getZoom() && Math.abs(imagePosition.y - point.y) < 5 * context.getZoom()) {
                        this.editedPoint = point;
                        break;
                    }
                }
            }
            if (this.editedPoint == null) {
                selectedGeometry.geometryChanged();
                selectedGeometry = null;
            }
        } else {
            if (selectedGeometry != null) {
                selectedGeometry.geometryChanged();
            }
            this.editedPoint = null;
        }
    } else {
        selectedGeometry.geometryChanged();
        editedPoint = null;
        selectedGeometry = null;
    }
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:34,代码来源:EditGeometryVectorLayer.java

示例11: lineStats

import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
private static FeatureStats lineStats(Geometry geom) {
  final FeatureStats featureStats = new FeatureStats();

  for (int i = 0; i < geom.getNumGeometries(); ++i) {
    final LineString lineString = (LineString) geom.getGeometryN(i);
    featureStats.totalPts += lineString.getNumPoints();
    featureStats.repeatedPts += checkRepeatedPoints2d(lineString);
  }

  return featureStats;
}
 
开发者ID:OrdnanceSurvey,项目名称:vt-support,代码行数:12,代码来源:JtsGeomStats.java

示例12: canMergeGeometries

import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
private static boolean canMergeGeometries(List<Geometry> geoms)
{
	int i = 0;
	Coordinate pLast = null;
	
	for(Geometry geom : geoms)
	{
		LineString ls = (LineString)geom;
		
		if (i > 0)
		{
			int nCoords = ls.getNumPoints();
			Coordinate pEnd = pLast;
			Coordinate p0 = ls.getCoordinateN(0);
			Coordinate pN = ls.getCoordinateN(nCoords - 1);
			double dist0 = distCalc.calcDist(pEnd.y,  pEnd.x, p0.y, p0.x);
			double distN = distCalc.calcDist(pEnd.y,  pEnd.x, pN.y, pN.x);
			if (dist0 > 15 && distN > 15)
				return false;
		}
		
		pLast = ls.getCoordinateN(ls.getNumPoints() - 1);
		
		i++;
	}
	
	return true;
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:29,代码来源:TrafficUtility.java

示例13: copyConvexHullPoints

import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
private void copyConvexHullPoints(Polygon poly)
{
	LineString ring = (LineString)poly.getExteriorRing();		
	if (prevIsoPoints == null)
		prevIsoPoints = new ArrayList<Coordinate>(ring.getNumPoints());
	else
		prevIsoPoints.clear();
	for (int i = 0; i< ring.getNumPoints(); ++i)
	{
		Point p = ring.getPointN(i);
		prevIsoPoints.add(new Coordinate(p.getX(), p.getY()));
	}
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:14,代码来源:ConcaveBallsIsochroneMapBuilder.java

示例14: getArea

import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
/**
 * Convert a linear ring to an area using the coordinate transformation.
 *
 * @param ring the ring to create an area from
 * @param ct the transformation to apply
 * @return the created area.
 */
public static Area getArea(LineString ring, CoordinateTransformer ct) {
    Path2D.Double path = new Path2D.Double();
    Coordinate coord = ring.getCoordinateN(0);
    path.moveTo(ct.getX(coord.x), ct.getY(coord.y));
    for (int i = 1; i < ring.getNumPoints(); i++) {
        coord = ring.getCoordinateN(i);
        path.lineTo(ct.getX(coord.x), ct.getY(coord.y));
    }
    path.closePath();
    return new Area(path);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:19,代码来源:Jts2Awt.java

示例15: getPath

import com.vividsolutions.jts.geom.LineString; //导入方法依赖的package包/类
/**
 * Convert a linestring to a path using the coordinate transformation.
 *
 * @param string the string to create a path from.
 * @param ct the transformation to apply.
 * @return the path created.
 */
public static Path2D getPath(LineString string, CoordinateTransformer ct) {
    Path2D.Double path = new Path2D.Double();
    Coordinate coord = string.getCoordinateN(0);
    path.moveTo(ct.getX(coord.x), ct.getY(coord.y));
    for (int i = 1; i < string.getNumPoints(); i++) {
        coord = string.getCoordinateN(i);
        path.lineTo(ct.getX(coord.x), ct.getY(coord.y));
    }
    return path;
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:18,代码来源:Jts2Awt.java


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