Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fishnet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lorenz Gruber
fishnet
Commits
e8c85777
Commit
e8c85777
authored
4 months ago
by
Lorenz Gruber
Browse files
Options
Downloads
Patches
Plain Diff
adding distance functions for different coordinate systems
parent
d0863b45
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/sda-workflow/src/shared/neighbourPredicates/DistanceBiPredicate.hpp
+31
-5
31 additions, 5 deletions
...ow/src/shared/neighbourPredicates/DistanceBiPredicate.hpp
with
31 additions
and
5 deletions
app/sda-workflow/src/shared/neighbourPredicates/DistanceBiPredicate.hpp
+
31
−
5
View file @
e8c85777
...
...
@@ -5,18 +5,44 @@
/**
* @brief Distance BiPredicate Functor.
* Emits true if the distance between the two shapes is less or equal to the maximum distance.
*
Uses WGS84Ellipsoid
distance between
the
two
closest points of the two shapes
* Emits true if the distance between the two shapes is less or equal to the maximum distance
(in meters)
.
*
@tparam DistanceFunction type determining how to calculate the
distance between two
points in meters.
*/
template
<
fishnet
::
util
::
BiFunction
<
fishnet
::
geometry
::
Vec2DReal
,
fishnet
::
geometry
::
Vec2DReal
,
fishnet
::
math
::
DEFAULT_FLOATING_POINT
>
DistanceFunction
>
struct
DistanceBiPredicate
{
DistanceFunction
distanceFunction
;
double
maxDistanceInMeters
;
bool
operator
()(
fishnet
::
geometry
::
Shape
auto
const
&
lhs
,
fishnet
::
geometry
::
Shape
auto
const
&
rhs
)
const
noexcept
{
auto
[
l
,
r
]
=
fishnet
::
geometry
::
closestPoints
(
lhs
,
rhs
);
return
l
==
r
||
f
is
hnet
::
WGS84Ellipsoid
::
distance
(
l
,
r
)
<=
maxDistanceInMeters
;
}
return
l
==
r
||
d
is
tanceFunction
(
l
,
r
)
<=
maxDistanceInMeters
;
}
static
NeighbouringPredicateType
type
()
{
return
NeighbouringPredicateType
::
DistanceBiPredicate
;
}
};
\ No newline at end of file
};
struct
WGS84Distance
{
static
auto
operator
()(
const
fishnet
::
geometry
::
Vec2DReal
&
lhs
,
const
fishnet
::
geometry
::
Vec2DReal
&
rhs
)
noexcept
{
return
fishnet
::
WGS84Ellipsoid
::
distance
(
lhs
,
rhs
);
}
};
struct
MetricDistance
{
static
auto
operator
()(
const
fishnet
::
geometry
::
Vec2DReal
&
lhs
,
const
fishnet
::
geometry
::
Vec2DReal
&
rhs
)
noexcept
{
return
lhs
.
distance
(
rhs
);
}
};
using
DistanceFunction
=
std
::
function
<
fishnet
::
math
::
DEFAULT_FLOATING_POINT
(
const
fishnet
::
geometry
::
Vec2DReal
&
,
const
fishnet
::
geometry
::
Vec2DReal
&
)
>
;
static
DistanceFunction
distanceFunctionForSpatialReference
(
const
OGRSpatialReference
&
spatialRef
)
{
if
(
spatialRef
.
IsEmpty
())
throw
std
::
runtime_error
(
"No distance function available for empty coordinate system"
);
if
(
spatialRef
.
IsLocal
()
||
spatialRef
.
IsProjected
())
return
MetricDistance
();
if
(
spatialRef
.
IsGeographic
())
return
WGS84Distance
();
throw
std
::
runtime_error
(
"No distance function found for coordinate system:
\"
"
+
std
::
string
(
spatialRef
.
GetName
())
+
"
\"
"
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment