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


Java MultiLineString.getGeometryN方法代码示例

本文整理汇总了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);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:24,代码来源:BoundaryOp.java

示例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);
}
 
开发者ID:scaleset,项目名称:scaleset-geo,代码行数:24,代码来源:GeoJsonModuleTest.java

示例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;
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:50,代码来源:LineSequencer.java

示例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;
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:10,代码来源:ShapeWriter.java

示例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);
            }
        }
    }
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:31,代码来源:PointLocator.java

示例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;
}
 
开发者ID:orientechnologies,项目名称:orientdb-spatial,代码行数:15,代码来源:OMultiLineStringShapeBuilder.java

示例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()]));
}
 
开发者ID:reuven,项目名称:modelingcommons,代码行数:14,代码来源:Conic.java

示例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;
}
 
开发者ID:reuven,项目名称:modelingcommons,代码行数:31,代码来源:ESRIShapeBuffer.java

示例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;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:38,代码来源:OmsLW08_NetworkBufferWidthCalculator.java

示例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);
}
 
开发者ID:senbox-org,项目名称:snap-desktop,代码行数:16,代码来源:SimpleFeatureFigureFactory.java

示例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);
}
 
开发者ID:GitHubDroid,项目名称:geodroid_master_update,代码行数:11,代码来源:ShapeWriter.java

示例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;
}
 
开发者ID:conveyal,项目名称:geom2gtfs,代码行数:16,代码来源:PicketStopGenerator.java

示例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;
}
 
开发者ID:conveyal,项目名称:geom2gtfs,代码行数:16,代码来源:ShapefileStopGenerator.java

示例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;
}
 
开发者ID:dr-jts,项目名称:jeql,代码行数:14,代码来源:Java2DConverter.java

示例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);
}
 
开发者ID:Mappy,项目名称:fpm,代码行数:6,代码来源:RoadShapefile.java


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