Skip to content

Commit 6c3fcfa

Browse files
committed
-fixed multipoint problem (spelling mistake)
-rewrote whole test procedure including all types of spatial data -fixed incorrect serialization of Polygon and MultiPolygon instances and added support for geometrycollection (thanx to Jackie Ng) -added support for linestring, multilinestring, polygon inner rings and boundingbox (thanks to Tito Luyo Murata) -fixed #3
1 parent 8f193b6 commit 6c3fcfa

17 files changed

+221
-195
lines changed

GeoJSON4EntityFramework.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 2013
4-
VisualStudioVersion = 12.0.31101.0
3+
# Visual Studio 14
4+
VisualStudioVersion = 14.0.23107.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "GeoJSON4EntityFramework", "GeoJSON4EntityFramework\GeoJSON4EntityFramework.vbproj", "{7B0F6694-A109-4F3F-84A0-9FA49193AF31}"
77
EndProject
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
Public Interface IGeoJsonGeometry
1+
2+
Public Interface IGeoJsonGeometry
23

34
End Interface

GeoJSON4EntityFramework/Elements/FeatureEF6.vb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
f.Geometry.Add(Polygon.FromDbGeometry(inp))
1111
Case "Point"
1212
f.Geometry.Add(Point.FromDbGeometry(inp))
13-
Case "MultPoint"
13+
Case "MultiPoint"
1414
f.Geometry.Add(MultiPoint.FromDbGeometry(inp))
1515
Case "LineString"
1616
f.Geometry.Add(LineString.FromDbGeometry(inp))
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
Partial Public Class GeometryCollection
2-
Inherits GeoJsonElement(Of GeometryCollection)
2+
Inherits GeoJsonGeometry(Of GeometryCollection)
33
Implements IGeoJsonGeometry
44

55
<JsonProperty(PropertyName:="geometries")>
66
Public Property Geometries As New List(Of IGeoJsonGeometry)
77

8-
Shared Function FromDbGeometry(inp As Entity.Spatial.DbGeometry) As IGeoJsonGeometry
9-
Dim obj As New GeometryCollection()
10-
obj.CreateFromDbGeometry(inp)
11-
Return obj
12-
End Function
13-
8+
<JsonIgnore>
9+
Public Overrides ReadOnly Property Coordinates()
1410
End Class

GeoJSON4EntityFramework/Elements/GeometryCollectionEF6.vb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Partial Public Class GeometryCollection
2-
Public Sub CreateFromDbGeometry(inp As Entity.Spatial.DbGeometry)
2+
Public Overrides Sub CreateFromDbGeometry(inp As Entity.Spatial.DbGeometry)
33
If inp.SpatialTypeName <> "GeometryCollection" Then Throw New ArgumentException
44
Geometries.Clear()
55

@@ -14,6 +14,8 @@
1414
Geometries.Add(Point.FromDbGeometry(element))
1515
Case "MultiPoint"
1616
Geometries.Add(MultiPoint.FromDbGeometry(element))
17+
Case Else
18+
Throw New NotImplementedException
1719
End Select
1820
Next
1921
End Sub

GeoJSON4EntityFramework/Elements/MultiLineString.vb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
Public Overrides ReadOnly Property Coordinates As Object
99
Get
10-
'TODO: Complete
11-
Throw New NotImplementedException
10+
Return (From ls In LineStrings Let c = ls.Coordinates Select c).ToArray
1211
End Get
1312
End Property
1413
End Class

GeoJSON4EntityFramework/GeoJSON4EntityFramework.vbproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,6 @@
143143
</None>
144144
<None Include="packages.config" />
145145
</ItemGroup>
146-
<ItemGroup>
147-
<Content Include="geojson.png" />
148-
</ItemGroup>
149146
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
150147
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
151148
Other similar extension points exist, see Microsoft.Common.targets.

GeoJSON4EntityFramework5/Elements/FeatureEF5.vb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010
f.Geometry.Add(Polygon.FromDbGeometry(inp))
1111
Case "Point"
1212
f.Geometry.Add(Point.FromDbGeometry(inp))
13-
Case "MultPoint"
13+
Case "MultiPoint"
1414
f.Geometry.Add(MultiPoint.FromDbGeometry(inp))
1515
Case "LineString"
1616
f.Geometry.Add(LineString.FromDbGeometry(inp))
1717
Case "MultiLineString"
1818
f.Geometry.Add(MultiLineString.FromDbGeometry(inp))
19+
Case "GeometryCollection"
20+
f.Geometry.Add(GeometryCollection.FromDbGeometry(inp))
1921
Case Else
2022
Throw New NotImplementedException
2123
End Select
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Partial Public Class GeometryCollection
2+
Public Overrides Sub CreateFromDbGeometry(inp As Spatial.DbGeometry)
3+
If inp.SpatialTypeName <> "GeometryCollection" Then Throw New ArgumentException
4+
Geometries.Clear()
5+
6+
For i As Integer = 1 To inp.ElementCount
7+
Dim element = inp.ElementAt(i)
8+
Select Case element.SpatialTypeName
9+
Case "MultiPolygon"
10+
Geometries.Add(MultiPolygon.FromDbGeometry(element))
11+
Case "Polygon"
12+
Geometries.Add(Polygon.FromDbGeometry(element))
13+
Case "Point"
14+
Geometries.Add(Point.FromDbGeometry(element))
15+
Case "MultiPoint"
16+
Geometries.Add(MultiPoint.FromDbGeometry(element))
17+
Case Else
18+
Throw New NotImplementedException
19+
End Select
20+
Next
21+
End Sub
22+
End Class

GeoJSON4EntityFramework5/GeoJSON4EntityFramework5.vbproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@
9090
<Compile Include="..\GeoJSON4EntityFramework\Elements\FeatureCollection.vb">
9191
<Link>Elements\FeatureCollection.vb</Link>
9292
</Compile>
93+
<Compile Include="..\GeoJSON4EntityFramework\Elements\GeometryCollection.vb">
94+
<Link>Elements\GeometryCollection.vb</Link>
95+
</Compile>
9396
<Compile Include="..\GeoJSON4EntityFramework\Elements\LineString.vb">
9497
<Link>Elements\LineString.vb</Link>
9598
</Compile>
@@ -122,6 +125,7 @@
122125
</Compile>
123126
<Compile Include="Base\GeoJsonGeometryEF5.vb" />
124127
<Compile Include="Elements\FeatureEF5.vb" />
128+
<Compile Include="Elements\GeometryCollectionEF5.vb" />
125129
<Compile Include="Elements\LineStringEF5.vb" />
126130
<Compile Include="Elements\MultiLineStringEF5.vb" />
127131
<Compile Include="Elements\MultiPointEF5.vb" />

0 commit comments

Comments
 (0)