コード例 #1
0
/* private static */
int
OrientedCoordinateArray::compareOriented(const geom::CoordinateSequence& pts1,
                                     bool orientation1,
                                     const geom::CoordinateSequence& pts2,
                                     bool orientation2)
{
    int dir1 = orientation1 ? 1 : -1;
    int dir2 = orientation2 ? 1 : -1;
    int limit1 = orientation1 ? pts1.size() : -1;
    int limit2 = orientation2 ? pts2.size() : -1;

    int i1 = orientation1 ? 0 : pts1.size() - 1;
    int i2 = orientation2 ? 0 : pts2.size() - 1;
    //int comp = 0; // unused, but is in JTS ...
    while (true) {
      int compPt = pts1[i1].compareTo(pts2[i2]);
      if (compPt != 0)
        return compPt;
      i1 += dir1;
      i2 += dir2;
      bool done1 = i1 == limit1;
      bool done2 = i2 == limit2;
      if (done1 && ! done2) return -1;
      if (! done1 && done2) return 1;
      if (done1 && done2) return 0;
    }
}
コード例 #2
0
geom::Envelope
DelaunayTriangulationBuilder::envelope(const geom::CoordinateSequence& coords)
{
	Envelope env;
	std::vector<Coordinate> coord_vector;
	coords.toVector(coord_vector);
	for(std::vector<Coordinate>::iterator it= coord_vector.begin() ; it!=coord_vector.end() ; ++it)
	{
		const Coordinate& coord = *it;
		env.expandToInclude(coord);
	}
	return env;
}
コード例 #3
0
void
CentroidArea::addLinearSegments(const geom::CoordinateSequence& pts)
{
	std::size_t const n = pts.size()-1;
	for (std::size_t i = 0; i < n; ++i) {
		double segmentLen = pts[i].distance(pts[i + 1]);
		totalLength += segmentLen;

		double midx = (pts[i].x + pts[i + 1].x) / 2;
		centSum.x += segmentLen * midx;
		double midy = (pts[i].y + pts[i + 1].y) / 2;
		centSum.y += segmentLen * midy;
	}
}
コード例 #4
0
/*static*/
int
RayCrossingCounterDD::locatePointInRing(const geom::Coordinate& point,
                                        const geom::CoordinateSequence& ring)
{
    RayCrossingCounterDD rcc(point);

    for (std::size_t i = 1, ni = ring.size(); i < ni; i++) {
        const geom::Coordinate & p1 = ring[ i - 1 ];
        const geom::Coordinate & p2 = ring[ i ];

        rcc.countSegment(p1, p2);

        if (rcc.isOnSegment())
            return rcc.getLocation();
    }
    return rcc.getLocation();
}
コード例 #5
0
void VoronoiDiagramBuilder::setSites(const geom::CoordinateSequence& coords)
{
   CoordinateSequence* coords_cpy = coords.clone();
   DelaunayTriangulationBuilder::unique(*coords_cpy);
   *siteCoords = *coords_cpy;
}
コード例 #6
0
void 
VoronoiDiagramBuilder::setSites(const geom::CoordinateSequence& coords)
{
	siteCoords.reset( coords.clone() );
	DelaunayTriangulationBuilder::unique(*siteCoords);
}