本文整理汇总了Java中com.vividsolutions.jts.geom.MultiLineString.getGeometryN方法的典型用法代码示例。如果您正苦于以下问题:Java MultiLineString.getGeometryN方法的具体用法?Java MultiLineString.getGeometryN怎么用?Java MultiLineString.getGeometryN使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vividsolutions.jts.geom.MultiLineString
的用法示例。
在下文中一共展示了MultiLineString.getGeometryN方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeBoundaryCoordinates
import com.vividsolutions.jts.geom.MultiLineString; //导入方法依赖的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);
}
示例2: testMultiLineString
import com.vividsolutions.jts.geom.MultiLineString; //导入方法依赖的package包/类
@Test
public void testMultiLineString() throws IOException, JSONException {
String expected = "{\"type\": \"MultiLineString\", "
+ " \"coordinates\": ["
+ " [[10, 10], [20, 20], [10, 40]], "
+ " [[40, 40], [30, 30], [40, 20], [30, 10]]"
+ " ]"
+ "}";
Geometry g = mapper.readValue(expected, Geometry.class);
assertNotNull(g);
assertTrue(g instanceof MultiLineString);
MultiLineString mls = (MultiLineString) g;
assertEquals(2, mls.getNumGeometries());
assertTrue(mls.getGeometryN(0) instanceof LineString);
LineString ls1 = (LineString) mls.getGeometryN(0);
assertEquals(10.0, ls1.getCoordinate().x, MM_PRECISION);
assertTrue(mls.getGeometryN(1) instanceof LineString);
LineString ls2 = (LineString) mls.getGeometryN(1);
assertEquals(40.0, ls2.getCoordinate().x, MM_PRECISION);
String json = mapper.writeValueAsString(mls);
JSONAssert.assertEquals(expected, json, true);
}
示例3: isSequenced
import com.vividsolutions.jts.geom.MultiLineString; //导入方法依赖的package包/类
/**
* Tests whether a {@link Geometry} is sequenced correctly.
* {@link LineString}s are trivially sequenced.
* {@link MultiLineString}s are checked for correct sequencing.
* Otherwise, <code>isSequenced</code> is defined
* to be <code>true</code> for geometries that are not lineal.
*
* @param geom the geometry to test
* @return <code>true</code> if the geometry is sequenced or is not lineal
*/
public static boolean isSequenced(Geometry geom) {
if (!(geom instanceof MultiLineString)) {
return true;
}
MultiLineString mls = (MultiLineString) geom;
// the nodes in all subgraphs which have been completely scanned
Set prevSubgraphNodes = new TreeSet();
Coordinate lastNode = null;
List currNodes = new ArrayList();
for (int i = 0; i < mls.getNumGeometries(); i++) {
LineString line = (LineString) mls.getGeometryN(i);
Coordinate startNode = line.getCoordinateN(0);
Coordinate endNode = line.getCoordinateN(line.getNumPoints() - 1);
/**
* If this linestring is connected to a previous subgraph, geom is not sequenced
*/
if (prevSubgraphNodes.contains(startNode)) {
return false;
}
if (prevSubgraphNodes.contains(endNode)) {
return false;
}
if (lastNode != null) {
if (!startNode.equals(lastNode)) {
// start new connected sequence
prevSubgraphNodes.addAll(currNodes);
currNodes.clear();
}
}
currNodes.add(startNode);
currNodes.add(endNode);
lastNode = endNode;
}
return true;
}
示例4: toShape
import com.vividsolutions.jts.geom.MultiLineString; //导入方法依赖的package包/类
private GeneralPath toShape(MultiLineString mls) {
GeneralPath path = new GeneralPath();
for (int i = 0; i < mls.getNumGeometries(); i++) {
LineString lineString = (LineString) mls.getGeometryN(i);
path.append(this.toShape(lineString), false);
}
return path;
}
示例5: computeLocation
import com.vividsolutions.jts.geom.MultiLineString; //导入方法依赖的package包/类
private void computeLocation(Coordinate p, Geometry geom) {
if (geom instanceof Point) {
this.updateLocationInfo(this.locate(p, (Point) geom));
}
if (geom instanceof LineString) {
this.updateLocationInfo(this.locate(p, (LineString) geom));
} else if (geom instanceof Polygon) {
this.updateLocationInfo(this.locate(p, (Polygon) geom));
} else if (geom instanceof MultiLineString) {
MultiLineString ml = (MultiLineString) geom;
for (int i = 0; i < ml.getNumGeometries(); i++) {
LineString l = (LineString) ml.getGeometryN(i);
this.updateLocationInfo(this.locate(p, l));
}
} else if (geom instanceof MultiPolygon) {
MultiPolygon mpoly = (MultiPolygon) geom;
for (int i = 0; i < mpoly.getNumGeometries(); i++) {
Polygon poly = (Polygon) mpoly.getGeometryN(i);
this.updateLocationInfo(this.locate(p, poly));
}
} else if (geom instanceof GeometryCollection) {
Iterator geomi = new GeometryCollectionIterator(geom);
while (geomi.hasNext()) {
Geometry g2 = (Geometry) geomi.next();
if (g2 != geom) {
this.computeLocation(p, g2);
}
}
}
}
示例6: toDoc
import com.vividsolutions.jts.geom.MultiLineString; //导入方法依赖的package包/类
@Override
public ODocument toDoc(JtsGeometry shape) {
final MultiLineString geom = (MultiLineString) shape.getGeom();
List<List<List<Double>>> coordinates = new ArrayList<List<List<Double>>>();
ODocument doc = new ODocument(getName());
for (int i = 0; i < geom.getNumGeometries(); i++) {
final LineString lineString = (LineString) geom.getGeometryN(i);
coordinates.add(coordinatesFromLineString(lineString));
}
doc.field(COORDINATES, coordinates);
return doc;
}
示例7: process
import com.vividsolutions.jts.geom.MultiLineString; //导入方法依赖的package包/类
/** */
public MultiLineString process (LineString line) {
GeometryFactory factory = line.getFactory();
MultiLineString mls = ProjectionUtils.wrap(line, _lambda0);
List<LineString> result = new ArrayList<LineString>(mls.getNumGeometries());
for (int i = 0; i < mls.getNumGeometries(); i += 1) {
MultiLineString clippedLine = super.process((LineString)mls.getGeometryN(i));
for (int j = 0; j < clippedLine.getNumGeometries(); j += 1) {
result.add((LineString)clippedLine.getGeometryN(j));
}
}
return factory.createMultiLineString(result.toArray(new LineString[result.size()]));
}
示例8: putESRIPolyLineRecord
import com.vividsolutions.jts.geom.MultiLineString; //导入方法依赖的package包/类
/** */
public int putESRIPolyLineRecord (int offset, MultiLineString shape, int index) {
int bytesWritten = 0;
setByteOrder(ByteOrder.BIG_ENDIAN);
bytesWritten += putInt(offset + bytesWritten, index);
int segmentCount = shape.getNumGeometries();
int pointCount = shape.getNumPoints();
int recordLength = 22 + (segmentCount * 2) + (pointCount * 8);
ensureCapacity((recordLength * 2) + 8);
bytesWritten += putInt(offset + bytesWritten, recordLength);
setByteOrder(ByteOrder.LITTLE_ENDIAN);
bytesWritten += putInt(offset + bytesWritten, SHAPE_TYPE_POLYLINE);
bytesWritten += putBoundingBox(offset + bytesWritten, shape.getEnvelopeInternal());
bytesWritten += putInt(offset + bytesWritten, segmentCount);
bytesWritten += putInt(offset + bytesWritten, pointCount);
int segmentOffset = 0;
for (int i = 0; i < segmentCount; i += 1) {
bytesWritten += putInt(offset + bytesWritten, segmentOffset);
segmentOffset += shape.getGeometryN(i).getNumPoints();
}
for (int i = 0; i < segmentCount; i += 1) {
LineString ls = (LineString)shape.getGeometryN(i);
for (int j = 0; j < ls.getNumPoints(); j += 1) {
Point pt = ls.getPointN(j);
bytesWritten += putDouble(offset + bytesWritten, _converter.convert(pt.getX()));
bytesWritten += putDouble(offset + bytesWritten, _converter.convert(pt.getY()));
}
}
return bytesWritten;
}
示例9: checkSupFormIntersection
import com.vividsolutions.jts.geom.MultiLineString; //导入方法依赖的package包/类
private LineString checkSupFormIntersection( Point centerPoint, Coordinate origC, LineString newOneSideSegment ) {
if (preparedSupFormGeom.intersects(newOneSideSegment) && !preparedSupFormGeom.covers(newOneSideSegment)) {
Geometry intersection1 = preparedSupFormGeom.getGeometry().intersection(newOneSideSegment);
if (intersection1 instanceof LineString) {
newOneSideSegment = (LineString) intersection1;
} else if (intersection1 instanceof MultiLineString) {
newOneSideSegment = null;
MultiLineString multiLineIntersected = (MultiLineString) intersection1;
double minDistance = Double.POSITIVE_INFINITY;
for( int i = 0; i < multiLineIntersected.getNumGeometries(); i++ ) {
LineString tmpLine = (LineString) multiLineIntersected.getGeometryN(i);
double distance = DistanceOp.distance(tmpLine, centerPoint);
if (distance < minDistance) {
minDistance = distance;
newOneSideSegment = tmpLine;
}
}
if (newOneSideSegment == null) {
throw new RuntimeException();
}
} else {
throw new RuntimeException("Geometry found: " + intersection1);
}
}
Point checkPoint = newOneSideSegment.getStartPoint();
if (centerPoint.equals(checkPoint)) {
// need to check since we are not sure about the order after intersection
checkPoint = newOneSideSegment.getEndPoint();
}
if (centerPoint.distance(checkPoint) < centerPoint.getCoordinate().distance(origC)) {
// the new line segment is smaller, that is not allowed
newOneSideSegment = gf.createLineString(new Coordinate[]{centerPoint.getCoordinate(), origC});
}
return newOneSideSegment;
}
示例10: createLineFigure
import com.vividsolutions.jts.geom.MultiLineString; //导入方法依赖的package包/类
@Override
public ShapeFigure createLineFigure(Shape shape, FigureStyle style) {
MultiLineString multiLineString = toJtsGeom.createMultiLineString(shape);
Geometry geometry = multiLineString;
if (multiLineString.getNumGeometries() == 1) {
geometry = multiLineString.getGeometryN(0);
}
final Geometry geometryInSceneCoords;
try {
geometryInSceneCoords = sceneTransformProvider.getModelToSceneTransform().transform(geometry);
} catch (TransformException e) {
return null;
}
return createShapeFigure(geometryInSceneCoords, style);
}
示例11: toShape
import com.vividsolutions.jts.geom.MultiLineString; //导入方法依赖的package包/类
private PathShape toShape( MultiLineString mls ) {
Path path = new Path();
for( int i = 0; i < mls.getNumGeometries(); i++ ) {
LineString lineString = (LineString) mls.getGeometryN(i);
PathShape shape = toShape(lineString);
path.addPath(shape.getPath());
}
return new PathShape(path);
}
示例12: makeProtoRoute
import com.vividsolutions.jts.geom.MultiLineString; //导入方法依赖的package包/类
public ProtoRoute makeProtoRoute(ExtendedFeature exft, Double speed) throws Exception {
GeometryAttribute geomAttr = exft.feat.getDefaultGeometryProperty();
MultiLineString geom = (MultiLineString) geomAttr.getValue();
if (FAIL_ON_MULTILINESTRING && geom.getNumGeometries() > 1) {
throw new Exception("Features may only contain a single linestring.");
}
double spacing = Config.getSpacing(exft, this.data);
LineString ls = (LineString) geom.getGeometryN(0);
ProtoRoute ret = this.makeProtoRouteStopsFromLinestring(ls, spacing);
ret.speed = speed;
return ret;
}
示例13: makeProtoRoute
import com.vividsolutions.jts.geom.MultiLineString; //导入方法依赖的package包/类
@Override
public ProtoRoute makeProtoRoute(ExtendedFeature exft, Double speed) throws Exception {
GeometryAttribute geomAttr = exft.feat.getDefaultGeometryProperty();
MultiLineString geom = (MultiLineString) geomAttr.getValue();
if (FAIL_ON_MULTILINESTRING && geom.getNumGeometries() > 1) {
throw new Exception("Features may only contain a single linestring.");
}
LineString ls = (LineString) geom.getGeometryN(0);
ProtoRoute ret = this.makeProtoRouteStopsFromLinestring(ls);
ret.speed = speed;
return ret;
}
示例14: toShape
import com.vividsolutions.jts.geom.MultiLineString; //导入方法依赖的package包/类
private GeneralPath toShape(MultiLineString mls)
{
GeneralPath path = new GeneralPath();
for (int i = 0; i < mls.getNumGeometries(); i++) {
LineString lineString = (LineString) mls.getGeometryN(i);
path.append(toShape(lineString), false);
}
//BasicFeatureRenderer expects LineStrings and MultiLineStrings to be
//converted to GeneralPaths. [Jon Aquino]
return path;
}
示例15: geom
import com.vividsolutions.jts.geom.MultiLineString; //导入方法依赖的package包/类
private static LineString geom(Feature feature) {
MultiLineString multiLine = feature.getMultiLineString();
checkArgument(multiLine.getNumGeometries() == 1, "Tomtom road multiline should contain only line");
return (LineString) multiLine.getGeometryN(0);
}