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


Java CoordinateList.add方法代码示例

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


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

示例1: getCoordinates

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

示例2: densifyPoints

import com.vividsolutions.jts.geom.CoordinateList; //导入方法依赖的package包/类
/**
 * Densifies a coordinate sequence.
 *
 * @param pts
 * @param distanceTolerance
 * @return the densified coordinate sequence
 */
private static Coordinate[] densifyPoints(Coordinate[] pts,
                                          double distanceTolerance, PrecisionModel precModel) {
    LineSegment seg = new LineSegment();
    CoordinateList coordList = new CoordinateList();
    for (int i = 0; i < pts.length - 1; i++) {
        seg.p0 = pts[i];
        seg.p1 = pts[i + 1];
        coordList.add(seg.p0, false);
        double len = seg.getLength();
        int densifiedSegCount = (int) (len / distanceTolerance) + 1;
        if (densifiedSegCount > 1) {
            double densifiedSegLen = len / densifiedSegCount;
            for (int j = 1; j < densifiedSegCount; j++) {
                double segFract = (j * densifiedSegLen) / len;
                Coordinate p = seg.pointAlong(segFract);
                precModel.makePrecise(p);
                coordList.add(p, false);
            }
        }
    }
    coordList.add(pts[pts.length - 1], false);
    return coordList.toCoordinateArray();
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:31,代码来源:Densifier.java

示例3: snapSegments

import com.vividsolutions.jts.geom.CoordinateList; //导入方法依赖的package包/类
/**
 * Snap segments of the source to nearby snap vertices.
 * Source segments are "cracked" at a snap vertex.
 * A single input segment may be snapped several times
 * to different snap vertices.
 * <p/>
 * For each distinct snap vertex, at most one source segment
 * is snapped to.  This prevents "cracking" multiple segments
 * at the same point, which would likely cause
 * topology collapse when being used on polygonal linework.
 *
 * @param srcCoords the coordinates of the source linestring to be snapped
 * @param snapPts   the target snap vertices
 */
private void snapSegments(CoordinateList srcCoords, Coordinate[] snapPts) {
    // guard against empty input
    if (snapPts.length == 0) return;

    int distinctPtCount = snapPts.length;

    // check for duplicate snap pts when they are sourced from a linear ring.
    // TODO: Need to do this better - need to check *all* snap points for dups (using a Set?)
    if (snapPts[0].equals2D(snapPts[snapPts.length - 1]))
        distinctPtCount = snapPts.length - 1;

    for (int i = 0; i < distinctPtCount; i++) {
        Coordinate snapPt = snapPts[i];
        int index = findSegmentIndexToSnap(snapPt, srcCoords);
        /**
         * If a segment to snap to was found, "crack" it at the snap pt.
         * The new pt is inserted immediately into the src segment list,
         * so that subsequent snapping will take place on the modified segments.
         * Duplicate points are not added.
         */
        if (index >= 0) {
            srcCoords.add(index + 1, new Coordinate(snapPt), false);
        }
    }
}
 
开发者ID:Semantive,项目名称:jts,代码行数:40,代码来源:LineStringSnapper.java

示例4: convertDwgPolyline3D

import com.vividsolutions.jts.geom.CoordinateList; //导入方法依赖的package包/类
/**
 * Builds a line feature from a dwg polyline 3D.
 * 
 * TODO handle these as contourlines
 * 
 */
public SimpleFeature convertDwgPolyline3D( String typeName, String layerName,
        DwgPolyline3D polyline3d, int id ) {
    double[][] ptos = polyline3d.getPts();
    CoordinateList coordList = new CoordinateList();
    if (ptos != null) {
        for( int j = 0; j < ptos.length; j++ ) {
            Coordinate coord = new Coordinate(ptos[j][0], ptos[j][1], ptos[j][2]);
            coordList.add(coord);
        }

        SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
        b.setName(typeName);
        b.setCRS(crs);
        b.add(THE_GEOM, LineString.class);
        b.add(LAYER, String.class);
        SimpleFeatureType type = b.buildFeatureType();
        SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
        Geometry lineString = gF.createLineString(coordList.toCoordinateArray());
        Object[] values = new Object[]{lineString, layerName};
        builder.addAll(values);
        return builder.buildFeature(typeName + "." + id);
    }
    return null;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:31,代码来源:GeometryTranslator.java

示例5: convertDwgPolyline2D

import com.vividsolutions.jts.geom.CoordinateList; //导入方法依赖的package包/类
/**
 * Builds a line feature from a dwg polyline 2D.
 * 
 */
public SimpleFeature convertDwgPolyline2D( String typeName, String layerName,
        DwgPolyline2D polyline2d, int id ) {
    Point2D[] ptos = polyline2d.getPts();
    CoordinateList coordList = new CoordinateList();
    if (ptos != null) {
        for( int j = 0; j < ptos.length; j++ ) {
            Coordinate coord = new Coordinate(ptos[j].getX(), ptos[j].getY(), 0.0);
            coordList.add(coord);
        }

        SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
        b.setName(typeName);
        b.setCRS(crs);
        b.add(THE_GEOM, LineString.class);
        b.add(LAYER, String.class);
        SimpleFeatureType type = b.buildFeatureType();
        SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
        Geometry lineString = gF.createLineString(coordList.toCoordinateArray());
        Object[] values = new Object[]{lineString, layerName};
        builder.addAll(values);
        return builder.buildFeature(typeName + "." + id);
    }
    return null;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:29,代码来源:GeometryTranslator.java

示例6: convertDwgLwPolyline

import com.vividsolutions.jts.geom.CoordinateList; //导入方法依赖的package包/类
/**
 * Builds a line feature from a dwg polyline 2D.
 * 
 */
public SimpleFeature convertDwgLwPolyline( String typeName, String layerName,
        DwgLwPolyline lwPolyline, int id ) {
    Point2D[] ptos = lwPolyline.getVertices();
    if (ptos != null) {
        CoordinateList coordList = new CoordinateList();
        for( int j = 0; j < ptos.length; j++ ) {
            Coordinate coord = new Coordinate(ptos[j].getX(), ptos[j].getY(), 0.0);
            coordList.add(coord);
        }

        SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
        b.setName(typeName);
        b.setCRS(crs);
        b.add(THE_GEOM, LineString.class);
        b.add(LAYER, String.class);
        SimpleFeatureType type = b.buildFeatureType();
        SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
        Geometry lineString = gF.createLineString(coordList.toCoordinateArray());
        Object[] values = new Object[]{lineString, layerName};
        builder.addAll(values);
        return builder.buildFeature(typeName + "." + id);
    }
    return null;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:29,代码来源:GeometryTranslator.java

示例7: convertDwgPoint

import com.vividsolutions.jts.geom.CoordinateList; //导入方法依赖的package包/类
/**
 * Builds a point feature from a dwg point.
 */
public SimpleFeature convertDwgPoint( String typeName, String layerName, DwgPoint point, int id ) {
    double[] p = point.getPoint();
    Point2D pto = new Point2D.Double(p[0], p[1]);

    CoordinateList coordList = new CoordinateList();
    Coordinate coord = new Coordinate(pto.getX(), pto.getY(), 0.0);
    coordList.add(coord);

    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName(typeName);
    b.setCRS(crs);
    b.add(THE_GEOM, MultiPoint.class);
    b.add(LAYER, String.class);
    SimpleFeatureType type = b.buildFeatureType();
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
    Geometry points = gF.createMultiPoint(coordList.toCoordinateArray());
    Object[] values = new Object[]{points, layerName};
    builder.addAll(values);
    return builder.buildFeature(typeName + "." + id);
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:24,代码来源:GeometryTranslator.java

示例8: convertDwgLine

import com.vividsolutions.jts.geom.CoordinateList; //导入方法依赖的package包/类
/**
 * Builds a line feature from a dwg line.
 * 
 */
public SimpleFeature convertDwgLine( String typeName, String layerName, DwgLine line, int id ) {
    double[] p1 = line.getP1();
    double[] p2 = line.getP2();
    Point2D[] ptos = new Point2D[]{new Point2D.Double(p1[0], p1[1]),
            new Point2D.Double(p2[0], p2[1])};
    CoordinateList coordList = new CoordinateList();
    for( int j = 0; j < ptos.length; j++ ) {
        Coordinate coord = new Coordinate(ptos[j].getX(), ptos[j].getY(), 0.0);
        coordList.add(coord);
    }

    SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
    b.setName(typeName);
    b.setCRS(crs);
    b.add(THE_GEOM, LineString.class);
    b.add(LAYER, String.class);
    SimpleFeatureType type = b.buildFeatureType();
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type);
    Geometry lineString = gF.createLineString(coordList.toCoordinateArray());
    Object[] values = new Object[]{lineString, layerName};
    builder.addAll(values);
    return builder.buildFeature(typeName + "." + id);
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:28,代码来源:GeometryTranslator.java

示例9: readEntity

import com.vividsolutions.jts.geom.CoordinateList; //导入方法依赖的package包/类
public static DxfGroup readEntity(RandomAccessFile raf, CoordinateList coordList)
                                                        throws IOException {
    Coordinate coord;
    double x=Double.NaN, y=Double.NaN, z=Double.NaN;
    DxfGroup group;
    try {
        while (null != (group = DxfGroup.readGroup(raf)) && group.getCode()!=0) {
            if (group.getCode()==10) x = group.getDoubleValue();
            else if (group.getCode()==20) y = group.getDoubleValue();
            else if (group.getCode()==30) z = group.getDoubleValue();
            else {}
        }
        if (!Double.isNaN(x) && !Double.isNaN(y)) {
            coordList.add(new Coordinate(x,y,z));
        }
    } catch (IOException ioe) {throw ioe;}
    return group;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:19,代码来源:DxfVERTEX.java

示例10: getCoordinates

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

  return coordinates;
}
 
开发者ID:GitHubDroid,项目名称:geodroid_master_update,代码行数:26,代码来源:EdgeString.java

示例11: densify

import com.vividsolutions.jts.geom.CoordinateList; //导入方法依赖的package包/类
public Geometry densify(double maxSegLenDeg)
{
  double maxSegLenRad = MathFunction.toRadians(maxSegLenDeg);
  
  Coordinate p0 = line.getCoordinates()[0];
  Coordinate p1 = line.getCoordinates()[1];
  
  CoordinateList coords = new CoordinateList();
  
  Coordinate dc1 = GeodeticCoord.toCartesian(p1);
  //coords.add(dc0);
  densify(GeodeticCoord.toCartesian(p0), GeodeticCoord.toCartesian(p1), maxSegLenRad, coords);
  coords.add(dc1);
  
  // convert back to geo
  Coordinate[] dcPts = coords.toCoordinateArray();
  for (int i = 0; i < dcPts.length; i++) {
    dcPts[i] = GeodeticCoord.toGeodetic(dcPts[i]);
  }
  return line.getFactory().createLineString(dcPts);
}
 
开发者ID:dr-jts,项目名称:jeql,代码行数:22,代码来源:GeodeticDensifier.java

示例12: parseCoordinates

import com.vividsolutions.jts.geom.CoordinateList; //导入方法依赖的package包/类
private Coordinate[] parseCoordinates(String coordStr, boolean closeRing) {
  StreamTokenizer st = new StreamTokenizer(new StringReader(coordStr));
  st.parseNumbers();

  CoordinateList coordinates = new CoordinateList();
  try {
    coordinates.add(parseCoordinate(st));
    while (hasMoreTokens(st)) {
      coordinates.add(parseCoordinate(st));
    }
  } catch (IOException ex) {
    // should never happen - throw illegal state exception
    throw new IllegalStateException(
        "IOException during coordinate string parsing");
  }
  // close ring if required
  if (closeRing) 
    coordinates.closeRing();
  
  return coordinates.toCoordinateArray();
  /*
   * System.out.println(coordStr); // TODO: parse it! return new Coordinate[] {
   * new Coordinate(),new Coordinate(),new Coordinate(),new Coordinate() };
   */
}
 
开发者ID:dr-jts,项目名称:jeql,代码行数:26,代码来源:PlacemarkParser.java

示例13: addEdge

import com.vividsolutions.jts.geom.CoordinateList; //导入方法依赖的package包/类
private static void addEdge(Coordinate[] coords, boolean isForward, CoordinateList coordList) {
    if (isForward) {
        for (Coordinate coord : coords) {
            coordList.add(coord, false);
        }
    } else {
        for (int i = coords.length - 1; i >= 0; i--) {
            coordList.add(coords[i], false);
        }
    }
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:12,代码来源:EdgeRing.java

示例14: snapSegments

import com.vividsolutions.jts.geom.CoordinateList; //导入方法依赖的package包/类
/**
 * Snap segments of the source to nearby snap vertices.
 * Source segments are "cracked" at a snap vertex.
 * A single input segment may be snapped several times
 * to different snap vertices.
 * <p>
 * For each distinct snap vertex, at most one source segment
 * is snapped to.  This prevents "cracking" multiple segments
 * at the same point, which would likely cause
 * topology collapse when being used on polygonal linework.
 *
 * @param srcCoords the coordinates of the source linestring to be snapped
 * @param snapPts the target snap vertices
 */
private void snapSegments(CoordinateList srcCoords, Coordinate[] snapPts) {
    // guard against empty input
    if (snapPts.length == 0) {
        return;
    }

    int distinctPtCount = snapPts.length;

    // check for duplicate snap pts when they are sourced from a linear ring.
    // TODO: Need to do this better - need to check *all* snap points for dups (using a Set?)
    if (snapPts[0].equals2D(snapPts[snapPts.length - 1])) {
        distinctPtCount = snapPts.length - 1;
    }

    for (int i = 0; i < distinctPtCount; i++) {
        Coordinate snapPt = snapPts[i];
        int index = this.findSegmentIndexToSnap(snapPt, srcCoords);
        /**
         * If a segment to snap to was found, "crack" it at the snap pt.
         * The new pt is inserted immediately into the src segment list,
         * so that subsequent snapping will take place on the modified segments.
         * Duplicate points are not added.
         */
        if (index >= 0) {
            srcCoords.add(index + 1, new Coordinate(snapPt), false);
        }
    }
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:43,代码来源:LineStringSnapper.java

示例15: collapseLine

import com.vividsolutions.jts.geom.CoordinateList; //导入方法依赖的package包/类
private Coordinate[] collapseLine() {
        CoordinateList coordList = new CoordinateList();
        for (int i = 0; i < this.inputLine.length; i++) {
            if (this.isDeleted[i] != DELETE) {
                coordList.add(this.inputLine[i]);
            }
        }
//    if (coordList.size() < inputLine.length)      System.out.println("Simplified " + (inputLine.length - coordList.size()) + " pts");
        return coordList.toCoordinateArray();
    }
 
开发者ID:gegy1000,项目名称:Earth,代码行数:11,代码来源:BufferInputLineSimplifier.java


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