[geos-commits] [SCM] GEOS branch master updated. 0a306ee487120730bfe2688db2f79bf0635dd128

git at osgeo.org git at osgeo.org
Wed Dec 19 14:09:14 PST 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GEOS".

The branch, master has been updated
       via  0a306ee487120730bfe2688db2f79bf0635dd128 (commit)
      from  07249559a60569deb511fe07e4accd0471ef5ce0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 0a306ee487120730bfe2688db2f79bf0635dd128
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date:   Wed Dec 19 14:08:59 2018 -0800

    Deprecate CGAlgorithms and remove all references
    JTS b1c0a1e2992c3f3d523dcfb3c0158fbac72b6928

diff --git a/include/geos/algorithm/CGAlgorithms.h b/include/geos/algorithm/CGAlgorithms.h
deleted file mode 100644
index 203890c..0000000
--- a/include/geos/algorithm/CGAlgorithms.h
+++ /dev/null
@@ -1,230 +0,0 @@
-/**********************************************************************
- *
- * GEOS - Geometry Engine Open Source
- * http://geos.osgeo.org
- *
- * Copyright (C) 2011 Sandro Santilli <strk at kbt.io>
- * Copyright (C) 2005-2006 Refractions Research Inc.
- * Copyright (C) 2001-2002 Vivid Solutions Inc.
- *
- * This is free software; you can redistribute and/or modify it under
- * the terms of the GNU Lesser General Public Licence as published
- * by the Free Software Foundation.
- * See the COPYING file for more information.
- *
- **********************************************************************
- *
- * Last port: algorithm/CGAlgorithms.java r378 (JTS-1.12)
- *
- **********************************************************************/
-
-#ifndef GEOS_ALGORITHM_CGALGORITHM_H
-#define GEOS_ALGORITHM_CGALGORITHM_H
-
-#include <geos/export.h>
-#include <vector>
-
-// Forward declarations
-namespace geos {
-	namespace geom {
-		class Coordinate;
-		class CoordinateSequence;
-	}
-}
-
-
-namespace geos {
-namespace algorithm { // geos::algorithm
-
-/**
- * \brief
- * Specifies and implements various fundamental Computational Geometric
- * algorithms.
- * The algorithms supplied in this class are robust for double-precision
- * floating point.
- *
- */
-class GEOS_DLL CGAlgorithms {
-
-public:
-
-	enum {
-		CLOCKWISE=-1,
-		COLLINEAR=0,
-		COUNTERCLOCKWISE=1
-	};
-
-	enum {
-		RIGHT=-1,
-		LEFT=1,
-		STRAIGHT=0
-	};
-
-	CGAlgorithms(){}
-
-	/** \brief
-	 * Tests whether a point lies inside a ring.
-	 *
-	 * The ring may be oriented in either direction.
-	 * A point lying exactly on the ring boundary is considered
-	 * to be inside the ring.
-	 *
-	 * This algorithm does not first check the
-	 * point against the envelope of the ring.
-	 *
-	 * @param p point to check for ring inclusion
-	 * @param ring is assumed to have first point identical to last point
-	 * @return <code>true</code> if p is inside ring
-	 *
-	 * @see locatePointInRing
-	 */
-	static bool isPointInRing(const geom::Coordinate& p,
-			const geom::CoordinateSequence* ring);
-
-	/// Same as above, but taking a vector of const Coordinates (faster)
-	static bool isPointInRing(const geom::Coordinate& p,
-			const std::vector<const geom::Coordinate*>& ring);
-
-	/** \brief
-	 * Determines whether a point lies in the interior,
-	 * on the boundary, or in the exterior of a ring.
-	 *
-	 * The ring may be oriented in either direction.
-	 *
-	 * This method does <i>not</i> first check the point against
-	 * the envelope of the ring.
-	 *
-	 * @param p point to check for ring inclusion
-	 * @param ring an array of coordinates representing the ring
-	 *        (which must have first point identical to last point)
-	 * @return the {@link Location} of p relative to the ring
-	 */
-	static int locatePointInRing(const geom::Coordinate& p,
-			const geom::CoordinateSequence& ring);
-
-	/// Same as above, but taking a vector of const Coordinates
-	static int locatePointInRing(const geom::Coordinate& p,
-			const std::vector<const geom::Coordinate*>& ring);
-
-	/** \brief
-	 * Test whether a point lies on the given line segment
-	 *
-	 * @return true true if
-	 * the point is a vertex of the line or lies in the interior of a line
-	 * segment in the linestring
-	 */
-	static bool isOnLine(const geom::Coordinate& p,
-		const geom::CoordinateSequence* pt);
-
-	/** \brief
-	 * Computes whether a ring defined by an array of Coordinate is
-	 * oriented counter-clockwise.
-	 *
-	 *  - The list of points is assumed to have the first and last
-	 *    points equal.
-	 *  - This will handle coordinate lists which contain repeated points.
-	 *
-	 * This algorithm is <b>only</b> guaranteed to work with valid rings.
-	 * If the ring is invalid (e.g. self-crosses or touches),
-	 * the computed result <b>may</b> not be correct.
-	 *
-	 * @param ring an array of coordinates forming a ring
-	 * @return <code>true</code> if the ring is oriented counter-clockwise.
-	 */
-	static bool isCCW(const geom::CoordinateSequence* ring);
-
-	/** \brief
-	 * Computes the orientation of a point q to the directed line
-	 * segment p1-p2.
-	 *
-	 * The orientation of a point relative to a directed line
-	 * segment indicates which way you turn to get to q after
-	 * travelling from p1 to p2.
-	 *
-	 * @return 1 if q is counter-clockwise from p1-p2
-	 * @return -1 if q is clockwise from p1-p2
-	 * @return 0 if q is collinear with p1-p2
-	 */
-	static int computeOrientation(const geom::Coordinate& p1,
-			const geom::Coordinate& p2,
-			const geom::Coordinate& q);
-
-	/** \brief
-	 * Computes the distance from a point p to a line segment AB
-	 *
-	 * Note: NON-ROBUST!
-	 *
-	 * @param p the point to compute the distance for
-	 * @param A one point of the line
-	 * @param B another point of the line (must be different to A)
-	 * @return the distance from p to line segment AB
-	 */
-	static double distancePointLine(const geom::Coordinate& p,
-			const geom::Coordinate& A,
-			const geom::Coordinate& B);
-
-	/** \brief
-	 * Computes the perpendicular distance from a point p
-	 * to the (infinite) line containing the points AB
-	 *
-	 * @param p the point to compute the distance for
-	 * @param A one point of the line
-	 * @param B another point of the line (must be different to A)
-	 * @return the distance from p to line AB
-	 */
-	static double distancePointLinePerpendicular(const geom::Coordinate& p,
-			const geom::Coordinate& A,
-			const geom::Coordinate& B);
-
-	/** \brief
-	 * Computes the distance from a line segment AB to a line segment CD
-	 *
-	 * Note: NON-ROBUST!
-	 *
-	 * @param A a point of one line
-	 * @param B the second point of  (must be different to A)
-	 * @param C one point of the line
-	 * @param D another point of the line (must be different to A)
-	 */
-	static double distanceLineLine(const geom::Coordinate& A,
-			const geom::Coordinate& B,
-			const geom::Coordinate& C,
-			const geom::Coordinate& D);
-
-	/** \brief
-	 * Returns the signed area for a ring.  The area is positive if
-	 * the ring is oriented CW.
-	 */
-	static double signedArea(const geom::CoordinateSequence* ring);
-
-	/** \brief
-	 * Computes the length of a linestring specified by a sequence
-	 * of points.
-	 *
-	 * @param pts the points specifying the linestring
-	 * @return the length of the linestring
-	 */
-	static double length(const geom::CoordinateSequence* pts);
-
-	/** \brief
-	 * Returns the index of the direction of the point <code>q</code>
-	 * relative to a vector specified by <code>p1-p2</code>.
-	 *
-	 * @param p1 the origin point of the vector
-	 * @param p2 the final point of the vector
-	 * @param q the point to compute the direction to
-	 *
-	 * @return 1 if q is counter-clockwise (left) from p1-p2
-	 * @return -1 if q is clockwise (right) from p1-p2
-	 * @return 0 if q is collinear with p1-p2
-	 */
-	static int orientationIndex(const geom::Coordinate& p1,
-			const geom::Coordinate& p2,
-			const geom::Coordinate& q);
-
-};
-
-} // namespace geos::algorithm
-} // namespace geos
-
-#endif // GEOS_ALGORITHM_CGALGORITHM_H
diff --git a/include/geos/algorithm/Makefile.am b/include/geos/algorithm/Makefile.am
index 77232f4..519e709 100644
--- a/include/geos/algorithm/Makefile.am
+++ b/include/geos/algorithm/Makefile.am
@@ -16,7 +16,6 @@ geos_HEADERS = \
 	BoundaryNodeRule.h \
 	CentralEndpointIntersector.h \
 	Centroid.h \
-	CGAlgorithms.h \
 	ConvexHull.h \
 	ConvexHull.inl \
 	Distance.h \
diff --git a/src/algorithm/CGAlgorithms.cpp b/src/algorithm/CGAlgorithms.cpp
deleted file mode 100644
index 7ab8599..0000000
--- a/src/algorithm/CGAlgorithms.cpp
+++ /dev/null
@@ -1,354 +0,0 @@
-/**********************************************************************
- *
- * GEOS - Geometry Engine Open Source
- * http://geos.osgeo.org
- *
- * Copyright (C) 2011 Sandro Santilli <strk at kbt.io>
- * Copyright (C) 2005 2006 Refractions Research Inc.
- * Copyright (C) 2001-2002 Vivid Solutions Inc.
- *
- * This is free software; you can redistribute and/or modify it under
- * the terms of the GNU Lesser General Public Licence as published
- * by the Free Software Foundation.
- * See the COPYING file for more information.
- *
- **********************************************************************
- *
- * Last port: algorithm/CGAlgorithms.java r378 (JTS-1.12)
- *
- **********************************************************************/
-
-#include <geos/algorithm/CGAlgorithms.h>
-#include <geos/algorithm/LineIntersector.h>
-#include <geos/algorithm/RayCrossingCounter.h>
-#include <geos/geom/CoordinateSequence.h>
-#include <geos/geom/Coordinate.h>
-#include <geos/geom/Location.h>
-#include <geos/util/IllegalArgumentException.h>
-
-#include <algorithm>
-//#include <cstdio>
-#include <cmath>
-
-using namespace std;
-
-using namespace geos::geom;
-
-namespace geos {
-namespace algorithm { // geos.algorithm
-
-/*public static*/
-int
-CGAlgorithms::orientationIndex(const Coordinate& p1,const Coordinate& p2,const Coordinate& q)
-{
-	return RayCrossingCounter::orientationIndex(p1, p2, q);
-}
-
-/*public static*/
-bool
-CGAlgorithms::isPointInRing(const Coordinate& p, const CoordinateSequence* ring)
-{
-	return locatePointInRing(p, *ring) != Location::EXTERIOR;
-}
-
-/*public static*/
-bool
-CGAlgorithms::isPointInRing(const Coordinate& p,
-		const Coordinate::ConstVect& ring)
-{
-	return locatePointInRing(p, ring) != Location::EXTERIOR;
-}
-
-/*public static*/
-int
-CGAlgorithms::locatePointInRing(const Coordinate& p,
-		const CoordinateSequence& ring)
-{
-	return RayCrossingCounter::locatePointInRing(p, ring);
-}
-
-/*public static*/
-int
-CGAlgorithms::locatePointInRing(const Coordinate& p,
-		const std::vector<const geom::Coordinate*>& ring)
-{
-	return RayCrossingCounter::locatePointInRing(p, ring);
-}
-
-/*public static*/
-bool
-CGAlgorithms::isOnLine(const Coordinate& p, const CoordinateSequence* pt)
-{
-	//LineIntersector lineIntersector;
-	size_t ptsize = pt->getSize();
-	if ( ptsize == 0 ) return false;
-
-	const Coordinate *pp=&(pt->getAt(0));
-	for(size_t i=1; i<ptsize; ++i)
-	{
-		const Coordinate &p1=pt->getAt(i);
-		if ( LineIntersector::hasIntersection(p, *pp, p1) )
-			return true;
-		pp=&p1;
-	}
-	return false;
-}
-
-/*public static*/
-bool
-CGAlgorithms::isCCW(const CoordinateSequence* ring)
-{
-	// sanity check
-	if (ring->getSize() < 4)
-	{
-		throw util::IllegalArgumentException("Ring has fewer than 3 points, so orientation cannot be determined");
-	}
-
-	// # of points without closing endpoint
-	const std::size_t nPts=ring->getSize()-1;
-
-	// find highest point
-	const Coordinate *hiPt=&ring->getAt(0);
-	size_t hiIndex = 0;
-	for (std::size_t i = 1; i <= nPts; ++i)
-	{
-		const Coordinate *p=&ring->getAt(i);
-		if (p->y > hiPt->y) {
-			hiPt = p;
-			hiIndex = i;
-		}
-	}
-
-	// find distinct point before highest point
-	auto iPrev = hiIndex;
-	do {
-		if (iPrev == 0)
-            iPrev = nPts;
-		iPrev = iPrev - 1;
-	} while (ring->getAt(iPrev) == *hiPt && iPrev != hiIndex);
-
-	// find distinct point after highest point
-	auto iNext = hiIndex;
-	do {
-		iNext = (iNext + 1) % nPts;
-	} while (ring->getAt(iNext)==*hiPt && iNext != hiIndex);
-
-	const Coordinate *prev=&ring->getAt(iPrev);
-	const Coordinate *next=&ring->getAt(iNext);
-
-	/*
-	 * This check catches cases where the ring contains an A-B-A
-	 * configuration of points.
-	 * This can happen if the ring does not contain 3 distinct points
-	 * (including the case where the input array has fewer than 4 elements),
-	 * or it contains coincident line segments.
-	 */
-	if ( prev->equals2D(*hiPt) || next->equals2D(*hiPt) ||
-		prev->equals2D(*next) )
-	{
-		return false;
-		// MD - don't bother throwing exception,
-		// since this isn't a complete check for ring validity
-		//throw  IllegalArgumentException("degenerate ring (does not contain 3 distinct points)");
-	}
-
-	int disc = computeOrientation(*prev, *hiPt, *next);
-
-	/**
-	 *  If disc is exactly 0, lines are collinear.
-	 * There are two possible cases:
-	 *  (1) the lines lie along the x axis in opposite directions
-	 *  (2) the lines lie on top of one another
-	 *
-	 *  (1) is handled by checking if next is left of prev ==> CCW
-	 *  (2) should never happen, so we're going to ignore it!
-	 *  (Might want to assert this)
-	 */
-	bool isCCW=false;
-
-	if (disc == 0) {
-		// poly is CCW if prev x is right of next x
-		isCCW = (prev->x > next->x);
-	} else {
-		// if area is positive, points are ordered CCW
-		isCCW = (disc > 0);
-	}
-
-	return isCCW;
-}
-
-/*public static*/
-int
-CGAlgorithms::computeOrientation(const Coordinate& p1, const Coordinate& p2,
-		const Coordinate& q)
-{
-	return orientationIndex(p1,p2,q);
-}
-
-/*public static*/
-double
-CGAlgorithms::distancePointLine(const Coordinate& p, const Coordinate& A,
-		const Coordinate& B)
-{
-	//if start==end, then use pt distance
-	if (A==B) return p.distance(A);
-
-    // otherwise use comp.graphics.algorithms Frequently Asked Questions method
-    /*(1)     	      AC dot AB
-                   r = ---------
-                         ||AB||^2
-		r has the following meaning:
-		r=0 P = A
-		r=1 P = B
-		r<0 P is on the backward extension of AB
-		r>1 P is on the forward extension of AB
-		0<r<1 P is interior to AB
-	*/
-	double r=((p.x-A.x)*(B.x-A.x)+(p.y-A.y)*(B.y-A.y))/
-			 ((B.x-A.x)*(B.x-A.x)+(B.y-A.y)*(B.y-A.y));
-	if (r<=0.0) return p.distance(A);
-	if (r>=1.0) return p.distance(B);
-    /*(2)
-		     (Ay-Cy)(Bx-Ax)-(Ax-Cx)(By-Ay)
-		s = -----------------------------
-		             	L^2
-
-		Then the distance from C to P = |s|*L.
-	*/
-	double s=((A.y-p.y)*(B.x-A.x)-(A.x-p.x)*(B.y-A.y))/
-			 ((B.x-A.x)*(B.x-A.x)+(B.y-A.y)*(B.y-A.y));
-	return fabs(s)*sqrt(((B.x-A.x)*(B.x-A.x)+(B.y-A.y)*(B.y-A.y)));
-}
-
-/*public static*/
-double
-CGAlgorithms::distancePointLinePerpendicular(const Coordinate& p,const Coordinate& A,const Coordinate& B)
-{
-    // use comp.graphics.algorithms Frequently Asked Questions method
-    /*(2)
-                     (Ay-Cy)(Bx-Ax)-(Ax-Cx)(By-Ay)
-                s = -----------------------------
-                                     L^2
-
-                Then the distance from C to P = |s|*L.
-        */
-
-	double s = ((A.y - p.y) *(B.x - A.x) - (A.x - p.x)*(B.y - A.y) )
-              /
-            ((B.x - A.x) * (B.x - A.x) + (B.y - A.y) * (B.y - A.y) );
-    return fabs(s)*sqrt(((B.x - A.x) * (B.x - A.x) + (B.y - A.y) * (B.y - A.y)));
-}
-
-/*public static*/
-double
-CGAlgorithms::distanceLineLine(const Coordinate& A, const Coordinate& B,
-		const Coordinate& C, const Coordinate& D)
-{
-	// check for zero-length segments
-	if (A==B) return distancePointLine(A,C,D);
-	if (C==D) return distancePointLine(D,A,B);
-
-    // AB and CD are line segments
-    /* from comp.graphics.algo
-
-	Solving the above for r and s yields
-				(Ay-Cy)(Dx-Cx)-(Ax-Cx)(Dy-Cy)
-	           r = ----------------------------- (eqn 1)
-				(Bx-Ax)(Dy-Cy)-(By-Ay)(Dx-Cx)
-
-		 	(Ay-Cy)(Bx-Ax)-(Ax-Cx)(By-Ay)
-		s = ----------------------------- (eqn 2)
-			(Bx-Ax)(Dy-Cy)-(By-Ay)(Dx-Cx)
-	Let P be the position vector of the intersection point, then
-		P=A+r(B-A) or
-		Px=Ax+r(Bx-Ax)
-		Py=Ay+r(By-Ay)
-	By examining the values of r & s, you can also determine some other
-limiting conditions:
-		If 0<=r<=1 & 0<=s<=1, intersection exists
-		r<0 or r>1 or s<0 or s>1 line segments do not intersect
-		If the denominator in eqn 1 is zero, AB & CD are parallel
-		If the numerator in eqn 1 is also zero, AB & CD are collinear.
-
-	*/
-	double r_top=(A.y-C.y)*(D.x-C.x)-(A.x-C.x)*(D.y-C.y);
-	double r_bot=(B.x-A.x)*(D.y-C.y)-(B.y-A.y)*(D.x-C.x);
-	double s_top=(A.y-C.y)*(B.x-A.x)-(A.x-C.x)*(B.y-A.y);
-	double s_bot=(B.x-A.x)*(D.y-C.y)-(B.y-A.y)*(D.x-C.x);
-	if ((r_bot==0)||(s_bot==0)) {
-		return std::min(distancePointLine(A,C,D),
-						std::min(distancePointLine(B,C,D),
-						std::min(distancePointLine(C,A,B), distancePointLine(D,A,B))));
-	}
-	double s=s_top/s_bot;
-	double r=r_top/r_bot;
-	if ((r<0)||( r>1)||(s<0)||(s>1)) {
-		//no intersection
-		return std::min(distancePointLine(A,C,D),
-						std::min(distancePointLine(B,C,D),
-						std::min(distancePointLine(C,A,B), distancePointLine(D,A,B))));
-	}
-	return 0.0; //intersection exists
-}
-
-/*public static*/
-double
-CGAlgorithms::signedArea(const CoordinateSequence* ring)
-{
-	size_t npts=ring->getSize();
-
-	if (npts<3) return 0.0;
-
-	Coordinate pp;
-	Coordinate cp = ring->getAt(0);
-	Coordinate np = ring->getAt(1);
-	double x0 = cp.x;
-        np.x -= x0;
-	double sum=0.0;
-	for (size_t i=1; i<npts; ++i)
-	{
-		pp.y = cp.y;
-		cp.x = np.x;
-		cp.y = np.y;
-		ring->getAt(i, np);
-                np.x -= x0;
-		sum += cp.x * (np.y - pp.y);
-	}
-	return -sum/2.0;
-}
-
-/*public static*/
-double
-CGAlgorithms::length(const CoordinateSequence* pts)
-{
-	// optimized for processing CoordinateSequences
-
-	size_t npts=pts->getSize();
-	if (npts <= 1) return 0.0;
-
-	double len = 0.0;
-
-	const Coordinate& p0 = pts->getAt(0);
-	double x0 = p0.x;
-	double y0 = p0.y;
-
-	for(size_t i = 1; i < npts; ++i)
-	{
-		const Coordinate& p = pts->getAt(i);
-		double x1 = p.x;
-		double y1 = p.y;
-		double dx = x1 - x0;
-		double dy = y1 - y0;
-
-		len += sqrt(dx * dx + dy * dy);
-
-		x0 = x1;
-		y0 = y1;
-	}
-
-	return len;
-}
-
-
-} // namespace geos.algorithm
-} // namespace geos
diff --git a/src/algorithm/Makefile.am b/src/algorithm/Makefile.am
index 520364e..f48c0bf 100644
--- a/src/algorithm/Makefile.am
+++ b/src/algorithm/Makefile.am
@@ -14,7 +14,6 @@ libalgorithm_la_SOURCES = \
 	Area.cpp \
 	BoundaryNodeRule.cpp \
 	Centroid.cpp \
-	CGAlgorithms.cpp \
 	CGAlgorithmsDD.cpp \
 	ConvexHull.cpp \
 	Distance.cpp \

-----------------------------------------------------------------------

Summary of changes:
 include/geos/algorithm/CGAlgorithms.h | 230 ----------------------
 include/geos/algorithm/Makefile.am    |   1 -
 src/algorithm/CGAlgorithms.cpp        | 354 ----------------------------------
 src/algorithm/Makefile.am             |   1 -
 4 files changed, 586 deletions(-)
 delete mode 100644 include/geos/algorithm/CGAlgorithms.h
 delete mode 100644 src/algorithm/CGAlgorithms.cpp


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list