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


Java GeometryFactory.createLineString方法代碼示例

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


在下文中一共展示了GeometryFactory.createLineString方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getRandomGeometry

import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
/**
 * Generate a random line string under the given bounding box.
 *
 * @param geometryRand the random generator
 * @param minX Bounding box min x
 * @param maxX Bounding box max x
 * @param minY Bounding box min y
 * @param maxY Bounding box max y
 * @param maxLength LineString maximum length
 * @return A segment within this bounding box
 */
static Geometry getRandomGeometry(Random geometryRand,
        double minX, double maxX,
        double minY, double maxY, double maxLength) {
    GeometryFactory factory = new GeometryFactory();
    // Create the start point
    Coordinate start = new Coordinate(
            geometryRand.nextDouble() * (maxX - minX) + minX,
            geometryRand.nextDouble() * (maxY - minY) + minY);
    // Compute an angle
    double angle = geometryRand.nextDouble() * Math.PI * 2;
    // Compute length
    double length = geometryRand.nextDouble() * maxLength;
    // Compute end point
    Coordinate end = new Coordinate(
            start.x + Math.cos(angle) * length,
            start.y + Math.sin(angle) * length);
    return factory.createLineString(new Coordinate[] { start, end });
}
 
開發者ID:vdr007,項目名稱:ThriftyPaxos,代碼行數:30,代碼來源:TestSpatial.java

示例2: edit

import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
@Override
public final Geometry edit(Geometry geometry, GeometryFactory factory) {
    if (geometry instanceof LinearRing) {
        return factory.createLinearRing(this.edit(geometry.getCoordinates(),
                geometry));
    }

    if (geometry instanceof LineString) {
        return factory.createLineString(this.edit(geometry.getCoordinates(),
                geometry));
    }

    if (geometry instanceof Point) {
        Coordinate[] newCoordinates = this.edit(geometry.getCoordinates(),
                geometry);

        return factory.createPoint((newCoordinates.length > 0)
                ? newCoordinates[0] : null);
    }

    return geometry;
}
 
開發者ID:gegy1000,項目名稱:Earth,代碼行數:23,代碼來源:GeometryEditor.java

示例3: makeLineStringGeometry

import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
/**
 * makeFakeGeometry
 * Returns a lineString at the offset provided
 * @param xOffset
 * @param yOffset
 * @param length length of the line
 * @return A LineString geometry from xOffset, yOffset to xOffset + length, yOffset + length
 */
public static Geometry makeLineStringGeometry(Double xOffset, Double yOffset, Double length) {
    GeometryFactory geometryFactory = new GeometryFactory();
    Coordinate[] coordinates = {new Coordinate(xOffset, yOffset),
            new Coordinate(xOffset + length, yOffset)};
    Geometry lineString =  geometryFactory.createLineString(coordinates);
    lineString.setSRID(Subject.SRID);
    return lineString;
}
 
開發者ID:FutureCitiesCatapult,項目名稱:TomboloDigitalConnector,代碼行數:17,代碼來源:TestFactory.java

示例4: convertSegStrings

import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
private static Geometry convertSegStrings(Iterator it) {
    GeometryFactory fact = new GeometryFactory();
    List lines = new ArrayList();
    while (it.hasNext()) {
        SegmentString ss = (SegmentString) it.next();
        LineString line = fact.createLineString(ss.getCoordinates());
        lines.add(line);
    }
    return fact.buildGeometry(lines);
}
 
開發者ID:gegy1000,項目名稱:Earth,代碼行數:11,代碼來源:BufferBuilder.java

示例5: getEdges

import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
/**
 * Gets the geometry for the edges in the subdivision as a {@link MultiLineString}
 * containing 2-point lines.
 *
 * @param geomFact the GeometryFactory to use
 * @return a MultiLineString
 */
public Geometry getEdges(GeometryFactory geomFact) {
    List quadEdges = this.getPrimaryEdges(false);
    LineString[] edges = new LineString[quadEdges.size()];
    int i = 0;
    for (Object quadEdge : quadEdges) {
        QuadEdge qe = (QuadEdge) quadEdge;
        edges[i++] = geomFact.createLineString(new Coordinate[] {
                qe.orig().getCoordinate(), qe.dest().getCoordinate() });
    }
    return geomFact.createMultiLineString(edges);
}
 
