TaggedLineStringSimplifier.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 Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************
*
* Last port: simplify/TaggedLineStringSimplifier.java r536 (JTS-1.12+)
*
**********************************************************************
*
* NOTES: This class can be optimized to work with vector<Coordinate*>
* rather then with CoordinateSequence
*
**********************************************************************/
#pragma once
#include <geos/export.h>
#include <cstddef>
#include <vector>
#include <memory>
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
#endif
// Forward declarations
namespace geos {
namespace algorithm {
class LineIntersector;
}
namespace geom {
class CoordinateSequence;
class Coordinate;
class LineSegment;
}
namespace simplify {
class TaggedLineSegment;
class TaggedLineString;
class LineSegmentIndex;
class ComponentJumpChecker;
}
}
namespace geos {
namespace simplify { // geos::simplify
class GEOS_DLL TaggedLineStringSimplifier {
using CoordinateSequence = geos::geom::CoordinateSequence;
using Coordinate = geos::geom::Coordinate;
using LineSegment = geos::geom::LineSegment;
public:
TaggedLineStringSimplifier(LineSegmentIndex* inputIndex,
LineSegmentIndex* outputIndex,
const ComponentJumpChecker* jumpChecker);
void simplify(TaggedLineString* line, double distanceTolerance);
private:
// externally owned
LineSegmentIndex* inputIndex;
// externally owned
LineSegmentIndex* outputIndex;
const ComponentJumpChecker* jumpChecker;
std::unique_ptr<algorithm::LineIntersector> li;
TaggedLineString* line;
const CoordinateSequence* linePts;
void simplifySection(std::size_t i, std::size_t j, std::size_t depth, double distanceTolerance);
void simplifyRingEndpoint(double distanceTolerance);
static std::size_t findFurthestPoint(
const CoordinateSequence* pts,
std::size_t i, std::size_t j,
double& maxDistance);
bool isTopologyValid(
const TaggedLineString* lineIn,
std::size_t sectionStart, std::size_t sectionEnd,
const LineSegment& flatSeg);
bool isTopologyValid(
const TaggedLineString* lineIn,
const LineSegment* seg1, const LineSegment* seg2,
const LineSegment& flatSeg);
bool hasInputIntersection(const LineSegment& flatSeg);
bool hasInputIntersection(
const TaggedLineString* lineIn,
std::size_t excludeStart, std::size_t excludeEnd,
const LineSegment& flatSeg);
bool isCollinear(const Coordinate& pt, const LineSegment& seg) const;
bool hasOutputIntersection(const LineSegment& flatSeg);
bool hasInvalidIntersection(
const LineSegment& seg0,
const LineSegment& seg1) const;
std::unique_ptr<TaggedLineSegment> flatten(
std::size_t start, std::size_t end);
static bool isInLineSection(
const TaggedLineString* line,
const std::size_t excludeStart, const std::size_t excludeEnd,
const TaggedLineSegment* seg);
void remove(const TaggedLineString* line,
std::size_t start,
std::size_t end);
};
} // namespace geos::simplify
} // namespace geos
#ifdef _MSC_VER
#pragma warning(pop)
#endif
geos::algorithm::LineIntersector
A LineIntersector is an algorithm that can both test whether two line segments intersect and compute ...
Definition LineIntersector.h:53
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::geom::LineSegment
Definition LineSegment.h:61
geos::simplify::TaggedLineSegment
A geom::LineSegment which is tagged with its location in a geom::Geometry.
Definition TaggedLineSegment.h:53
geos::simplify::TaggedLineStringSimplifier::simplify
void simplify(TaggedLineString *line, double distanceTolerance)
geos::simplify::TaggedLineString
Contains and owns a list of TaggedLineSegments.
Definition TaggedLineString.h:57
geos::algorithm
Contains classes and interfaces implementing fundamental computational geometry algorithms.
Definition Angle.h:32
geos::geom
Definition Angle.h:26
geos::simplify
Classes which implement algorithms for simplifying or generalizing geometries.
Definition Corner.h:26
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38