FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
GeoJson.NET-Unity/GeoJSONObject.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
/
GeoJSONObject.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
158 lines (138 loc) · 5.56 KB
Breadcrumbs
GeoJson.NET-Unity
/
GeoJSONObject.cs
Copy path
File metadata and controls
executable file
·
158 lines (138 loc) · 5.56 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
// Copyright © Joerg Battermann 2014, Matt Hunt 2017
using
System
.
Linq
;
using
System
.
Runtime
.
Serialization
;
using
GeoJSON
.
Net
.
Converters
;
using
GeoJSON
.
Net
.
CoordinateReferenceSystem
;
using
Newtonsoft
.
Json
;
using
Newtonsoft
.
Json
.
Converters
;
using
System
.
Collections
.
Generic
;
using
System
;
namespace
GeoJSON
.
Net
{
/// <summary>
/// Base class for all IGeometryObject implementing types
/// </summary>
[
JsonObject
(
MemberSerialization
.
OptIn
)
]
public
abstract
class
GeoJSONObject
:
IGeoJSONObject
,
IEqualityComparer
<
GeoJSONObject
>
,
IEquatable
<
GeoJSONObject
>
{
internal
static
readonly
DoubleTenDecimalPlaceComparer
DoubleComparer
=
new
DoubleTenDecimalPlaceComparer
(
)
;
/// <summary>
/// Gets or sets the (optional)
/// <see cref="https://tools.ietf.org/html/rfc7946#section-5">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="https://tools.ietf.org/html/rfc7946#section-4">
/// 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>
/// The (mandatory) type of the
/// <see cref="https://tools.ietf.org/html/rfc7946#section-3">GeoJSON Object</see>.
/// </summary>
[
JsonProperty
(
PropertyName
=
"type"
,
Required
=
Required
.
Always
,
DefaultValueHandling
=
DefaultValueHandling
.
Include
)
]
//[JsonConverter(typeof(StringEnumConverter))]
public
abstract
GeoJSONObjectType
Type
{
get
;
}
#region IEqualityComparer, IEquatable
/// <summary>
/// Determines whether the specified object is equal to the current object
/// </summary>
public
override
bool
Equals
(
object
obj
)
{
return
Equals
(
this
,
obj
as
GeoJSONObject
)
;
}
/// <summary>
/// Determines whether the specified object is equal to the current object
/// </summary>
public
bool
Equals
(
GeoJSONObject
other
)
{
return
Equals
(
this
,
other
)
;
}
/// <summary>
/// Determines whether the specified object instances are considered equal
/// </summary>
public
bool
Equals
(
GeoJSONObject
left
,
GeoJSONObject
right
)
{
if
(
ReferenceEquals
(
left
,
right
)
)
{
return
true
;
}
if
(
ReferenceEquals
(
null
,
right
)
)
{
return
false
;
}
if
(
left
.
Type
!=
right
.
Type
)
{
return
false
;
}
if
(
!
Equals
(
left
.
CRS
,
right
.
CRS
)
)
{
return
false
;
}
var
leftIsNull
=
ReferenceEquals
(
null
,
left
.
BoundingBoxes
)
;
var
rightIsNull
=
ReferenceEquals
(
null
,
right
.
BoundingBoxes
)
;
var
bothAreMissing
=
leftIsNull
&&
rightIsNull
;
if
(
bothAreMissing
||
leftIsNull
!=
rightIsNull
)
{
return
bothAreMissing
;
}
return
left
.
BoundingBoxes
.
SequenceEqual
(
right
.
BoundingBoxes
,
DoubleComparer
)
;
}
/// <summary>
/// Determines whether the specified object instances are considered equal
/// </summary>
public
static
bool
operator
==
(
GeoJSONObject
left
,
GeoJSONObject
right
)
{
if
(
ReferenceEquals
(
left
,
right
)
)
{
return
true
;
}
if
(
ReferenceEquals
(
null
,
right
)
)
{
return
false
;
}
return
left
.
Equals
(
right
)
;
}
/// <summary>
/// Determines whether the specified object instances are not considered equal
/// </summary>
public
static
bool
operator
!=
(
GeoJSONObject
left
,
GeoJSONObject
right
)
{
return
!
(
left
==
right
)
;
}
/// <summary>
/// Returns the hash code for this instance
/// </summary>
public
override
int
GetHashCode
(
)
{
return
(
(
int
)
Type
)
.
GetHashCode
(
)
;
}
/// <summary>
/// Returns the hash code for the specified object
/// </summary>
public
int
GetHashCode
(
GeoJSONObject
obj
)
{
return
obj
.
GetHashCode
(
)
;
}
#endregion
}
}
Back
|
FazBrowse Home
|
New Git URL