/* 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
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;
	}
}
Пример #3
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();
}