FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
GeoJSON.Net/src/GeoJSON.Net/Geometry/Polygon.cs at master · deRightDirection/GeoJSON.Net · GitHub
deRightDirection
/
GeoJSON.Net
Public
forked from
GeoJSON-Net/GeoJSON.Net
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
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
/
src
/
GeoJSON.Net
/
Geometry
/
Polygon.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
99 lines (86 loc) · 3.45 KB
Breadcrumbs
GeoJSON.Net
/
src
/
GeoJSON.Net
/
Geometry
/
Polygon.cs
Copy path
File metadata and controls
99 lines (86 loc) · 3.45 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
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Polygon.cs" company="Joerg Battermann">
// Copyright © Joerg Battermann 2014
// </copyright>
// <summary>
// Defines the <see cref="http://geojson.org/geojson-spec.html#polygon">Polygon</see> type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
using
System
;
using
System
.
Collections
.
Generic
;
using
System
.
Linq
;
using
GeoJSON
.
Net
.
Converters
;
using
Newtonsoft
.
Json
;
namespace
GeoJSON
.
Net
.
Geometry
{
/// <summary>
/// Defines the <see cref="http://geojson.org/geojson-spec.html#polygon">Polygon</see> type.
/// Coordinates of a Polygon are a list of
/// <see cref="http://geojson.org/geojson-spec.html#linestring">linear rings</see>
/// coordinate arrays. The first element in the array represents the exterior ring. Any subsequent elements
/// represent interior rings (or holes).
/// </summary>
/// <seealso cref="http://geojson.org/geojson-spec.html#polygon" />
public
class
Polygon
:
GeoJSONObject
,
IGeometryObject
{
/// <summary>
/// Initializes a new instance of the <see cref="Polygon" /> class.
/// </summary>
/// <param name="coordinates">
/// The <see cref="http://geojson.org/geojson-spec.html#linestring">linear rings</see> with the first element
/// in the array representing the exterior ring. Any subsequent elements represent interior rings (or holes).
/// </param>
public
Polygon
(
List
<
LineString
>
coordinates
)
{
if
(
coordinates
==
null
)
{
throw
new
ArgumentNullException
(
"coordinates"
)
;
}
if
(
coordinates
.
Any
(
linearRing
=>
!
linearRing
.
IsLinearRing
(
)
)
)
{
throw
new
ArgumentException
(
"All elements must be closed LineStrings with 4 or more positions"
+
" (see GeoJSON spec at 'http://geojson.org/geojson-spec.html#linestring')."
,
"coordinates"
)
;
}
Coordinates
=
coordinates
;
Type
=
GeoJSONObjectType
.
Polygon
;
}
/// <summary>
/// Gets the list of points outlining this Polygon.
/// </summary>
[
JsonProperty
(
PropertyName
=
"coordinates"
,
Required
=
Required
.
Always
)
]
[
JsonConverter
(
typeof
(
PolygonConverter
)
)
]
public
List
<
LineString
>
Coordinates
{
get
;
set
;
}
public
override
bool
Equals
(
object
obj
)
{
if
(
ReferenceEquals
(
null
,
obj
)
)
{
return
false
;
}
if
(
ReferenceEquals
(
this
,
obj
)
)
{
return
true
;
}
if
(
obj
.
GetType
(
)
!=
GetType
(
)
)
{
return
false
;
}
return
Equals
(
(
Polygon
)
obj
)
;
}
public
override
int
GetHashCode
(
)
{
return
Coordinates
.
GetHashCode
(
)
;
}
public
static
bool
operator
==
(
Polygon
left
,
Polygon
right
)
{
return
Equals
(
left
,
right
)
;
}
public
static
bool
operator
!=
(
Polygon
left
,
Polygon
right
)
{
return
!
Equals
(
left
,
right
)
;
}
protected
bool
Equals
(
Polygon
other
)
{
return
base
.
Equals
(
other
)
&&
Coordinates
.
SequenceEqual
(
other
.
Coordinates
)
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL