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


Java CoordinateSequence类代码示例

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


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

示例1: visitLiteralGeometry

import com.vividsolutions.jts.geom.CoordinateSequence; //导入依赖的package包/类
protected void visitLiteralGeometry(Literal expression) throws IOException {
    // evaluate the literal and store it for later
    currentGeometry  = (Geometry) evaluateLiteral(expression, Geometry.class);

    if ( currentGeometry instanceof LinearRing ) {
        // convert LinearRing to LineString
        final GeometryFactory factory = currentGeometry.getFactory();
        final LinearRing linearRing = (LinearRing) currentGeometry;
        final CoordinateSequence coordinates;
        coordinates = linearRing.getCoordinateSequence();
        currentGeometry = factory.createLineString(coordinates);
    }

    final String geoJson = new GeometryJSON().toString(currentGeometry);
    currentShapeBuilder = mapReader.readValue(geoJson);
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:17,代码来源:FilterToElastic.java

示例2: applyZValues

import com.vividsolutions.jts.geom.CoordinateSequence; //导入依赖的package包/类
private void applyZValues(CoordinateSequence cs, int idx,
        CoordinateSequence csOrig, int origIdx) {
    double lx1 = cs.getOrdinate(idx, 0);                
    double ly1 = cs.getOrdinate(idx, 1);
    double lz1;
    
    double ox1 = csOrig.getOrdinate(origIdx, 0);                
    double oy1 = csOrig.getOrdinate(origIdx, 1);
    double oz1 = csOrig.getOrdinate(origIdx, 2);
    double ox2 = csOrig.getOrdinate(origIdx + 1, 0);                
    double oy2 = csOrig.getOrdinate(origIdx + 1, 1);
    double oz2 = csOrig.getOrdinate(origIdx + 1, 2);
    
    if(lx1 == ox1 && ly1 == oy1) {
        lz1 = oz1;
    } else {
        double d1 = distance(ox1, oy1, lx1, ly1);
        double d = distance(ox1, oy1, ox2, oy2);
        lz1 = oz1 + (oz2 - oz1) * (d1 / d);
    }
    
    cs.setOrdinate(idx, 2, lz1);
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:24,代码来源:ClipProcess.java

示例3: checkRepeatedPoints2d

import com.vividsolutions.jts.geom.CoordinateSequence; //导入依赖的package包/类
private static int checkRepeatedPoints2d(LineString lineString) {
  int repeatedPoints = 0;

  final CoordinateSequence coordSeq = lineString.getCoordinateSequence();
  Coordinate nextCoord = null;
  Coordinate prevCoord;
  for (int i = 0; i < coordSeq.size(); ++i) {
    prevCoord = nextCoord;
    nextCoord = coordSeq.getCoordinate(i);
    if (nextCoord.equals(prevCoord)) {
      ++repeatedPoints;
    }
  }

  return repeatedPoints;
}
 
开发者ID:OrdnanceSurvey,项目名称:vt-support,代码行数:17,代码来源:JtsGeomStats.java

示例4: toJSON

import com.vividsolutions.jts.geom.CoordinateSequence; //导入依赖的package包/类
public static JSONArray toJSON(LineString line, boolean inverseSeq)
{
	// "coordinates": [ [100.0, 0.0], [101.0, 1.0] ]
	int size = line.getNumPoints();

	JSONArray arrCoords = new JSONArray(size);

	CoordinateSequence seq = line.getCoordinateSequence();
	Coordinate coord = null;

	for (int i = 0; i < size; ++i) 
	{
		coord = seq.getCoordinate(inverseSeq ? size - i - 1: i);

		arrCoords.put(toJSON(coord));
	}

	return arrCoords;
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:20,代码来源:GeometryJSON.java

示例5: toCoordinateSequence

import com.vividsolutions.jts.geom.CoordinateSequence; //导入依赖的package包/类
private CoordinateSequence toCoordinateSequence(OsmEntityProvider resolver)
        throws EntityNotFoundException {
    CoordinateSequenceFactory csf = factory.getCoordinateSequenceFactory();

    int len = this.getLength();
    CoordinateSequence points = csf.create(len, 2);

    int n = 0;
    for (int i = 0; i < this.segments.size(); i++) {
        WaySegment segment = this.segments.get(i);
        OsmWay way = segment.getWay();
        for (int k = 0; k < way.getNumberOfNodes(); k++) {
            if (k > 0 || i == 0) {
                OsmNode node = resolver.getNode(segment.getNodeId(k));
                points.setOrdinate(n, 0, node.getLongitude());
                points.setOrdinate(n, 1, node.getLatitude());
                n++;
            }
        }
    }

    return points;
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:24,代码来源:ChainOfWays.java

示例6: ringFromSegments

import com.vividsolutions.jts.geom.CoordinateSequence; //导入依赖的package包/类
private static LinearRing ringFromSegments(List<LineSegment> segments) {
    GeometryFactory factory = new GeometryFactory();
    int nSegs = segments.size();
    if (nSegs < 3) {
        return null;
    }
    int len = segments.size() + 1;
    CoordinateSequence seq = factory.getCoordinateSequenceFactory().create(
            len, 2);
    int i = 0;
    for (LineSegment line : segments) {
        seq.setOrdinate(i, 0, line.p0.x);
        seq.setOrdinate(i, 1, line.p0.y);
        i++;
    }
    seq.setOrdinate(i, 0, segments.get(0).p0.x);
    seq.setOrdinate(i, 1, segments.get(0).p0.y);
    return factory.createLinearRing(seq);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:20,代码来源:SelfIntersectionUtil.java

示例7: filter

import com.vividsolutions.jts.geom.CoordinateSequence; //导入依赖的package包/类
@Override
public void filter(CoordinateSequence seq, int index) {
    if (index == 0) {
        return;
    }

    Coordinate p0 = seq.getCoordinate(index - 1);
    Coordinate p1 = seq.getCoordinate(index);
    Coordinate midPt = new Coordinate(
            (p0.x + p1.x) / 2,
            (p0.y + p1.y) / 2);

    this.minPtDist.initialize();
    DistanceToPointFinder.computeDistance(this.geom, midPt, this.minPtDist);
    this.maxPtDist.setMaximum(this.minPtDist);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:17,代码来源:BufferCurveMaximumDistanceFinder.java

示例8: computeFacetSequences

import com.vividsolutions.jts.geom.CoordinateSequence; //导入依赖的package包/类
/**
 * Creates facet sequences
 *
 * @param g
 * @return List<GeometryFacetSequence>
 */
private static List computeFacetSequences(Geometry g) {
    final List sections = new ArrayList();

    g.apply((GeometryComponentFilter) geom -> {
        CoordinateSequence seq = null;
        if (geom instanceof LineString) {
            seq = ((LineString) geom).getCoordinateSequence();
            addFacetSequences(seq, sections);
        } else if (geom instanceof Point) {
            seq = ((Point) geom).getCoordinateSequence();
            addFacetSequences(seq, sections);
        }
    });
    return sections;
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:22,代码来源:FacetSequenceTreeBuilder.java

示例9: averageNormal

import com.vividsolutions.jts.geom.CoordinateSequence; //导入依赖的package包/类
/**
 * Computes an average normal vector from a list of polygon coordinates.
 * Uses Newell's method, which is based
 * on the fact that the vector with components
 * equal to the areas of the projection of the polygon onto
 * the Cartesian axis planes is normal.
 *
 * @param seq the sequence of coordinates for the polygon
 * @return a normal vector
 */
private Vector3D averageNormal(CoordinateSequence seq) {
    int n = seq.size();
    Coordinate sum = new Coordinate(0, 0, 0);
    Coordinate p1 = new Coordinate(0, 0, 0);
    Coordinate p2 = new Coordinate(0, 0, 0);
    for (int i = 0; i < n - 1; i++) {
        seq.getCoordinate(i, p1);
        seq.getCoordinate(i + 1, p2);
        sum.x += (p1.y - p2.y) * (p1.z + p2.z);
        sum.y += (p1.z - p2.z) * (p1.x + p2.x);
        sum.z += (p1.x - p2.x) * (p1.y + p2.y);
    }
    sum.x /= n;
    sum.y /= n;
    sum.z /= n;
    Vector3D norm = Vector3D.create(sum).normalize();
    return norm;
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:29,代码来源:PlanarPolygon3D.java

示例10: locatePointInRing

import com.vividsolutions.jts.geom.CoordinateSequence; //导入依赖的package包/类
/**
 * Determines the {@link Location} of a point in a ring.
 *
 * @param p the point to test
 * @param ring a coordinate sequence forming a ring
 * @return the location of the point in the ring
 */
public static int locatePointInRing(Coordinate p, CoordinateSequence ring) {
    RayCrossingCounter counter = new RayCrossingCounter(p);

    Coordinate p1 = new Coordinate();
    Coordinate p2 = new Coordinate();
    for (int i = 1; i < ring.size(); i++) {
        ring.getCoordinate(i, p1);
        ring.getCoordinate(i - 1, p2);
        counter.countSegment(p1, p2);
        if (counter.isOnSegment()) {
            return counter.getLocation();
        }
    }
    return counter.getLocation();
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:23,代码来源:RayCrossingCounter.java

示例11: setOrdinate

import com.vividsolutions.jts.geom.CoordinateSequence; //导入依赖的package包/类
/**
 * @see com.vividsolutions.jts.geom.CoordinateSequence#setOrdinate(int, int, double)
 */
@Override
public void setOrdinate(int index, int ordinateIndex, double value) {
    switch (ordinateIndex) {
        case CoordinateSequence.X:
            this.coordinates[index].x = value;
            break;
        case CoordinateSequence.Y:
            this.coordinates[index].y = value;
            break;
        case CoordinateSequence.Z:
            this.coordinates[index].z = value;
            break;
        default:
            throw new IllegalArgumentException("invalid ordinateIndex");
    }
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:20,代码来源:CoordinateArraySequence.java

示例12: writeCoordinate

import com.vividsolutions.jts.geom.CoordinateSequence; //导入依赖的package包/类
private void writeCoordinate(CoordinateSequence seq, int index, OutStream os)
        throws IOException {
    ByteOrderValues.putDouble(seq.getX(index), this.buf, this.byteOrder);
    os.write(this.buf, 8);
    ByteOrderValues.putDouble(seq.getY(index), this.buf, this.byteOrder);
    os.write(this.buf, 8);

    // only write 3rd dim if caller has requested it for this writer
    if (this.outputDimension >= 3) {
        // if 3rd dim is requested, only write it if the CoordinateSequence provides it
        double ordVal = Coordinate.NULL_ORDINATE;
        if (seq.getDimension() >= 3) {
            ordVal = seq.getOrdinate(index, 2);
        }
        ByteOrderValues.putDouble(ordVal, this.buf, this.byteOrder);
        os.write(this.buf, 8);
    }
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:19,代码来源:WKBWriter.java

示例13: toLineString

import com.vividsolutions.jts.geom.CoordinateSequence; //导入依赖的package包/类
/**
 * Generates the WKT for a <tt>LINESTRING</tt>
 * specified by a {@link CoordinateSequence}.
 *
 * @param seq the sequence to write
 * @return the WKT string
 */
public static String toLineString(CoordinateSequence seq) {
    StringBuffer buf = new StringBuffer();
    buf.append("LINESTRING ");
    if (seq.size() == 0) {
        buf.append(" EMPTY");
    } else {
        buf.append("(");
        for (int i = 0; i < seq.size(); i++) {
            if (i > 0) {
                buf.append(", ");
            }
            buf.append(seq.getX(i)).append(" ").append(seq.getY(i));
        }
        buf.append(")");
    }
    return buf.toString();
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:25,代码来源:WKTWriter.java

示例14: appendSequenceText

import com.vividsolutions.jts.geom.CoordinateSequence; //导入依赖的package包/类
/**
 * Converts a <code>LineString</code> to &lt;LineString Text&gt; format, then
 * appends it to the writer.
 *
 * @param lineString the <code>LineString</code> to process
 * @param writer the output writer to append to
 */
private void appendSequenceText(CoordinateSequence seq, int level, boolean doIndent, Writer writer)
        throws IOException {
    if (seq.size() == 0) {
        writer.write("EMPTY");
    } else {
        if (doIndent) {
            this.indent(level, writer);
        }
        writer.write("(");
        for (int i = 0; i < seq.size(); i++) {
            if (i > 0) {
                writer.write(", ");
                if (this.coordsPerLine > 0
                        && i % this.coordsPerLine == 0) {
                    this.indent(level + 1, writer);
                }
            }
            this.appendCoordinate(seq, i, writer);
        }
        writer.write(")");
    }
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:30,代码来源:WKTWriter.java

示例15: reverseRing

import com.vividsolutions.jts.geom.CoordinateSequence; //导入依赖的package包/类
/**
 * Does what it says, reverses the order of the Coordinates in the ring.
 * <p>
 * This is different then lr.reverses() in that a copy is produced using a
 * new coordinate sequence.
 * </p>
 *
 * @param lr The ring to reverse.
 * @return A new ring with the reversed Coordinates.
 */
public static final LinearRing reverseRing(LinearRing lr) {
    GeometryFactory gf = lr.getFactory();
    CoordinateSequenceFactory csf = gf.getCoordinateSequenceFactory();

    CoordinateSequence csOrig = lr.getCoordinateSequence();
    int numPoints = csOrig.size();
    int dimensions = csOrig.getDimension();
    CoordinateSequence csNew = csf.create(numPoints, dimensions);

    for (int i = 0; i < numPoints; i++) {
        for (int j = 0; j < dimensions; j++) {
            csNew.setOrdinate(numPoints - 1 - i, j, csOrig.getOrdinate(i, j));
        }
    }

    return gf.createLinearRing(csNew);
}
 
开发者ID:PDOK,项目名称:gml3-jts,代码行数:28,代码来源:GML321ToSurfaceConvertor.java


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