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


Java CoordinateArrays类代码示例

本文整理汇总了Java中com.vividsolutions.jts.geom.CoordinateArrays的典型用法代码示例。如果您正苦于以下问题:Java CoordinateArrays类的具体用法?Java CoordinateArrays怎么用?Java CoordinateArrays使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CoordinateArrays类属于com.vividsolutions.jts.geom包,在下文中一共展示了CoordinateArrays类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addEdge

import com.vividsolutions.jts.geom.CoordinateArrays; //导入依赖的package包/类
/**
 * Add a {@link LineString} forming an edge of the polygon graph.
 *
 * @param line the line to add
 */
public void addEdge(LineString line) {
    if (line.isEmpty()) {
        return;
    }
    Coordinate[] linePts = CoordinateArrays.removeRepeatedPoints(line.getCoordinates());

    if (linePts.length < 2) {
        return;
    }

    Coordinate startPt = linePts[0];
    Coordinate endPt = linePts[linePts.length - 1];

    Node nStart = this.getNode(startPt);
    Node nEnd = this.getNode(endPt);

    DirectedEdge de0 = new PolygonizeDirectedEdge(nStart, nEnd, linePts[1], true);
    DirectedEdge de1 = new PolygonizeDirectedEdge(nEnd, nStart, linePts[linePts.length - 2], false);
    Edge edge = new PolygonizeEdge(line);
    edge.setDirectedEdges(de0, de1);
    this.add(edge);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:28,代码来源:PolygonizeGraph.java

示例2: getCoordinates

import com.vividsolutions.jts.geom.CoordinateArrays; //导入依赖的package包/类
private Coordinate[] getCoordinates() {
    if (this.coordinates == null) {
        int forwardDirectedEdges = 0;
        int reverseDirectedEdges = 0;
        CoordinateList coordinateList = new CoordinateList();
        for (Object directedEdge1 : directedEdges) {
            LineMergeDirectedEdge directedEdge = (LineMergeDirectedEdge) directedEdge1;
            if (directedEdge.getEdgeDirection()) {
                forwardDirectedEdges++;
            } else {
                reverseDirectedEdges++;
            }
            coordinateList.add(((LineMergeEdge) directedEdge.getEdge()).getLine()
                            .getCoordinates(), false,
                    directedEdge.getEdgeDirection());
        }
        this.coordinates = coordinateList.toCoordinateArray();
        if (reverseDirectedEdges > forwardDirectedEdges) {
            CoordinateArrays.reverse(this.coordinates);
        }
    }

    return this.coordinates;
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:25,代码来源:EdgeString.java

示例3: addEdge

import com.vividsolutions.jts.geom.CoordinateArrays; //导入依赖的package包/类
/**
 * Adds an Edge, DirectedEdges, and Nodes for the given LineString representation
 * of an edge.
 * Empty lines or lines with all coordinates equal are not added.
 *
 * @param lineString the linestring to add to the graph
 */
public void addEdge(LineString lineString) {
    if (lineString.isEmpty()) {
        return;
    }

    Coordinate[] coordinates = CoordinateArrays.removeRepeatedPoints(lineString.getCoordinates());

    // don't add lines with all coordinates equal
    if (coordinates.length <= 1) {
        return;
    }

    Coordinate startCoordinate = coordinates[0];
    Coordinate endCoordinate = coordinates[coordinates.length - 1];
    Node startNode = this.getNode(startCoordinate);
    Node endNode = this.getNode(endCoordinate);
    DirectedEdge directedEdge0 = new LineMergeDirectedEdge(startNode, endNode,
            coordinates[1], true);
    DirectedEdge directedEdge1 = new LineMergeDirectedEdge(endNode, startNode,
            coordinates[coordinates.length - 2], false);
    Edge edge = new LineMergeEdge(lineString);
    edge.setDirectedEdges(directedEdge0, directedEdge1);
    this.add(edge);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:32,代码来源:LineMergeGraph.java

示例4: getOffsetCurve

import com.vividsolutions.jts.geom.CoordinateArrays; //导入依赖的package包/类
public Coordinate[] getOffsetCurve(Coordinate[] inputPts, double distance) {
    this.distance = distance;

    // a zero width offset curve is empty
    if (distance == 0.0) {
        return null;
    }

    boolean isRightSide = distance < 0.0;
    double posDistance = Math.abs(distance);
    OffsetSegmentGenerator segGen = this.getSegGen(posDistance);
    if (inputPts.length <= 1) {
        this.computePointCurve(inputPts[0], segGen);
    } else {
        this.computeOffsetCurve(inputPts, isRightSide, segGen);
    }
    Coordinate[] curvePts = segGen.getCoordinates();
    // for right side line is traversed in reverse direction, so have to reverse generated line
    if (isRightSide) {
        CoordinateArrays.reverse(curvePts);
    }
    return curvePts;
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:24,代码来源:OffsetCurveBuilder.java

示例5: computeBoundaryCoordinates

import com.vividsolutions.jts.geom.CoordinateArrays; //导入依赖的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

示例6: addLineString

import com.vividsolutions.jts.geom.CoordinateArrays; //导入依赖的package包/类
private void addLineString(LineString line) {
    Coordinate[] coord = CoordinateArrays.removeRepeatedPoints(line.getCoordinates());

    if (coord.length < 2) {
        this.hasTooFewPoints = true;
        this.invalidPoint = coord[0];
        return;
    }

    // add the edge for the LineString
    // line edges do not have locations for their left and right sides
    Edge e = new Edge(coord, new Label(this.argIndex, Location.INTERIOR));
    this.lineEdgeMap.put(line, e);
    this.insertEdge(e);
    /**
     * Add the boundary points of the LineString, if any.
     * Even if the LineString is closed, add both points as if they were endpoints.
     * This allows for the case that the node already exists and is a boundary point.
     */
    Assert.isTrue(coord.length >= 2, "found LineString with single point");
    this.insertBoundaryPoint(this.argIndex, coord[0]);
    this.insertBoundaryPoint(this.argIndex, coord[coord.length - 1]);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:24,代码来源:GeometryGraph.java

示例7: addEdge

import com.vividsolutions.jts.geom.CoordinateArrays; //导入依赖的package包/类
/**
 * Add a {@link LineString} forming an edge of the polygon graph.
 *
 * @param line the line to add
 */
public void addEdge(LineString line) {
    if (line.isEmpty()) {
        return;
    }
    Coordinate[] linePts = CoordinateArrays.removeRepeatedPoints(line.getCoordinates());

    if (linePts.length < 2) {
        return;
    }

    Coordinate startPt = linePts[0];
    Coordinate endPt = linePts[linePts.length - 1];

    Node nStart = getNode(startPt);
    Node nEnd = getNode(endPt);

    DirectedEdge de0 = new PolygonizeDirectedEdge(nStart, nEnd, linePts[1], true);
    DirectedEdge de1 = new PolygonizeDirectedEdge(nEnd, nStart, linePts[linePts.length - 2], false);
    Edge edge = new PolygonizeEdge(line);
    edge.setDirectedEdges(de0, de1);
    add(edge);
}
 
开发者ID:Semantive,项目名称:jts,代码行数:28,代码来源:PolygonizeGraph.java

示例8: addEdge

import com.vividsolutions.jts.geom.CoordinateArrays; //导入依赖的package包/类
/**
 * Adds an Edge, DirectedEdges, and Nodes for the given LineString representation
 * of an edge.
 * Empty lines or lines with all coordinates equal are not added.
 *
 * @param lineString the linestring to add to the graph
 */
public void addEdge(LineString lineString) {
    if (lineString.isEmpty()) {
        return;
    }

    Coordinate[] coordinates = CoordinateArrays.removeRepeatedPoints(lineString.getCoordinates());

    // don't add lines with all coordinates equal
    if (coordinates.length <= 1) return;

    Coordinate startCoordinate = coordinates[0];
    Coordinate endCoordinate = coordinates[coordinates.length - 1];
    Node startNode = getNode(startCoordinate);
    Node endNode = getNode(endCoordinate);
    DirectedEdge directedEdge0 = new LineMergeDirectedEdge(startNode, endNode,
            coordinates[1], true);
    DirectedEdge directedEdge1 = new LineMergeDirectedEdge(endNode, startNode,
            coordinates[coordinates.length - 2], false);
    Edge edge = new LineMergeEdge(lineString);
    edge.setDirectedEdges(directedEdge0, directedEdge1);
    add(edge);
}
 
开发者ID:Semantive,项目名称:jts,代码行数:30,代码来源:LineMergeGraph.java

示例9: getOffsetCurve

import com.vividsolutions.jts.geom.CoordinateArrays; //导入依赖的package包/类
public Coordinate[] getOffsetCurve(Coordinate[] inputPts, double distance) {
    this.distance = distance;

    // a zero width offset curve is empty
    if (distance == 0.0) return null;

    boolean isRightSide = distance < 0.0;
    double posDistance = Math.abs(distance);
    OffsetSegmentGenerator segGen = getSegGen(posDistance);
    if (inputPts.length <= 1) {
        computePointCurve(inputPts[0], segGen);
    } else {
        computeOffsetCurve(inputPts, isRightSide, segGen);
    }
    Coordinate[] curvePts = segGen.getCoordinates();
    // for right side line is traversed in reverse direction, so have to reverse generated line
    if (isRightSide)
        CoordinateArrays.reverse(curvePts);
    return curvePts;
}
 
开发者ID:Semantive,项目名称:jts,代码行数:21,代码来源:OffsetCurveBuilder.java

示例10: addEdge

import com.vividsolutions.jts.geom.CoordinateArrays; //导入依赖的package包/类
/**
 * Adds an Edge, DirectedEdges, and Nodes for the given LineString representation
 * of an edge. 
 * Empty lines or lines with all coordinates equal are not added.
 * 
 * @param lineString the linestring to add to the graph
 */
public void addEdge(LineString lineString) {
  if (lineString.isEmpty()) { return; }
  
  Coordinate[] coordinates = CoordinateArrays.removeRepeatedPoints(lineString.getCoordinates());
  
  // don't add lines with all coordinates equal
  if (coordinates.length <= 1) return;
  
  Coordinate startCoordinate = coordinates[0];
  Coordinate endCoordinate = coordinates[coordinates.length - 1];
  Node startNode = getNode(startCoordinate);
  Node endNode = getNode(endCoordinate);
  DirectedEdge directedEdge0 = new LineMergeDirectedEdge(startNode, endNode,
      coordinates[1], true);
  DirectedEdge directedEdge1 = new LineMergeDirectedEdge(endNode, startNode,
      coordinates[coordinates.length - 2], false);
  Edge edge = new LineMergeEdge(lineString);
  edge.setDirectedEdges(directedEdge0, directedEdge1);
  add(edge);
}
 
开发者ID:GitHubDroid,项目名称:geodroid_master_update,代码行数:28,代码来源:LineMergeGraph.java

示例11: getOffsetCurve

import com.vividsolutions.jts.geom.CoordinateArrays; //导入依赖的package包/类
public Coordinate[] getOffsetCurve(Coordinate[] inputPts, double distance)
{
  this.distance = distance;
  
  // a zero width offset curve is empty
  if (distance == 0.0) return null;

  boolean isRightSide = distance < 0.0;
  double posDistance = Math.abs(distance);
  OffsetSegmentGenerator segGen = getSegGen(posDistance);
  if (inputPts.length <= 1) {
    computePointCurve(inputPts[0], segGen);
  }
  else {
    computeOffsetCurve(inputPts, isRightSide, segGen);
  }
  Coordinate[] curvePts = segGen.getCoordinates();
  // for right side line is traversed in reverse direction, so have to reverse generated line
  if (isRightSide) 
    CoordinateArrays.reverse(curvePts);
  return curvePts;
}
 
开发者ID:GitHubDroid,项目名称:geodroid_master_update,代码行数:23,代码来源:OffsetCurveBuilder.java

示例12: union

import com.vividsolutions.jts.geom.CoordinateArrays; //导入依赖的package包/类
public Geometry union() {
    PointLocator locater = new PointLocator();
    // use a set to eliminate duplicates, as required for union
    Set exteriorCoords = new TreeSet();

    for (int i = 0; i < this.pointGeom.getNumGeometries(); i++) {
        Point point = (Point) this.pointGeom.getGeometryN(i);
        Coordinate coord = point.getCoordinate();
        int loc = locater.locate(coord, this.otherGeom);
        if (loc == Location.EXTERIOR) {
            exteriorCoords.add(coord);
        }
    }

    // if no points are in exterior, return the other geom
    if (exteriorCoords.size() == 0) {
        return this.otherGeom;
    }

    // make a puntal geometry of appropriate size
    Geometry ptComp = null;
    Coordinate[] coords = CoordinateArrays.toCoordinateArray(exteriorCoords);
    if (coords.length == 1) {
        ptComp = this.geomFact.createPoint(coords[0]);
    } else {
        ptComp = this.geomFact.createMultiPoint(coords);
    }

    // add point component to the other geometry
    return GeometryCombiner.combine(ptComp, this.otherGeom);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:32,代码来源:PointGeometryUnion.java

示例13: findEdgeRingContaining

import com.vividsolutions.jts.geom.CoordinateArrays; //导入依赖的package包/类
/**
 * Find the innermost enclosing shell EdgeRing containing the argument EdgeRing, if any.
 * The innermost enclosing ring is the <i>smallest</i> enclosing ring.
 * The algorithm used depends on the fact that:
 * <br>
 * ring A contains ring B iff envelope(ring A) contains envelope(ring B)
 * <br>
 * This routine is only safe to use if the chosen point of the hole
 * is known to be properly contained in a shell
 * (which is guaranteed to be the case if the hole does not touch its shell)
 *
 * @return containing EdgeRing, if there is one
 * or null if no containing EdgeRing is found
 */
public static EdgeRing findEdgeRingContaining(EdgeRing testEr, List shellList) {
    LinearRing testRing = testEr.getRing();
    Envelope testEnv = testRing.getEnvelopeInternal();
    Coordinate testPt = testRing.getCoordinateN(0);

    EdgeRing minShell = null;
    Envelope minShellEnv = null;
    for (Object aShellList : shellList) {
        EdgeRing tryShell = (EdgeRing) aShellList;
        LinearRing tryShellRing = tryShell.getRing();
        Envelope tryShellEnv = tryShellRing.getEnvelopeInternal();
        // the hole envelope cannot equal the shell envelope
        // (also guards against testing rings against themselves)
        if (tryShellEnv.equals(testEnv)) {
            continue;
        }
        // hole must be contained in shell
        if (!tryShellEnv.contains(testEnv)) {
            continue;
        }

        testPt = CoordinateArrays.ptNotInList(testRing.getCoordinates(), tryShellRing.getCoordinates());
        boolean isContained = false;
        if (CGAlgorithms.isPointInRing(testPt, tryShellRing.getCoordinates())) {
            isContained = true;
        }

        // check if this new containing ring is smaller than the current minimum ring
        if (isContained) {
            if (minShell == null
                    || minShellEnv.contains(tryShellEnv)) {
                minShell = tryShell;
                minShellEnv = minShell.getRing().getEnvelopeInternal();
            }
        }
    }
    return minShell;
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:53,代码来源:EdgeRing.java

示例14: addLineString

import com.vividsolutions.jts.geom.CoordinateArrays; //导入依赖的package包/类
private void addLineString(LineString line) {
    // a zero or negative width buffer of a line/point is empty
    if (this.distance <= 0.0 && !this.curveBuilder.getBufferParameters().isSingleSided()) {
        return;
    }
    Coordinate[] coord = CoordinateArrays.removeRepeatedPoints(line.getCoordinates());
    Coordinate[] curve = this.curveBuilder.getLineCurve(coord, this.distance);
    this.addCurve(curve, Location.EXTERIOR, Location.INTERIOR);

    // TESTING
    //Coordinate[] curveTrim = BufferCurveLoopPruner.prune(curve);
    //addCurve(curveTrim, Location.EXTERIOR, Location.INTERIOR);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:14,代码来源:OffsetCurveSetBuilder.java

示例15: buildIndex

import com.vividsolutions.jts.geom.CoordinateArrays; //导入依赖的package包/类
private void buildIndex() {
    //Envelope env = ring.getEnvelopeInternal();
    this.tree = new Bintree();

    Coordinate[] pts = CoordinateArrays.removeRepeatedPoints(this.ring.getCoordinates());
    List mcList = MonotoneChainBuilder.getChains(pts);

    for (Object aMcList : mcList) {
        MonotoneChain mc = (MonotoneChain) aMcList;
        Envelope mcEnv = mc.getEnvelope();
        this.interval.min = mcEnv.getMinY();
        this.interval.max = mcEnv.getMaxY();
        this.tree.insert(this.interval, mc);
    }
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:16,代码来源:MCPointInRing.java


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