RayCrossingCounter.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2006 Refractions Research 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/RayCrossingCounter.java rev. 1.2 (JTS-1.9)
*
**********************************************************************/
#pragma once
#include <geos/export.h>
#include <geos/geom/Location.h>
#include <array>
#include <vector>
// forward declarations
namespace geos {
namespace geom {
class Coordinate;
class CoordinateXY;
class CoordinateSequence;
class CircularArc;
class Curve;
}
}
namespace geos {
namespace algorithm {
class GEOS_DLL RayCrossingCounter {
private:
const geom::CoordinateXY& point;
std::size_t crossingCount;
// true if the test point lies on an input segment
bool isPointOnSegment;
// Declare type as noncopyable
RayCrossingCounter(const RayCrossingCounter& other) = delete;
RayCrossingCounter& operator=(const RayCrossingCounter& rhs) = delete;
public:
static geom::Location locatePointInRing(const geom::CoordinateXY& p,
const geom::CoordinateSequence& ring);
static geom::Location locatePointInRing(const geom::CoordinateXY& p,
const std::vector<const geom::Coordinate*>& ring);
static geom::Location locatePointInRing(const geom::CoordinateXY& p,
const geom::Curve& ring);
RayCrossingCounter(const geom::CoordinateXY& p_point)
: point(p_point),
crossingCount(0),
isPointOnSegment(false)
{ }
void countSegment(const geom::CoordinateXY& p1,
const geom::CoordinateXY& p2);
void countArc(const geom::CoordinateXY& p1,
const geom::CoordinateXY& p2,
const geom::CoordinateXY& p3);
void processSequence(const geom::CoordinateSequence& seq, bool isLinear);
bool
isOnSegment() const
{
return isPointOnSegment;
}
geom::Location getLocation() const;
bool isPointInPolygon() const;
std::size_t getCount() const { return crossingCount; };
static bool shouldCountCrossing(const geom::CircularArc& arc, const geom::CoordinateXY& q);
static std::array<geom::CoordinateXY, 2>
pointsIntersectingHorizontalRay(const geom::CircularArc& arc, const geom::CoordinateXY& origin);
};
} // geos::algorithm
} // geos
geos::algorithm::RayCrossingCounter::countSegment
void countSegment(const geom::CoordinateXY &p1, const geom::CoordinateXY &p2)
Counts a segment.
geos::algorithm::RayCrossingCounter::locatePointInRing
static geom::Location locatePointInRing(const geom::CoordinateXY &p, const geom::CoordinateSequence &ring)
Determines the Location of a point in a ring.
geos::algorithm::RayCrossingCounter::getLocation
geom::Location getLocation() const
Gets the Location of the point relative to the ring, polygon or multipolygon from which the processed...
geos::algorithm::RayCrossingCounter::locatePointInRing
static geom::Location locatePointInRing(const geom::CoordinateXY &p, const std::vector< const geom::Coordinate * > &ring)
Semantically equal to the above, just different args encoding.
geos::algorithm::RayCrossingCounter::isPointInPolygon
bool isPointInPolygon() const
Tests whether the point lies in or on the ring, polygon or multipolygon from which the processed segm...
geos::algorithm::RayCrossingCounter::isOnSegment
bool isOnSegment() const
Reports whether the point lies exactly on one of the supplied segments.
Definition RayCrossingCounter.h:135
geos::algorithm::RayCrossingCounter::processSequence
void processSequence(const geom::CoordinateSequence &seq, bool isLinear)
Counts all segments or arcs in the sequence.
geos::geom::CircularArc
Definition CircularArc.h:29
geos::geom::CoordinateSequence
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:56
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:217
geos::algorithm
Contains classes and interfaces implementing fundamental computational geometry algorithms.
Definition Angle.h:32
geos::geom
Definition Angle.h:26
geos::geom::Location
Location
Constants representing the location of a point relative to a geometry.
Definition Location.h:32
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38