-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-added dbgeography support -changed bbox to optional -removed unnecessary points array from multipoint -added unit tests for the specific spatial features -a few cleanup
- Loading branch information
Showing
13 changed files
with
366 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,103 @@ | ||
Imports System.Text | ||
Imports Microsoft.VisualStudio.TestTools.UnitTesting | ||
Imports alatas.GeoJSON4EntityFramework | ||
Imports System.Data.Entity.Spatial | ||
Imports alatas.GeoJSON4EntityFramework | ||
|
||
<TestClass()> | ||
Public Class Tests | ||
Private fc As FeatureCollection | ||
Private ReadOnly Property GetFeatureCollection() As FeatureCollection | ||
Get | ||
If fc Is Nothing Then | ||
fc = New FeatureCollection | ||
TestFeatures.ForEach(Sub(c) | ||
Dim geom As Entity.Spatial.DbGeometry = Entity.Spatial.DbGeometry.FromText(c.Geometry) | ||
Dim f = Feature.FromDbGeometry(geom) | ||
f.ID = c.ID | ||
f.Properties.Add("Name", c.Name) | ||
f.Properties.Add("Area", geom.Area) | ||
f.Properties.Add("Type", c.ElementType.ToString) | ||
fc.Features.Add(f) | ||
End Sub) | ||
Return fc | ||
End If | ||
|
||
Return fc | ||
End Get | ||
End Property | ||
|
||
Function GetFeatureCollection(Optional elementType As String = "", Optional withBBox As Boolean = False) As FeatureCollection | ||
Dim fc As New FeatureCollection | ||
TestFeatures.ForEach(Sub(c) | ||
If elementType = "" Or (elementType <> "" And elementType = c.ElementType.ToString) Then | ||
Dim geom = Entity.Spatial.DbGeometry.FromText(c.Geometry) | ||
Dim f = Feature.FromDbGeometry(geom, withBBox) | ||
f.ID = c.ID | ||
f.Properties.Add("Name", c.Name) | ||
f.Properties.Add("Area", geom.Area) | ||
f.Properties.Add("Type", c.ElementType.ToString) | ||
fc.Features.Add(f) | ||
End If | ||
End Sub) | ||
Return fc | ||
End Function | ||
|
||
<TestMethod()> Public Sub TestAll() | ||
Dim json = GeoJsonSerializer.Serialize(Of FeatureCollection)(GetFeatureCollection, True) | ||
Dim json = GeoJsonSerializer.Serialize(Of FeatureCollection)(GetFeatureCollection(withBBox:=True), True) | ||
Assert.IsNotNull(json) | ||
WriteOutput(json) | ||
End Sub | ||
|
||
<TestMethod()> Public Sub OnlineTestAll() | ||
Dim json = GeoJsonSerializer.Serialize(Of FeatureCollection)(GetFeatureCollection(withBBox:=True), False) | ||
Assert.IsNotNull(json) | ||
WriteOutput(json) | ||
SendOutput(json) | ||
End Sub | ||
|
||
Public Sub TestSpecificType(elementType As String) | ||
Dim json = GeoJsonSerializer.Serialize(Of FeatureCollection)(GetFeatureCollection(elementType.ToUpperInvariant), True) | ||
Assert.IsNotNull(json) | ||
WriteOutput(json) | ||
End Sub | ||
|
||
<TestMethod()> Public Sub TestAllOnline() | ||
Dim json = GeoJsonSerializer.Serialize(Of FeatureCollection)(GetFeatureCollection, False) | ||
Public Sub TestSpecificTypeOnline(elementType As String) | ||
Dim json = GeoJsonSerializer.Serialize(Of FeatureCollection)(GetFeatureCollection(elementType.ToUpperInvariant), False) | ||
Assert.IsNotNull(json) | ||
WriteOutput(json) | ||
SendOutput(json) | ||
End Sub | ||
<TestMethod> Sub TestMultiPolygon() | ||
TestSpecificType("MultiPolygon") | ||
End Sub | ||
|
||
<TestMethod> Sub TestPolygon() | ||
TestSpecificType("Polygon") | ||
End Sub | ||
|
||
<TestMethod> Sub TestPoint() | ||
TestSpecificType("Point") | ||
End Sub | ||
|
||
<TestMethod> Sub TestMultiPoint() | ||
TestSpecificType("MultiPoint") | ||
End Sub | ||
|
||
<TestMethod> Sub TestLineString() | ||
TestSpecificType("LineString") | ||
End Sub | ||
|
||
<TestMethod> Sub TestMultiLineString() | ||
TestSpecificType("MultiLineString") | ||
End Sub | ||
|
||
<TestMethod> Sub TestGeometryCollection() | ||
TestSpecificType("GeometryCollection") | ||
End Sub | ||
|
||
<TestMethod> Sub OnlineTestMultiPolygon() | ||
TestSpecificTypeOnline("MultiPolygon") | ||
End Sub | ||
|
||
<TestMethod> Sub OnlineTestPolygon() | ||
TestSpecificTypeOnline("Polygon") | ||
End Sub | ||
|
||
<TestMethod> Sub OnlineTestPoint() | ||
TestSpecificTypeOnline("Point") | ||
End Sub | ||
|
||
<TestMethod> Sub OnlineTestMultiPoint() | ||
TestSpecificTypeOnline("MultiPoint") | ||
End Sub | ||
|
||
<TestMethod> Sub OnlineTestLineString() | ||
TestSpecificTypeOnline("LineString") | ||
End Sub | ||
|
||
<TestMethod> Sub OnlineTestMultiLineString() | ||
TestSpecificTypeOnline("MultiLineString") | ||
End Sub | ||
|
||
<TestMethod> Sub OnlineTestGeometryCollection() | ||
TestSpecificTypeOnline("GeometryCollection") | ||
End Sub | ||
|
||
End Class |
Oops, something went wrong.