forked from libgeos/geos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CoveragePolygonValidator section perf optimization
- Loading branch information
Showing
6 changed files
with
216 additions
and
89 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/********************************************************************** | ||
* | ||
* GEOS - Geometry Engine Open Source | ||
* http://geos.osgeo.org | ||
* | ||
* Copyright (C) 2024 Martin Davis <mtnclimb@gmail.com> | ||
* | ||
* 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/locate/IndexedPointInAreaLocator.h> | ||
|
||
// Forward declarations | ||
namespace geos { | ||
namespace geom { | ||
class Coordinate; | ||
class Envelope; | ||
class Polygon; | ||
} | ||
} | ||
|
||
using geos::geom::Coordinate; | ||
using geos::geom::Envelope; | ||
using geos::geom::Polygon; | ||
using geos::algorithm::locate::IndexedPointInAreaLocator; | ||
|
||
namespace geos { // geos | ||
namespace coverage { // geos::coverage | ||
|
||
class GEOS_DLL CoveragePolygon { | ||
|
||
// Members | ||
const Polygon* polygon; | ||
Envelope polyEnv; | ||
std::unique_ptr<IndexedPointInAreaLocator> locator; | ||
|
||
public: | ||
CoveragePolygon(const Polygon* poly); | ||
|
||
bool intersectsEnv(const Envelope env); | ||
bool intersectsEnv(const Coordinate p); | ||
bool contains(const Coordinate p); | ||
|
||
private: | ||
IndexedPointInAreaLocator* getLocator(); | ||
|
||
}; | ||
|
||
} // namespace geos::coverage | ||
} // namespace geos | ||
|
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
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,76 @@ | ||
/********************************************************************** | ||
* | ||
* GEOS - Geometry Engine Open Source | ||
* http://geos.osgeo.org | ||
* | ||
* Copyright (C) 2024 Martin Davis <mtnclimb@gmail.com> | ||
* | ||
* 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. | ||
* | ||
**********************************************************************/ | ||
|
||
#include <geos/coverage/CoveragePolygon.h> | ||
|
||
#include <geos/geom/Coordinate.h> | ||
#include <geos/geom/Envelope.h> | ||
#include <geos/geom/Location.h> | ||
#include <geos/geom/Polygon.h> | ||
|
||
using geos::algorithm::locate::IndexedPointInAreaLocator; | ||
using geos::geom::Coordinate; | ||
using geos::geom::Envelope; | ||
using geos::geom::Location; | ||
using geos::geom::Polygon; | ||
|
||
namespace geos { // geos | ||
namespace coverage { // geos.coverage | ||
|
||
/* public */ | ||
CoveragePolygon::CoveragePolygon(const Polygon* poly) | ||
: polygon(poly) | ||
{ | ||
polyEnv = *(poly->getEnvelopeInternal()); | ||
} | ||
|
||
/* public */ | ||
bool | ||
CoveragePolygon::intersectsEnv(const Envelope env) | ||
{ | ||
return polyEnv.intersects(env); | ||
} | ||
|
||
/* public */ | ||
bool | ||
CoveragePolygon::intersectsEnv(const Coordinate p) | ||
{ | ||
return polyEnv.intersects(p); | ||
} | ||
|
||
/* public */ | ||
bool | ||
CoveragePolygon::contains(const Coordinate p) | ||
{ | ||
if (! intersectsEnv(p)) | ||
return false; | ||
IndexedPointInAreaLocator* pia = getLocator(); | ||
return Location::INTERIOR == pia->locate(&p); | ||
} | ||
|
||
/* private */ | ||
IndexedPointInAreaLocator* | ||
CoveragePolygon::getLocator() | ||
{ | ||
if (locator == nullptr) { | ||
//locator = std::make_unique<IndexedPointInAreaLocator>(new IndexedPointInAreaLocator(*polygon)); | ||
locator = std::unique_ptr<IndexedPointInAreaLocator>(new IndexedPointInAreaLocator(*polygon)); | ||
} | ||
return locator.get(); | ||
} | ||
|
||
} // namespace geos.coverage | ||
} // namespace geos | ||
|
||
|
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
Oops, something went wrong.