本文整理汇总了Java中com.vividsolutions.jts.geom.CoordinateList类的典型用法代码示例。如果您正苦于以下问题:Java CoordinateList类的具体用法?Java CoordinateList怎么用?Java CoordinateList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CoordinateList类属于com.vividsolutions.jts.geom包,在下文中一共展示了CoordinateList类的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;
}
示例2: snapVertices
import com.vividsolutions.jts.geom.CoordinateList; //导入依赖的package包/类
/**
* Snap source vertices to vertices in the target.
*
* @param srcCoords the points to snap
* @param snapPts the points to snap to
*/
private void snapVertices(CoordinateList srcCoords, Coordinate[] snapPts) {
// try snapping vertices
// if src is a ring then don't snap final vertex
int end = this.isClosed ? srcCoords.size() - 1 : srcCoords.size();
for (int i = 0; i < end; i++) {
Coordinate srcPt = (Coordinate) srcCoords.get(i);
Coordinate snapVert = this.findSnapForVertex(srcPt, snapPts);
if (snapVert != null) {
// update src with snap pt
srcCoords.set(i, new Coordinate(snapVert));
// keep final closing point in synch (rings only)
if (i == 0 && this.isClosed) {
srcCoords.set(srcCoords.size() - 1, new Coordinate(snapVert));
}
}
}
}
示例3: 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();
}
示例4: snapVertices
import com.vividsolutions.jts.geom.CoordinateList; //导入依赖的package包/类
/**
* Snap source vertices to vertices in the target.
*
* @param srcCoords the points to snap
* @param snapPts the points to snap to
*/
private void snapVertices(CoordinateList srcCoords, Coordinate[] snapPts) {
// try snapping vertices
// if src is a ring then don't snap final vertex
int end = isClosed ? srcCoords.size() - 1 : srcCoords.size();
for (int i = 0; i < end; i++) {
Coordinate srcPt = (Coordinate) srcCoords.get(i);
Coordinate snapVert = findSnapForVertex(srcPt, snapPts);
if (snapVert != null) {
// update src with snap pt
srcCoords.set(i, new Coordinate(snapVert));
// keep final closing point in synch (rings only)
if (i == 0 && isClosed)
srcCoords.set(srcCoords.size() - 1, new Coordinate(snapVert));
}
}
}
示例5: 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);
}
}
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: 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);
}
示例10: 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);
}
示例11: 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;
}
示例12: 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;
}
示例13: 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);
}
示例14: 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() };
*/
}
示例15: getCoordinates
import com.vividsolutions.jts.geom.CoordinateList; //导入依赖的package包/类
/**
* Computes the list of coordinates which are contained in this ring.
* The coordinatea are computed once only and cached.
*
* @return an array of the {@link Coordinate}s in this ring
*/
private Coordinate[] getCoordinates() {
if (this.ringPts == null) {
CoordinateList coordList = new CoordinateList();
for (Object aDeList : deList) {
DirectedEdge de = (DirectedEdge) aDeList;
PolygonizeEdge edge = (PolygonizeEdge) de.getEdge();
addEdge(edge.getLine().getCoordinates(), de.getEdgeDirection(), coordList);
}
this.ringPts = coordList.toCoordinateArray();
}
return this.ringPts;
}