Skip to content

Commit

Permalink
Merge branch 'additions_merge'
Browse files Browse the repository at this point in the history
  • Loading branch information
alatas committed Sep 12, 2015
2 parents 1c7db37 + 791c045 commit 202123a
Show file tree
Hide file tree
Showing 79 changed files with 271,941 additions and 226 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ obj/
*.suo
*.user
*.sln.docstates
.vs/

# Build results
[Dd]ebug/
Expand Down
12 changes: 6 additions & 6 deletions GeoJSON4EntityFramework.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.30110.0
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "GeoJSON4EntityFramework", "GeoJSON4EntityFramework\GeoJSON4EntityFramework.vbproj", "{7B0F6694-A109-4F3F-84A0-9FA49193AF31}"
EndProject
Expand All @@ -17,12 +17,12 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7B0F6694-A109-4F3F-84A0-9FA49193AF31}.Debug|Any CPU.ActiveCfg = Release|Any CPU
{7B0F6694-A109-4F3F-84A0-9FA49193AF31}.Debug|Any CPU.Build.0 = Release|Any CPU
{7B0F6694-A109-4F3F-84A0-9FA49193AF31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7B0F6694-A109-4F3F-84A0-9FA49193AF31}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7B0F6694-A109-4F3F-84A0-9FA49193AF31}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7B0F6694-A109-4F3F-84A0-9FA49193AF31}.Release|Any CPU.Build.0 = Release|Any CPU
{3AA1813C-601C-4FFF-8F7A-7070649CAF65}.Debug|Any CPU.ActiveCfg = Release|Any CPU
{3AA1813C-601C-4FFF-8F7A-7070649CAF65}.Debug|Any CPU.Build.0 = Release|Any CPU
{3AA1813C-601C-4FFF-8F7A-7070649CAF65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3AA1813C-601C-4FFF-8F7A-7070649CAF65}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3AA1813C-601C-4FFF-8F7A-7070649CAF65}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3AA1813C-601C-4FFF-8F7A-7070649CAF65}.Release|Any CPU.Build.0 = Release|Any CPU
{3622D159-0C66-4208-89FD-8DCD782B96F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
Expand Down
14 changes: 7 additions & 7 deletions GeoJSON4EntityFramework/App.config
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</configSections>

<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0"/>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /></startup></configuration>
3 changes: 3 additions & 0 deletions GeoJSON4EntityFramework/Base/GeoJsonGeometry.vb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
<JsonProperty(PropertyName:="coordinates")>
Public MustOverride ReadOnly Property Coordinates() As Object

<JsonProperty(PropertyName:="bbox", Order:=5, NullValueHandling:=NullValueHandling.Ignore)>
Public Property BoundingBox As Double()

End Class
8 changes: 8 additions & 0 deletions GeoJSON4EntityFramework/Base/GeoJsonGeometryEF6.vb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@

Public Shared Function FromDbGeometry(inp As System.Data.Entity.Spatial.DbGeometry) As GeoJsonGeometry(Of T)
Dim obj As GeoJsonGeometry(Of T) = CTypeDynamic(Activator.CreateInstance(Of T)(), GetType(T))

obj.BoundingBox = New Double(3) {
inp.Envelope.PointAt(1).YCoordinate,
inp.Envelope.PointAt(1).XCoordinate,
inp.Envelope.PointAt(3).YCoordinate,
inp.Envelope.PointAt(3).XCoordinate
}

obj.CreateFromDbGeometry(inp)
Return obj
End Function
Expand Down
3 changes: 2 additions & 1 deletion GeoJSON4EntityFramework/Base/IGeometry.vb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Public Interface IGeoJsonGeometry

Public Interface IGeoJsonGeometry

End Interface
5 changes: 4 additions & 1 deletion GeoJSON4EntityFramework/Elements/Coordinate.vb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Public Class Coordinate
<JsonConverter(GetType(CoordinateConverter))>
Public Class Coordinate
Sub New()
MyBase.New()
End Sub
Expand All @@ -14,8 +15,10 @@
End Get
End Property

<JsonIgnore()>
Public Property X As Double

<JsonIgnore()>
Public Property Y As Double

End Class
2 changes: 1 addition & 1 deletion GeoJSON4EntityFramework/Elements/Feature.vb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Public Property ID As String

<JsonProperty(PropertyName:="properties", Order:=3)>
Public Property Properties As New Dictionary(Of String, String)
Public Property Properties As New Dictionary(Of String, Object)

<JsonProperty(PropertyName:="geometry", Order:=4)>
<JsonConverter(GetType(GenericListConverter(Of IGeoJsonGeometry)))>
Expand Down
1 change: 0 additions & 1 deletion GeoJSON4EntityFramework/Elements/FeatureCollection.vb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Public Class FeatureCollection
Inherits GeoJsonElement(Of FeatureCollection)

<JsonConverter(GetType(GenericListConverter(Of Feature)))>
<JsonProperty(PropertyName:="features")>
Public Property Features As New List(Of Feature)
End Class
8 changes: 7 additions & 1 deletion GeoJSON4EntityFramework/Elements/FeatureEF6.vb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@
f.Geometry.Add(Polygon.FromDbGeometry(inp))
Case "Point"
f.Geometry.Add(Point.FromDbGeometry(inp))
Case "MultPoint"
Case "MultiPoint"
f.Geometry.Add(MultiPoint.FromDbGeometry(inp))
Case "LineString"
f.Geometry.Add(LineString.FromDbGeometry(inp))
Case "MultiLineString"
f.Geometry.Add(MultiLineString.FromDbGeometry(inp))
Case "GeometryCollection"
f.Geometry.Add(GeometryCollection.FromDbGeometry(inp))
Case Else
Throw New NotImplementedException
End Select
Expand Down
10 changes: 10 additions & 0 deletions GeoJSON4EntityFramework/Elements/GeometryCollection.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Partial Public Class GeometryCollection
Inherits GeoJsonGeometry(Of GeometryCollection)
Implements IGeoJsonGeometry

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

<JsonIgnore>
Public Overrides ReadOnly Property Coordinates()
End Class
22 changes: 22 additions & 0 deletions GeoJSON4EntityFramework/Elements/GeometryCollectionEF6.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Partial Public Class GeometryCollection
Public Overrides Sub CreateFromDbGeometry(inp As Entity.Spatial.DbGeometry)
If inp.SpatialTypeName <> "GeometryCollection" Then Throw New ArgumentException
Geometries.Clear()

For i As Integer = 1 To inp.ElementCount
Dim element = inp.ElementAt(i)
Select Case element.SpatialTypeName
Case "MultiPolygon"
Geometries.Add(MultiPolygon.FromDbGeometry(element))
Case "Polygon"
Geometries.Add(Polygon.FromDbGeometry(element))
Case "Point"
Geometries.Add(Point.FromDbGeometry(element))
Case "MultiPoint"
Geometries.Add(MultiPoint.FromDbGeometry(element))
Case Else
Throw New NotImplementedException
End Select
Next
End Sub
End Class
29 changes: 29 additions & 0 deletions GeoJSON4EntityFramework/Elements/LineString.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Public Class LineString
Inherits GeoJsonGeometry(Of LineString)
Implements IGeoJsonGeometry

<Newtonsoft.Json.JsonIgnore()>
Public Property Points As New CoordinateList

Public Overrides ReadOnly Property Coordinates()
Get
Try
If Points.Count = 0 Then
Return New Double() {}
ElseIf Points.Count = 1 Then
Throw New Exception("There must be an array of two or more points")
Else
Dim out()() As Double
out = New Double(Points.Count - 1)() {}
Parallel.For(0, Points.Count, Sub(i)
out(i) = Points(i).Coordinate
End Sub)
Return out
End If
Catch ex As Exception
Return New Double() {}
End Try
End Get
End Property

End Class
11 changes: 11 additions & 0 deletions GeoJSON4EntityFramework/Elements/LineStringEF6.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Partial Class LineString
Public Overrides Sub CreateFromDbGeometry(inp As Entity.Spatial.DbGeometry)
If inp.SpatialTypeName <> MyBase.TypeName Then Throw New ArgumentException
Points.Clear()

For i As Integer = 1 To inp.PointCount
Dim point = inp.PointAt(i)
Points.AddNew(point.XCoordinate, point.YCoordinate)
Next
End Sub
End Class
13 changes: 13 additions & 0 deletions GeoJSON4EntityFramework/Elements/MultiLineString.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Public Class MultiLineString
Inherits GeoJsonGeometry(Of MultiLineString)
Implements IGeoJsonGeometry

<JsonIgnore()>
Public Property LineStrings As New List(Of LineString)

Public Overrides ReadOnly Property Coordinates As Object
Get
Return (From ls In LineStrings Let c = ls.Coordinates Select c).ToArray
End Get
End Property
End Class
12 changes: 12 additions & 0 deletions GeoJSON4EntityFramework/Elements/MultiLineStringEF6.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Partial Class MultiLineString
Public Overrides Sub CreateFromDbGeometry(inp As Entity.Spatial.DbGeometry)
If inp.SpatialTypeName <> MyBase.TypeName Then Throw New ArgumentException
LineStrings.Clear()

For i As Integer = 1 To inp.ElementCount
Dim element = inp.ElementAt(i)
If element.SpatialTypeName <> "LineString" Then Throw New ArgumentException
LineStrings.Add(LineString.FromDbGeometry(element))
Next
End Sub
End Class
15 changes: 5 additions & 10 deletions GeoJSON4EntityFramework/Elements/MultiPolygon.vb
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,11 @@

Public Overrides ReadOnly Property Coordinates As Object
Get
If Polygons.Count = 0 Then
Return New Double() {}
Else
Dim out(Polygons.Count - 1)()()() As Double

Parallel.For(0, Polygons.Count, Sub(i)
out(i) = Polygons(i).Coordinates
End Sub)
Return out
End If
Dim result As New List(Of Object)()
For Each poly In Polygons
result.Add(poly.Coordinates)
Next
Return result
End Get
End Property
End Class
19 changes: 2 additions & 17 deletions GeoJSON4EntityFramework/Elements/Polygon.vb
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,11 @@
Implements IGeoJsonGeometry

<Newtonsoft.Json.JsonIgnore()>
Public Property Points As New CoordinateList
Public Property Rings As New List(Of CoordinateList)

Public Overrides ReadOnly Property Coordinates()
Get
Try
If Points.Count = 0 Then
Return New Double() {}
ElseIf Points.Count = 1 Then
Throw New Exception("There must be an array of two or more points")
Else
Dim out(0)()() As Double
out(0) = New Double(Points.Count - 1)() {}
Parallel.For(0, Points.Count, Sub(i)
out(0)(i) = Points(i).Coordinate
End Sub)
Return out
End If
Catch ex As Exception
Return New Double() {}
End Try
Return Rings
End Get
End Property
End Class
27 changes: 22 additions & 5 deletions GeoJSON4EntityFramework/Elements/PolygonEF6.vb
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
Partial Class Polygon
Private Function RingToCoordinateList(ring As Entity.Spatial.DbGeometry) As CoordinateList
Dim extRingCoords As New CoordinateList()
For i = 1 To ring.PointCount
Dim pt = ring.PointAt(i)
extRingCoords.Add(New Coordinate(pt.XCoordinate, pt.YCoordinate))
Next
Return extRingCoords
End Function

Public Overrides Sub CreateFromDbGeometry(inp As Entity.Spatial.DbGeometry)
If inp.SpatialTypeName <> MyBase.TypeName Then Throw New ArgumentException
Points.Clear()
Rings.Clear()

For i As Integer = 1 To inp.PointCount
Dim point = inp.PointAt(i)
Points.AddNew(point.XCoordinate, point.YCoordinate)
Next
' Process exterior ring
Dim extRing = inp.ExteriorRing
Rings.Add(RingToCoordinateList(extRing))

' Process interior rings (ie. holes)
If inp.InteriorRingCount > 0 Then
For i = 1 To inp.InteriorRingCount
Dim intRing = inp.InteriorRingAt(i)
Rings.Add(RingToCoordinateList(intRing))
Next
End If
End Sub

End Class
24 changes: 15 additions & 9 deletions GeoJSON4EntityFramework/GeoJSON4EntityFramework.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,17 @@
<OptionInfer>On</OptionInfer>
</PropertyGroup>
<ItemGroup>
<Reference Include="EntityFramework">
<HintPath>..\packages\EntityFramework.6.1.0\lib\net40\EntityFramework.dll</HintPath>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="EntityFramework.SqlServer">
<HintPath>..\packages\EntityFramework.6.1.0\lib\net40\EntityFramework.SqlServer.dll</HintPath>
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.6.0.1\lib\net40\Newtonsoft.Json.dll</HintPath>
<HintPath>..\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
Expand All @@ -79,10 +81,16 @@
<ItemGroup>
<Compile Include="Base\GeoJsonGeometryEF6.vb" />
<Compile Include="Elements\FeatureEF6.vb" />
<Compile Include="Elements\LineString.vb" />
<Compile Include="Elements\LineStringEF6.vb" />
<Compile Include="Elements\MultiLineStringEF6.vb" />
<Compile Include="Elements\GeometryCollection.vb" />
<Compile Include="Elements\MultiPointEF6.vb" />
<Compile Include="Elements\MultiPolygonEF6.vb" />
<Compile Include="Elements\MultiLineString.vb" />
<Compile Include="Elements\PointEF6.vb" />
<Compile Include="Elements\PolygonEF6.vb" />
<Compile Include="JsonNET\CoordinateConverter.vb" />
<Compile Include="JsonNET\GeoJsonSerializer.vb" />
<Compile Include="Elements\Coordinate.vb" />
<Compile Include="Elements\CoordinateList.vb" />
Expand Down Expand Up @@ -123,6 +131,7 @@
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<Compile Include="Elements\GeometryCollectionEF6.vb" />
<None Include="My Project\Application.myapp">
<Generator>MyApplicationCodeGenerator</Generator>
<LastGenOutput>Application.Designer.vb</LastGenOutput>
Expand All @@ -134,9 +143,6 @@
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="geojson.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
Loading

0 comments on commit 202123a

Please sign in to comment.