LinearLocation.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2011 Sandro Santilli <strk@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: linearref/LinearLocation.java r463
*
**********************************************************************/
#pragma once
#include <string>
#include <memory> // for std::unique_ptr
#include <geos/geom/Coordinate.h>
#include <geos/geom/Geometry.h>
#include <geos/geom/LineSegment.h>
namespace geos {
namespace linearref { // geos::linearref
class LinearLocation {
private:
std::size_t componentIndex;
std::size_t segmentIndex;
double segmentFraction;
void normalize();
public:
static LinearLocation getEndLocation(const geom::Geometry* linear);
static geom::Coordinate pointAlongSegmentByFraction(const geom::Coordinate& p0, const geom::Coordinate& p1,
double frac);
LinearLocation(std::size_t segmentIndex = 0, double segmentFraction = 0.0);
LinearLocation(std::size_t componentIndex, std::size_t segmentIndex, double segmentFraction);
void clamp(const geom::Geometry* linear);
void snapToVertex(const geom::Geometry* linearGeom, double minDistance);
double getSegmentLength(const geom::Geometry* linearGeom) const;
void setToEnd(const geom::Geometry* linear);
std::size_t getComponentIndex() const;
std::size_t getSegmentIndex() const;
double getSegmentFraction() const;
bool isVertex() const;
geom::Coordinate getCoordinate(const geom::Geometry* linearGeom) const;
std::unique_ptr<geom::LineSegment> getSegment(const geom::Geometry* linearGeom) const;
bool isValid(const geom::Geometry* linearGeom) const;
int compareTo(const LinearLocation& other) const;
int compareLocationValues(std::size_t componentIndex1, std::size_t segmentIndex1, double segmentFraction1) const;
static int compareLocationValues(
std::size_t componentIndex0, std::size_t segmentIndex0, double segmentFraction0,
std::size_t componentIndex1, std::size_t segmentIndex1, double segmentFraction1);
bool isOnSameSegment(const LinearLocation& loc) const;
bool isEndpoint(const geom::Geometry& linearGeom) const;
friend std::ostream& operator<< (std::ostream& out, const LinearLocation& obj);
};
} // namespace geos.linearref
} // namespace geos
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::linearref::LinearLocation::getEndLocation
static LinearLocation getEndLocation(const geom::Geometry *linear)
Gets a location which refers to the end of a linear Geometry.
geos::linearref::LinearLocation::compareLocationValues
static int compareLocationValues(std::size_t componentIndex0, std::size_t segmentIndex0, double segmentFraction0, std::size_t componentIndex1, std::size_t segmentIndex1, double segmentFraction1)
Compares two sets of location values for order.
geos::linearref::LinearLocation::compareTo
int compareTo(const LinearLocation &other) const
Compares this object with the specified object for order.
geos::linearref::LinearLocation::isEndpoint
bool isEndpoint(const geom::Geometry &linearGeom) const
Tests whether this location is an endpoint of the linear component it refers to.
geos::linearref::LinearLocation::LinearLocation
LinearLocation(std::size_t segmentIndex=0, double segmentFraction=0.0)
Creates a location referring to the start of a linear geometry.
geos::linearref::LinearLocation::isOnSameSegment
bool isOnSameSegment(const LinearLocation &loc) const
Tests whether two locations are on the same segment in the parent Geometry.
geos::linearref::LinearLocation::getSegmentLength
double getSegmentLength(const geom::Geometry *linearGeom) const
Gets the length of the segment in the given Geometry containing this location.
geos::linearref::LinearLocation::isVertex
bool isVertex() const
Tests whether this location refers to a vertex.
geos::linearref::LinearLocation::getSegment
std::unique_ptr< geom::LineSegment > getSegment(const geom::Geometry *linearGeom) const
Gets a LineSegment representing the segment of the given linear Geometry which contains this location...
geos::linearref::LinearLocation::getSegmentIndex
std::size_t getSegmentIndex() const
Gets the segment index for this location.
geos::linearref::LinearLocation::setToEnd
void setToEnd(const geom::Geometry *linear)
Sets the value of this location to refer the end of a linear geometry.
geos::linearref::LinearLocation::getSegmentFraction
double getSegmentFraction() const
Gets the segment fraction for this location.
geos::linearref::LinearLocation::compareLocationValues
int compareLocationValues(std::size_t componentIndex1, std::size_t segmentIndex1, double segmentFraction1) const
Compares this object with the specified index values for order.
geos::linearref::LinearLocation::getCoordinate
geom::Coordinate getCoordinate(const geom::Geometry *linearGeom) const
Gets the Coordinate along the given linear Geometry which is referenced by this location.
geos::linearref::LinearLocation::isValid
bool isValid(const geom::Geometry *linearGeom) const
Tests whether this location refers to a valid location on the given linear Geometry.
geos::linearref::LinearLocation::snapToVertex
void snapToVertex(const geom::Geometry *linearGeom, double minDistance)
Snaps the value of this location to the nearest vertex on the given linear Geometry,...
geos::linearref::LinearLocation::clamp
void clamp(const geom::Geometry *linear)
Ensures the indexes are valid for a given linear Geometry.
geos::linearref::LinearLocation::pointAlongSegmentByFraction
static geom::Coordinate pointAlongSegmentByFraction(const geom::Coordinate &p0, const geom::Coordinate &p1, double frac)
Computes the Coordinate of a point a given fraction along the line segment (p0, p1).
geos::linearref::LinearLocation::getComponentIndex
std::size_t getComponentIndex() const
Gets the component index for this location.
geos::linearref
Contains classes and interfaces implementing linear referencing on linear geometries.
Definition ExtractLineByLocation.h:27
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38