Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
geometry/test/algorithms/is_simple_geo.cpp at develop · boostorg/geometry · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
boostorg
geometry
Repository navigation
Code
Issues
146
(146)
Pull requests
16
(16)
Discussions
Actions
Projects
Wiki
Security and quality
Insights
More
items
Files
Expand file tree
develop
Breadcrumbs
geometry
/
test
/
algorithms
/
is_simple_geo.cpp
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
128 lines (99 loc) · 5.99 KB
develop
Breadcrumbs
geometry
/
test
/
algorithms
/
is_simple_geo.cpp
Copy path
Top
File metadata and controls
Code
Blame
128 lines (99 loc) · 5.99 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//
Boost.Geometry (aka GGL, Generic Geometry Library)
//
Unit Test
//
Copyright (c) 2014-2017, Oracle and/or its affiliates.
//
Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
//
Licensed under the Boost Software License version 1.0.
//
http://www.boost.org/users/license.html
#
ifndef
BOOST_TEST_MODULE
#
define
BOOST_TEST_MODULE
test_is_simple_geo
#
endif
#
include
"
test_is_simple.hpp
"
inline
bg::srs::spheroid<
double
>
sph
(
double
a,
double
rf)
{
double
b = a - a / rf;
return
bg::srs::spheroid<
double
>(a, b);
}
typedef
bg::model::point<
double
,
2
, bg::cs::geographic<bg::degree> > point_type;
typedef
bg::model::segment<point_type> segment_type;
typedef
bg::model::linestring<point_type> linestring_type;
typedef
bg::model::multi_linestring<linestring_type> multi_linestring_type;
//
ccw open and closed polygons
typedef
bg::model::polygon<point_type,
false
,
false
> open_ccw_polygon_type;
typedef
bg::model::polygon<point_type,
false
,
true
> closed_ccw_polygon_type;
//
multi-geometries
typedef
bg::model::multi_point<point_type> multi_point_type;
typedef
bg::model::multi_polygon<open_ccw_polygon_type> multi_polygon_type;
//
box
typedef
bg::model::box<point_type> box_type;
BOOST_AUTO_TEST_CASE
( test_is_simple_geo_multipoint )
{
typedef
multi_point_type G;
bg::strategy::intersection::geographic_segments<> s;
test_simple_s
(from_wkt<G>(
"
MULTIPOINT(0 90, 0 90)
"
), s,
false
);
test_simple_s
(from_wkt<G>(
"
MULTIPOINT(0 90, 1 90)
"
), s,
false
);
test_simple_s
(from_wkt<G>(
"
MULTIPOINT(0 -90, 0 -90)
"
), s,
false
);
test_simple_s
(from_wkt<G>(
"
MULTIPOINT(0 -90, 1 -90)
"
), s,
false
);
test_simple_s
(from_wkt<G>(
"
MULTIPOINT(0 80, 1 80)
"
), s,
true
);
}
BOOST_AUTO_TEST_CASE
( test_is_simple_geo_linestring )
{
typedef
linestring_type G;
bg::srs::spheroid<
double
> sph_wgs84;
bg::srs::spheroid<
double
>
sph_4053
(
6371228
,
6371228
);
bg::srs::spheroid<
double
>
sph_near_4053
(
6371228
,
6371227
);
bg::strategy::intersection::geographic_segments<>
s
(sph_wgs84);
bg::strategy::intersection::geographic_segments<>
s_4053
(sph_4053);
bg::strategy::intersection::geographic_segments<>
s_near_4053
(sph_near_4053);
//
Two cases which in Cartesian would be a spike, but in Geographic
//
they go over the equator (first segment) and then over the pole
//
(second segment)
test_simple_s
(from_wkt<G>(
"
LINESTRING(0 0, -90 0, 90 0)
"
), s,
true
);
test_simple_s
(from_wkt<G>(
"
LINESTRING(0 0, 90 0, -90 0)
"
), s,
true
);
//
Two similar cases, but these do not go over the pole back, but
//
over the equator, and therefore make a spike
test_simple_s
(from_wkt<G>(
"
LINESTRING(0 0, -80 0, 80 0)
"
), s,
false
);
test_simple_s
(from_wkt<G>(
"
LINESTRING(0 0, 80 0, -80 0)
"
), s,
false
);
//
Going over the equator in a normal way, eastwards and westwards
test_simple_s
(from_wkt<G>(
"
LINESTRING(-90 0, 0 0, 90 0)
"
), s,
true
);
test_simple_s
(from_wkt<G>(
"
LINESTRING(90 0, 0 0, -90 0)
"
), s,
true
);
test_simple_s
(from_wkt<G>(
"
LINESTRING(0 90, -90 0, 90 0)
"
), s,
false
);
test_simple_s
(from_wkt<G>(
"
LINESTRING(0 90, -90 50, 90 0)
"
), s,
false
);
test_simple_s
(from_wkt<G>(
"
LINESTRING(0 90, -90 -50, 90 0)
"
), s,
true
);
//
invalid linestrings
test_simple_s
(from_wkt<G>(
"
LINESTRING(0 90, 0 90)
"
), s,
false
,
false
);
test_simple_s
(from_wkt<G>(
"
LINESTRING(0 -90, 0 -90)
"
), s,
false
,
false
);
test_simple_s
(from_wkt<G>(
"
LINESTRING(0 90, 1 90)
"
), s,
false
,
false
);
test_simple_s
(from_wkt<G>(
"
LINESTRING(0 -90, 1 -90)
"
), s,
false
,
false
);
//
FAILING
//
test_simple_s(from_wkt<G>("LINESTRING(0 90, 0 80, 1 80, 0 90)"), s, false);
//
test_simple_s(from_wkt<G>("LINESTRING(0 -90, 0 -80, 1 -80, 0 -90)"), s, false);
//
test_simple_s(from_wkt<G>("LINESTRING(0 90, 0 80, 1 80, 1 90)"), s, false);
//
test_simple_s(from_wkt<G>("LINESTRING(0 -90, 0 -80, 1 -80, 1 -90)"), s, false);
test_simple_s
(from_wkt<G>(
"
LINESTRING(35 0, 110 36, 159 0, 82 30)
"
), s,
false
);
test_simple_s
(from_wkt<G>(
"
LINESTRING(135 0, -150 36, -101 0, -178 30)
"
), s,
false
);
test_simple_s
(from_wkt<G>(
"
LINESTRING(45 0, 120 36, 169 0, 92 30)
"
), s,
false
);
test_simple_s
(from_wkt<G>(
"
LINESTRING(179 0, -179 1, -179 0, 179 1)
"
), s,
false
);
test_simple_s
(from_wkt<G>(
"
LINESTRING(-121 -19,37 8,-19 -15,-104 -58)
"
), s,
false
);
test_simple_s
(from_wkt<G>(
"
LINESTRING(-121 -19,37 8,-19 -15,-104 -58)
"
), s_4053,
false
);
test_simple_s
(from_wkt<G>(
"
LINESTRING(-121 -19,37 8,-19 -15,-104 -58)
"
), s_near_4053,
false
);
//
The segments are very close to each other, in WGS84 they cross,
//
in spherical or nearly spherical they don't cross
test_simple_s
(from_wkt<G>(
"
LINESTRING(106 22,21 39,40 -12,-91 68)
"
), s,
false
);
test_simple_s
(from_wkt<G>(
"
LINESTRING(106 22,21 39,40 -12,-91 68)
"
), s_4053,
true
);
test_simple_s
(from_wkt<G>(
"
LINESTRING(106 22,21 39,40 -12,-91 68)
"
), s_near_4053,
true
);
}
BOOST_AUTO_TEST_CASE
( test_is_simple_geo_multilinestring )
{
typedef
multi_linestring_type G;
bg::strategy::intersection::geographic_segments<> s_wgs84;
//
EPSG 4326
bg::strategy::intersection::geographic_segments<>
s_bessel
((
sph
(
6377397.155
,
299.1528128
)));
//
EPSG 4804, 4813, 4820
//
FAILING
//
test_simple_s(from_wkt<G>("MULTILINESTRING((0 90, 0 80),(1 90, 1 80))"), s_wgs84, false);
//
test_simple_s(from_wkt<G>("MULTILINESTRING((0 -90, 0 -80),(1 -90, 1 -80))"), s_wgs84, false);
test_simple_s
(from_wkt<G>(
"
MULTILINESTRING((35 0, 110 36),(159 0, 82 30))
"
), s_wgs84,
false
);
test_simple_s
(from_wkt<G>(
"
MULTILINESTRING((135 0, -150 36),(-101 0, -178 30))
"
), s_wgs84,
false
);
test_simple_s
(from_wkt<G>(
"
MULTILINESTRING((45 0, 120 36),(169 0, 92 30))
"
), s_wgs84,
false
);
test_simple_s
(from_wkt<G>(
"
MULTILINESTRING((179 0, -179 1),(-179 0, 179 1))
"
), s_wgs84,
false
);
test_simple_s
(from_wkt<G>(
"
MULTILINESTRING((35 2,110 36),(72 51,67 28,16 53,159 3,82 30))
"
), s_wgs84,
false
);
test_simple_s
(from_wkt<G>(
"
MULTILINESTRING((35 2,110 36),(72 51,67 28,16 53,159 3,82 30))
"
), s_bessel,
false
);
}
You can’t perform that action at this time.