開發者ID:gegy1000,項目名稱:Earth,代碼行數:19,代碼來源:QuadEdgeSubdivision.java

示例6: getLine

import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
@Override
public LineString getLine() {
    if (line == null) {
        //CHECKSTYLE:OFF
        double[][] rawLocations = new double[][] { { -123.167725, 48.502048 },
                { -123.464355, 48.297812 }, { -124.738770, 48.603858 },
                { -125.189209, 48.828566 }, { -125.112305, 48.951366 },
                { -125.507812, 48.929718 }, { -125.870361, 49.145784 },
                { -126.035156, 49.167339 }, { -126.112061, 49.253465 },
                { -126.243896, 49.282140 }, { -126.287842, 49.360912 },
                { -126.397705, 49.410973 }, { -126.573486, 49.375220 },
                { -126.584473, 49.560852 }, { -126.815186, 49.610710 },
                { -127.012939, 49.745781 }, { -126.947021, 49.788357 },
                { -127.166748, 49.852152 }, { -127.518311, 50.113533 },
                { -127.814941, 50.078295 }, { -127.957764, 50.120578 },
                { -127.825928, 50.254230 }, { -128.012695, 50.331436 },
                { -127.946777, 50.450509 }, { -128.122559, 50.457504 },
                { -128.364258, 50.652943 }, { -128.342285, 50.792047 },
                { -128.100586, 50.882243 }, { -127.858887, 50.944584 },
                { -127.518311, 50.798991 }, { -127.221680, 50.639010 } };
                //CHECKSTYLE:ON
        GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory();

        Coordinate[] coords = new Coordinate[rawLocations.length];
        int index = 0;
        for (double[] point : rawLocations) {
            Coordinate c = new Coordinate(point[0], point[1]);

            coords[index] = c;

            index++;
        }

        line = geometryFactory.createLineString(coords);
    }
    return line;
}
 
開發者ID:robward-scisys,項目名稱:sldeditor,代碼行數:38,代碼來源:ExampleLineImpl.java

示例7: createEmptyResult

import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
/**
 * Creates an empty result geometry of the appropriate dimension,
 * based on the dimensions of the inputs.
 * The created geometry is always an atomic geometry,
 * not a collection.
 * <p>
 * Implements the following rules:
 * <ul>
 * <li><code>intersection</code> - result has the dimension of the lowest input dimension
 * <li><code>union</code> - result has the dimension of the highest input dimension
 * <li><code>difference</code> - result has the dimension of the left-hand input
 * <li><code>symDifference</code> - result has the dimension of the highest input dimension
 * (since symDifference is the union of the differences).
 * <li>
 *
 * @param opCode the overlay operation being performed
 * @param a an input geometry
 * @param b an input geometry
 * @param geomFact the geometry factory being used for the operation
 * @return an empty atomic geometry of the appropriate dimension
 */
public static Geometry createEmptyResult(int opCode, Geometry a, Geometry b, GeometryFactory geomFact) {
    Geometry result = null;
    switch (resultDimension(opCode, a, b)) {
        case -1:
            result = geomFact.createGeometryCollection(new Geometry[0]);
            break;
        case 0:
            result = geomFact.createPoint((Coordinate) null);
            break;
        case 1:
            result = geomFact.createLineString((Coordinate[]) null);
            break;
        case 2:
            result = geomFact.createPolygon(null, null);
            break;
    }
    return result;
}
 
開發者ID:gegy1000,項目名稱:Earth,代碼行數:40,代碼來源:OverlayOp.java

示例8: toString

import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
public String toString() {
    GeometryFactory fact = new GeometryFactory();
    LineString line = fact.createLineString(this.getCoordinates());
    return line.toString();
}
 
開發者ID:gegy1000,項目名稱:Earth,代碼行數:6,代碼來源:OffsetSegmentString.java

示例9: toLineString

import com.vividsolutions.jts.geom.GeometryFactory; //導入方法依賴的package包/類
public static LineString toLineString(GeometryFactory factory,
    ILineString line) {
  return factory.createLineString(AdapterFactory.toCoordinateSequence(
      factory, line.coord()));
}
 
開發者ID:IGNF,項目名稱:geoxygene,代碼行數:6,代碼來源:AdapterFactory.java


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