FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
GeoJSON.Net/src/GeoJSON.Net/GeoJSONObject.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
/
GeoJSONObject.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
217 lines (196 loc) · 7.6 KB
Breadcrumbs
GeoJSON.Net
/
src
/
GeoJSON.Net
/
GeoJSONObject.cs
Copy path
File metadata and controls
217 lines (196 loc) · 7.6 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="GeoJSONObject.cs" company="Joerg Battermann">
// Copyright © Joerg Battermann 2014
// </copyright>
// <summary>
// Defines the GeoJSONObject type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
using
System
.
Linq
;
using
System
.
Runtime
.
Serialization
;
using
GeoJSON
.
Net
.
Converters
;
using
GeoJSON
.
Net
.
CoordinateReferenceSystem
;
using
GeoJSON
.
Net
.
Geometry
;
using
Newtonsoft
.
Json
;
using
Newtonsoft
.
Json
.
Converters
;
namespace
GeoJSON
.
Net
{
/// <summary>
/// Base class for all IGeometryObject implementing types
/// </summary>
[
JsonObject
(
MemberSerialization
.
OptIn
)
]
public
abstract
class
GeoJSONObject
:
IGeoJSONObject
{
internal
static
readonly
DoubleTenDecimalPlaceComparer
DoubleComparer
=
new
DoubleTenDecimalPlaceComparer
(
)
;
protected
GeoJSONObject
(
)
{
CRS
=
DefaultCRS
.
Instance
;
}
/// <summary>
/// Gets or sets the (optional)
/// <see cref="http://geojson.org/geojson-spec.html#coordinate-reference-system-objects">Bounding Boxes</see>.
/// </summary>
/// <value>
/// The value of <see cref="BoundingBoxes" /> must be a 2*n array where n is the number of dimensions represented in
/// the
/// contained geometries, with the lowest values for all axes followed by the highest values.
/// The axes order of a bbox follows the axes order of geometries.
/// In addition, the coordinate reference system for the bbox is assumed to match the coordinate reference
/// system of the GeoJSON object of which it is a member.
/// </value>
[
JsonProperty
(
PropertyName
=
"bbox"
,
Required
=
Required
.
Default
,
NullValueHandling
=
NullValueHandling
.
Ignore
)
]
public
double
[
]
BoundingBoxes
{
get
;
set
;
}
/// <summary>
/// Gets or sets the (optional)
/// <see cref="http://geojson.org/geojson-spec.html#coordinate-reference-system-objects">
/// Coordinate Reference System
/// Object.
/// </see>
/// </summary>
/// <value>
/// The Coordinate Reference System Objects.
/// </value>
[
JsonProperty
(
PropertyName
=
"crs"
,
Required
=
Required
.
Default
,
DefaultValueHandling
=
DefaultValueHandling
.
IgnoreAndPopulate
,
NullValueHandling
=
NullValueHandling
.
Include
)
]
[
JsonConverter
(
typeof
(
CrsConverter
)
)
]
//[DefaultValue(typeof(DefaultCRS), "")]
public
ICRSObject
CRS
{
get
;
set
;
}
/// <summary>
/// Gets the (mandatory) type of the
/// <see cref="http://geojson.org/geojson-spec.html#geojson-objects">GeoJSON Object</see>.
/// </summary>
/// <value>
/// The type of the object.
/// </value>
[
JsonProperty
(
PropertyName
=
"type"
,
Required
=
Required
.
Always
)
]
[
JsonConverter
(
typeof
(
StringEnumConverter
)
)
]
public
GeoJSONObjectType
Type
{
get
;
internal
set
;
}
/// <summary>
/// Determines whether the specified <see cref="System.Object" />, is equal to this instance.
/// </summary>
/// <param name="obj">The <see cref="System.Object" /> to compare with this instance.</param>
/// <returns>
/// <c>true</c> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <c>false</c>.
/// </returns>
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
(
(
GeoJSONObject
)
obj
)
;
}
/// <summary>
/// Returns a hash code for this instance.
/// </summary>
/// <returns>
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
/// </returns>
public
override
int
GetHashCode
(
)
{
unchecked
{
var
hashCode
=
(
BoundingBoxes
!=
null
?
BoundingBoxes
.
GetHashCode
(
)
:
0
)
;
hashCode
=
(
hashCode
*
397
)
^
(
CRS
!=
null
?
CRS
.
GetHashCode
(
)
:
0
)
;
hashCode
=
(
hashCode
*
397
)
^
(
int
)
Type
;
return
hashCode
;
}
}
/// <summary>
/// Implements the operator ==.
/// </summary>
/// <param name="left">The left.</param>
/// <param name="right">The right.</param>
/// <returns>
/// The result of the operator.
/// </returns>
public
static
bool
operator
==
(
GeoJSONObject
left
,
GeoJSONObject
right
)
{
return
Equals
(
left
,
right
)
;
}
/// <summary>
/// Implements the operator !=.
/// </summary>
/// <param name="left">The left.</param>
/// <param name="right">The right.</param>
/// <returns>
/// The result of the operator.
/// </returns>
public
static
bool
operator
!=
(
GeoJSONObject
left
,
GeoJSONObject
right
)
{
return
!
Equals
(
left
,
right
)
;
}
/// <summary>
/// Determines whether the specified <see cref="GeoJSONObject" />, is equal to this instance.
/// </summary>
/// <param name="other">The <see cref="GeoJSONObject" /> to compare with this instance.</param>
/// <returns>
/// <c>true</c> if the specified <see cref="GeoJSONObject" /> is equal to this instance; otherwise, <c>false</c>.
/// </returns>
protected
virtual
bool
Equals
(
GeoJSONObject
other
)
{
if
(
Type
!=
other
.
Type
)
{
return
false
;
}
if
(
!
Equals
(
CRS
,
other
.
CRS
)
)
{
return
false
;
}
if
(
BoundingBoxes
==
null
&&
other
.
BoundingBoxes
==
null
)
{
return
true
;
}
if
(
(
BoundingBoxes
!=
null
&&
other
.
BoundingBoxes
==
null
)
||
(
BoundingBoxes
==
null
&&
other
.
BoundingBoxes
!=
null
)
)
{
return
false
;
}
return
BoundingBoxes
.
SequenceEqual
(
other
.
BoundingBoxes
,
DoubleComparer
)
;
}
/// <summary>
/// Called when [deserialized].
/// </summary>
/// <param name="streamingContext">The streaming context.</param>
[
OnDeserialized
]
private
void
OnDeserialized
(
StreamingContext
streamingContext
)
{
if
(
CRS
==
null
)
{
CRS
=
DefaultCRS
.
Instance
;
}
}
/// <summary>
/// Called when [serialized].
/// </summary>
/// <param name="streamingContext">The streaming context.</param>
[
OnSerialized
]
private
void
OnSerialized
(
StreamingContext
streamingContext
)
{
if
(
CRS
==
null
)
{
CRS
=
DefaultCRS
.
Instance
;
}
}
/// <summary>
/// Called when [serializing].
/// </summary>
/// <param name="streamingContext">The streaming context.</param>
[
OnSerializing
]
private
void
OnSerializing
(
StreamingContext
streamingContext
)
{
if
(
CRS
is
DefaultCRS
)
{
CRS
=
null
;
}
}
}
}
Back
|
FazBrowse Home
|
New Git URL