當前位置: 首頁>>代碼示例>>Java>>正文


Java MultiLineString.getNumGeometries方法代碼示例

本文整理匯總了Java中com.vividsolutions.jts.geom.MultiLineString.getNumGeometries方法的典型用法代碼示例。如果您正苦於以下問題:Java MultiLineString.getNumGeometries方法的具體用法?Java MultiLineString.getNumGeometries怎麽用?Java MultiLineString.getNumGeometries使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.vividsolutions.jts.geom.MultiLineString的用法示例。


在下文中一共展示了MultiLineString.getNumGeometries方法的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: writeMultiLineString

import com.vividsolutions.jts.geom.MultiLineString; //導入方法依賴的package包/類
private void writeMultiLineString(MultiLineString mls, Writer writer,
                                  int level) throws IOException {
    this.startLine(level, writer);
    this.startGeomTag(GMLConstants.GML_MULTI_LINESTRING, mls, writer);

    for (int t = 0; t < mls.getNumGeometries(); t++) {
        this.startLine(level + 1, writer);
        this.startGeomTag(GMLConstants.GML_LINESTRING_MEMBER, null, writer);

        this.writeLineString((LineString) mls.getGeometryN(t), writer, level + 2);

        this.startLine(level + 1, writer);
        this.endGeomTag(GMLConstants.GML_LINESTRING_MEMBER, writer);
    }
    this.startLine(level, writer);
    this.endGeomTag(GMLConstants.GML_MULTI_LINESTRING, writer);
}
 
開發者ID:gegy1000,項目名稱:Earth,代碼行數:18,代碼來源:GMLWriter.java

示例3: appendMultiLineStringText

import com.vividsolutions.jts.geom.MultiLineString; //導入方法依賴的package包/類
/**
 * Converts a <code>MultiLineString</code> to &lt;MultiLineString Text&gt;
 * format, then appends it to the writer.
 *
 * @param multiLineString the <code>MultiLineString</code> to process
 * @param writer the output writer to append to
 */
private void appendMultiLineStringText(MultiLineString multiLineString, int level, boolean indentFirst,
                                       Writer writer)
        throws IOException {
    if (multiLineString.isEmpty()) {
        writer.write("EMPTY");
    } else {
        int level2 = level;
        boolean doIndent = indentFirst;
        writer.write("(");
        for (int i = 0; i < multiLineString.getNumGeometries(); i++) {
            if (i > 0) {
                writer.write(", ");
                level2 = level + 1;
                doIndent = true;
            }
            this.appendLineStringText((LineString) multiLineString.getGeometryN(i), level2, doIndent, writer);
        }
        writer.write(")");
    }
}
 
開發者ID:gegy1000,項目名稱:Earth,代碼行數:28,代碼來源:WKTWriter.java

示例4: getGeoMultiPolygon

import com.vividsolutions.jts.geom.MultiLineString; //導入方法依賴的package包/類
/**
 * Return a MultiPolygon object that corresponds to the given Geometry
 * object.
 * 
 * For a point, we'll return a triangle centered around the point. For a
 * LineString or MultiLineString, we'll return a MultiPolygon created by
 * tracing the outline(s) of the LineString/MultiLineString. For a
 * Polygon, we'll return a MultiPolygon that contains only that polygon For
 * a MultiPolygon, we'll just return it
 * 
 * @param g
 * @return
 */
public MultiPolygon getGeoMultiPolygon(Geometry g) {
	MultiPolygon geoMultiPolygon = null;

	if (g instanceof Point) {
		Coordinate[] points = this.createTriangle(g.getCoordinate());
		geoMultiPolygon = new MultiPolygon(new Polygon[] { this.createPolygon(points, g.getFactory()) }, g.getFactory());
	} else if (g instanceof MultiPolygon) {
		geoMultiPolygon = (MultiPolygon) g;
	} else if (g instanceof Polygon) {
		geoMultiPolygon = new MultiPolygon(new Polygon[] { (Polygon) g }, g.getFactory());
	} else if (g instanceof LineString) {
		geoMultiPolygon = new MultiPolygon(new Polygon[] { this.createPolygon((LineString) g) }, g.getFactory());
	} else if (g instanceof MultiLineString) {
		MultiLineString mls = (MultiLineString) g;
		Polygon[] polygons = new Polygon[mls.getNumGeometries()];
		for (int n = 0; n < mls.getNumGeometries(); n++) {
			polygons[n] = this.createPolygon((LineString) mls.getGeometryN(n));
		}
		geoMultiPolygon = new MultiPolygon(polygons, g.getFactory());
	}
	return geoMultiPolygon;
}
 
開發者ID:terraframe,項目名稱:Runway-SDK,代碼行數:36,代碼來源:GeometryHelper.java

示例5: 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

示例6: 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

示例7: 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

示例8: transformMultiLineString

import com.vividsolutions.jts.geom.MultiLineString; //導入方法依賴的package包/類
protected Geometry transformMultiLineString(MultiLineString geom, Geometry parent) {
    List transGeomList = new ArrayList();
    for (int i = 0; i < geom.getNumGeometries(); i++) {
        Geometry transformGeom = this.transformLineString((LineString) geom.getGeometryN(i), geom);
        if (transformGeom == null) {
            continue;
        }
        if (transformGeom.isEmpty()) {
            continue;
        }
        transGeomList.add(transformGeom);
    }
    return this.factory.buildGeometry(transGeomList);
}
 
開發者ID:gegy1000,項目名稱:Earth,代碼行數:15,代碼來源:GeometryTransformer.java

示例9: fromMultiLineString

import com.vividsolutions.jts.geom.MultiLineString; //導入方法依賴的package包/類
/**
 * 轉換jts多線對象到geojson多線對象
 */
private List<List<double[]>> fromMultiLineString(MultiLineString multiLineString) {
  int size = multiLineString.getNumGeometries();
  List<List<double[]>> list = new ArrayList<List<double[]>>(size);
  for (int i = 0; i < size; i++) {
    list.add(toCoordinates(multiLineString.getGeometryN(i).getCoordinates()));
  }
  return list;
}
 
開發者ID:geomgis,項目名稱:geogson,代碼行數:12,代碼來源:GeometryAdapter.java

示例10: 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

示例11: writeMultiLineString

import com.vividsolutions.jts.geom.MultiLineString; //導入方法依賴的package包/類
private void writeMultiLineString(JsonGenerator jgen, MultiLineString value)
		throws JsonGenerationException, IOException {
	jgen.writeStartObject();
	jgen.writeStringField("type", "MultiLineString");
	jgen.writeArrayFieldStart("coordinates");

	for (int i = 0; i != value.getNumGeometries(); ++i) {
		writeLineStringCoords(jgen, (LineString) value.getGeometryN(i));
	}

	jgen.writeEndArray();
	jgen.writeEndObject();
}
 
開發者ID:conveyal,項目名稱:lodes-processor,代碼行數:14,代碼來源:GeometrySerializer.java

示例12: 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

示例13: transformMultiLineString

import com.vividsolutions.jts.geom.MultiLineString; //導入方法依賴的package包/類
protected Geometry transformMultiLineString(MultiLineString geom, Geometry parent) {
    List<LineString> lines = new ArrayList<LineString>();
    for (int i = 0; i < geom.getNumGeometries(); i += 1) {
        MultiLineString mls = _proj.process((LineString)geom.getGeometryN(i));
        mls.apply(_filter);
        mls.geometryChanged();
        for (int j = 0; j < mls.getNumGeometries(); j += 1) {
            lines.add((LineString)mls.getGeometryN(j));
        }
    }
    return factory.createMultiLineString(GeometryFactory.toLineStringArray(lines));
}
 
開發者ID:reuven,項目名稱:modelingcommons,代碼行數:13,代碼來源:AbstractProjection.java

示例14: 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

示例15: 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


注:本文中的com.vividsolutions.jts.geom.MultiLineString.getNumGeometries方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。