forked from yocontra/node-gdal-next
-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
4,693 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
/********************************************************************** | ||
* | ||
* GEOS - Geometry Engine Open Source | ||
* http://geos.osgeo.org | ||
* | ||
* Copyright (C) 2021 Paul Ramsey <[email protected]> | ||
* | ||
* 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/geom/Envelope.h> | ||
#include <geos/simplify/LinkedLine.h> | ||
#include <geos/export.h> | ||
|
||
#include <vector> | ||
#include <memory> | ||
#include <queue> | ||
|
||
namespace geos { | ||
namespace simplify { | ||
class LinkedLine; | ||
} | ||
namespace geom { | ||
class Coordinate; | ||
class LineString; | ||
} | ||
} | ||
|
||
|
||
using geos::geom::Coordinate; | ||
using geos::geom::Envelope; | ||
using geos::geom::LineString; | ||
using geos::simplify::LinkedLine; | ||
|
||
|
||
namespace geos { | ||
namespace coverage { // geos::coverage | ||
|
||
|
||
class Corner | ||
{ | ||
|
||
public: | ||
|
||
Corner(const LinkedLine* edge, std::size_t i); | ||
|
||
bool isVertex(std::size_t index) const; | ||
|
||
inline std::size_t getIndex() const { | ||
return m_index; | ||
} | ||
|
||
inline double getArea() const { | ||
return m_area; | ||
}; | ||
|
||
const Coordinate& prev() const; | ||
const Coordinate& next() const; | ||
|
||
Envelope envelope() const; | ||
|
||
bool isVertex(const Coordinate& v) const; | ||
bool isBaseline(const Coordinate& p0, const Coordinate& p1) const; | ||
bool intersects(const Coordinate& v) const; | ||
bool isRemoved() const; | ||
|
||
const Coordinate& getCoordinate() { | ||
return m_edge->getCoordinate(m_index); | ||
} | ||
|
||
std::unique_ptr<LineString> toLineString() const; | ||
|
||
inline int compareTo(const Corner& rhs) const { | ||
double area_lhs = getArea(); | ||
double area_rhs = rhs.getArea(); | ||
|
||
if (area_lhs == area_rhs) { | ||
std::size_t index_lhs = getIndex(); | ||
std::size_t index_rhs = rhs.getIndex(); | ||
if (index_lhs == index_rhs) return 0; | ||
else return index_lhs < index_rhs ? -1 : 1; | ||
} | ||
else | ||
return area_lhs < area_rhs ? -1 : 1; | ||
} | ||
|
||
bool operator< (const Corner& rhs) const { | ||
return compareTo(rhs) < 0; | ||
}; | ||
|
||
bool operator> (const Corner& rhs) const { | ||
return compareTo(rhs) > 0; | ||
}; | ||
|
||
bool operator==(const Corner& rhs) const { | ||
return compareTo(rhs) == 0; | ||
}; | ||
|
||
struct Greater { | ||
inline bool operator()(const Corner & a, const Corner & b) const { | ||
return a.compareTo(b) > 0; | ||
} | ||
}; | ||
|
||
// Order using greater for compatibility with the Java PriorityQueue | ||
// implementation, which returns the smallest item off the top of the | ||
// queue | ||
using PriorityQueue = std::priority_queue<Corner, std::vector<Corner>, Corner::Greater>; | ||
|
||
|
||
private: | ||
|
||
// members | ||
const LinkedLine* m_edge; | ||
std::size_t m_index; | ||
std::size_t m_prev; | ||
std::size_t m_next; | ||
double m_area; | ||
|
||
// methods | ||
static double area(const LinkedLine& edge, std::size_t index); | ||
|
||
}; // Corner | ||
|
||
|
||
|
||
GEOS_DLL std::ostream& operator<< (std::ostream& os, const Corner& c); | ||
|
||
|
||
} // geos::coverage | ||
} // geos |
83 changes: 83 additions & 0 deletions
83
deps/libgeos/geos/include/geos/coverage/CoverageBoundarySegmentFinder.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/********************************************************************** | ||
* | ||
* GEOS - Geometry Engine Open Source | ||
* http://geos.osgeo.org | ||
* | ||
* Copyright (C) 2021 Paul Ramsey <[email protected]> | ||
* | ||
* 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 <unordered_set> | ||
|
||
#include <geos/geom/CoordinateSequenceFilter.h> | ||
#include <geos/geom/Coordinate.h> | ||
#include <geos/geom/LineSegment.h> | ||
#include <geos/export.h> | ||
|
||
namespace geos { | ||
namespace geom { | ||
class CoordinateSequence; | ||
class Geometry; | ||
} | ||
} | ||
|
||
using geos::geom::Coordinate; | ||
using geos::geom::CoordinateSequence; | ||
using geos::geom::CoordinateSequenceFilter; | ||
using geos::geom::Geometry; | ||
using geos::geom::LineSegment; | ||
|
||
namespace geos { | ||
namespace coverage { // geos::coverage | ||
|
||
class CoverageBoundarySegmentFinder : public CoordinateSequenceFilter | ||
{ | ||
|
||
|
||
public: | ||
|
||
CoverageBoundarySegmentFinder(LineSegment::UnorderedSet& segs) | ||
: m_boundarySegs(segs) | ||
{}; | ||
|
||
bool isGeometryChanged() const override { | ||
return false; | ||
} | ||
|
||
bool isDone() const override { | ||
return false; | ||
} | ||
|
||
void filter_ro(const CoordinateSequence& seq, std::size_t i) override; | ||
|
||
|
||
static LineSegment::UnorderedSet | ||
findBoundarySegments(const std::vector<const Geometry*>& geoms); | ||
|
||
static bool isBoundarySegment( | ||
const LineSegment::UnorderedSet& boundarySegs, | ||
const CoordinateSequence* seq, | ||
std::size_t i); | ||
|
||
private: | ||
|
||
static LineSegment | ||
createSegment(const CoordinateSequence& seq, std::size_t i); | ||
|
||
|
||
LineSegment::UnorderedSet& m_boundarySegs; | ||
|
||
|
||
}; // CoverageBoundarySegmentFinder | ||
|
||
|
||
|
||
} // geos::coverage | ||
} // geos |
Oops, something went wrong.