FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
GeoJson.NET-Unity/PositionExtensions.cs at master · unitycoder/GeoJson.NET-Unity · GitHub
unitycoder
/
GeoJson.NET-Unity
Public
forked from
GeoJSON-Net/GeoJSON.Net
Notifications
You must be signed in to change notification settings
Fork
2
Star
3
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
GeoJson.NET-Unity
/
PositionExtensions.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
37 lines (36 loc) · 1.18 KB
Breadcrumbs
GeoJson.NET-Unity
/
PositionExtensions.cs
Copy path
File metadata and controls
executable file
·
37 lines (36 loc) · 1.18 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
using
System
;
using
System
.
Collections
.
Generic
;
using
GeoJSON
.
Net
.
Geometry
;
namespace
GeoJSON
.
Net
{
internal
static
class
PositionExtensions
{
internal
static
Position
ToPosition
(
this
IEnumerable
<
double
>
coordinates
)
{
using
(
var
enumerator
=
coordinates
.
GetEnumerator
(
)
)
{
double
lat
,
lng
,
alt
;
if
(
!
enumerator
.
MoveNext
(
)
)
{
throw
new
ArgumentException
(
"Expected 2 or 3 coordinates but got 0"
)
;
}
lng
=
enumerator
.
Current
;
if
(
!
enumerator
.
MoveNext
(
)
)
{
throw
new
ArgumentException
(
"Expected 2 or 3 coordinates but got 1"
)
;
}
lat
=
enumerator
.
Current
;
if
(
!
enumerator
.
MoveNext
(
)
)
{
return
new
Position
(
lat
,
lng
)
;
}
alt
=
enumerator
.
Current
;
if
(
enumerator
.
MoveNext
(
)
)
{
throw
new
ArgumentException
(
"Expected 2 or 3 coordinates but got >= 4"
)
;
}
return
new
Position
(
lat
,
lng
,
alt
)
;
}
}
}
}
Back
|
FazBrowse Home
|
New Git URL