RelatePointLocator.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (c) 2024 Martin Davis
* Copyright (C) 2024 Paul Ramsey <pramsey@cleverelephant.ca>
*
* 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.
*
**********************************************************************/
#pragma once
#include <geos/algorithm/BoundaryNodeRule.h>
#include <geos/algorithm/locate/PointOnGeometryLocator.h>
#include <geos/operation/relateng/AdjacentEdgeLocator.h>
#include <geos/operation/relateng/LinearBoundary.h>
#include <geos/geom/Coordinate.h>
#include <geos/geom/Location.h>
#include <geos/export.h>
#include <memory>
#include <vector>
// Forward declarations
namespace geos {
namespace algorithm {
namespace locate {
// class PointOnGeometryLocator;
}
}
namespace operation {
namespace relateng {
// class LinearBoundary;
// class AdjacentEdgeLocator;
}
}
namespace geom {
class CoordinateXY;
class Geometry;
class LineString;
class Point;
}
}
namespace geos { // geos.
namespace operation { // geos.operation
namespace relateng { // geos.operation.relateng
class GEOS_DLL RelatePointLocator {
using BoundaryNodeRule = geos::algorithm::BoundaryNodeRule;
using PointOnGeometryLocator = geos::algorithm::locate::PointOnGeometryLocator;
using Coordinate = geos::geom::Coordinate;
using CoordinateXY = geos::geom::CoordinateXY;
using Geometry = geos::geom::Geometry;
using LineString = geos::geom::LineString;
using Point = geos::geom::Point;
using Location = geos::geom::Location;
private:
// Members
const Geometry* geom;
bool isPrepared = false;
const BoundaryNodeRule& boundaryRule;
std::unique_ptr<AdjacentEdgeLocator> adjEdgeLocator;
Coordinate::ConstXYSet points;
std::vector<const LineString *> lines;
std::vector<const Geometry *> polygons;
std::vector<std::unique_ptr<PointOnGeometryLocator>> polyLocator;
std::unique_ptr<LinearBoundary> lineBoundary;
bool isEmpty;
public:
// Constructors
RelatePointLocator(const Geometry* p_geom)
: RelatePointLocator(p_geom, false, BoundaryNodeRule::getBoundaryRuleMod2())
{};
RelatePointLocator(const Geometry* p_geom, bool p_isPrepared, const BoundaryNodeRule& p_bnRule)
: geom(p_geom)
, isPrepared(p_isPrepared)
, boundaryRule(p_bnRule)
{
init(geom);
};
void init(const Geometry* p_geom);
bool hasBoundary() const;
void extractElements(const Geometry* geom);
void addPoint(const Point* pt);
void addLine(const LineString* line);
void addPolygonal(const Geometry* polygonal);
Location locate(const CoordinateXY* p);
int locateLineEndWithDim(const CoordinateXY* p);
/*
* Locates a point which is known to be a node of the geometry
* (i.e. a vertex or on an edge).
*
* @param p the node point to locate
* @param parentPolygonal the polygon the point is a node of
* @return the location of the node point
*/
Location locateNode(const CoordinateXY* p, const Geometry* parentPolygonal);
int locateNodeWithDim(const CoordinateXY* p, const Geometry* parentPolygonal);
int locateWithDim(const CoordinateXY* p);
private:
// Methods
int locateWithDim(const CoordinateXY* p, bool isNode, const Geometry* parentPolygonal);
int computeDimLocation(const CoordinateXY* p, bool isNode, const Geometry* parentPolygonal);
Location locateOnPoints(const CoordinateXY* p) const;
Location locateOnLines(const CoordinateXY* p, bool isNode);
Location locateOnLine(const CoordinateXY* p, /*bool isNode,*/ const LineString* l);
Location locateOnPolygons(const CoordinateXY* p, bool isNode, const Geometry* parentPolygonal);
Location locateOnPolygonal(const CoordinateXY* p,
bool isNode,
const Geometry* parentPolygonal,
std::size_t index);
PointOnGeometryLocator * getLocator(std::size_t index);
};
} // namespace geos.operation.relateng
} // namespace geos.operation
} // namespace geos
geos::algorithm::BoundaryNodeRule
An interface for rules which determine whether node points which are in boundaries of lineal geometry...
Definition BoundaryNodeRule.h:52
geos::algorithm::BoundaryNodeRule::getBoundaryRuleMod2
static const BoundaryNodeRule & getBoundaryRuleMod2()
The Mod-2 Boundary Node Rule (which is the rule specified in the OGC SFS).
geos::algorithm::locate::PointOnGeometryLocator
An interface for classes which determine the Location of points in Polygon or MultiPolygon geometries...
Definition PointOnGeometryLocator.h:36
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:217
geos::geom::Geometry
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:196
geos::geom::LineString
Definition LineString.h:66
geos::geom::Point
Definition Point.h:61
geos::operation::relateng::RelatePointLocator::locateNodeWithDim
int locateNodeWithDim(const CoordinateXY *p, const Geometry *parentPolygonal)
geos::operation::relateng::RelatePointLocator::locateWithDim
int locateWithDim(const CoordinateXY *p)
geos::algorithm::locate
Classes which determine the Location of points in geometries.
Definition IndexedPointInAreaLocator.h:40
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::index
Provides classes for various kinds of spatial indexes.
Definition CleanCoverage.h:39
geos::operation
Provides classes for implementing operations on geometries.
Definition CleanCoverage.h:34
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38