當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。