Skip to content
Permalink
Browse files

Added GeoJSON support

  • Loading branch information...
YohDeadfall committed Mar 8, 2018
1 parent 32501ef commit 35a910b8ec9f84772cd29e83aa76beebce0c769f
@@ -38,6 +38,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Npgsql.RawPostgis", "src\Np
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Npgsql.NetTopologySuite", "src\Npgsql.NetTopologySuite\Npgsql.NetTopologySuite.csproj", "{20D889AA-82DC-4AA0-B508-7CE68B83BB27}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Npgsql.GeoJSON", "src\Npgsql.GeoJSON\Npgsql.GeoJSON.csproj", "{04052CCF-CABC-4B37-B89D-F95721D95407}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -134,6 +136,14 @@ Global
{20D889AA-82DC-4AA0-B508-7CE68B83BB27}.Release|Any CPU.Build.0 = Release|Any CPU
{20D889AA-82DC-4AA0-B508-7CE68B83BB27}.Release|x86.ActiveCfg = Release|Any CPU
{20D889AA-82DC-4AA0-B508-7CE68B83BB27}.Release|x86.Build.0 = Release|Any CPU
{04052CCF-CABC-4B37-B89D-F95721D95407}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{04052CCF-CABC-4B37-B89D-F95721D95407}.Debug|Any CPU.Build.0 = Debug|Any CPU
{04052CCF-CABC-4B37-B89D-F95721D95407}.Debug|x86.ActiveCfg = Debug|Any CPU
{04052CCF-CABC-4B37-B89D-F95721D95407}.Debug|x86.Build.0 = Debug|Any CPU
{04052CCF-CABC-4B37-B89D-F95721D95407}.Release|Any CPU.ActiveCfg = Release|Any CPU
{04052CCF-CABC-4B37-B89D-F95721D95407}.Release|Any CPU.Build.0 = Release|Any CPU
{04052CCF-CABC-4B37-B89D-F95721D95407}.Release|x86.ActiveCfg = Release|Any CPU
{04052CCF-CABC-4B37-B89D-F95721D95407}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -150,6 +160,7 @@ Global
{EC0DCB3C-9401-47BB-A5E8-B8C7A47DF96A} = {8537E50E-CF7F-49CB-B4EF-3E2A1B11F050}
{B7E92398-DD4E-410E-923C-E256992F6687} = {8537E50E-CF7F-49CB-B4EF-3E2A1B11F050}
{20D889AA-82DC-4AA0-B508-7CE68B83BB27} = {8537E50E-CF7F-49CB-B4EF-3E2A1B11F050}
{04052CCF-CABC-4B37-B89D-F95721D95407} = {8537E50E-CF7F-49CB-B4EF-3E2A1B11F050}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C90AEECD-DB4C-4BE6-B506-16A449852FB8}
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2026
VisualStudioVersion = 15.0.27130.2036
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4A5A60DD-41B6-40BF-B677-227A921ECCC8}"
ProjectSection(SolutionItems) = preProject
@@ -31,6 +31,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Npgsql.RawPostgis", "src\Np
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Npgsql.NetTopologySuite", "src\Npgsql.NetTopologySuite\Npgsql.NetTopologySuite.csproj", "{6CB12050-DC9B-4155-BADD-BFDD54CDD70F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Npgsql.GeoJSON", "src\Npgsql.GeoJSON\Npgsql.GeoJSON.csproj", "{F7C53EBD-0075-474F-A083-419257D04080}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -111,6 +113,14 @@ Global
{6CB12050-DC9B-4155-BADD-BFDD54CDD70F}.Release|Any CPU.Build.0 = Release|Any CPU
{6CB12050-DC9B-4155-BADD-BFDD54CDD70F}.Release|x86.ActiveCfg = Release|Any CPU
{6CB12050-DC9B-4155-BADD-BFDD54CDD70F}.Release|x86.Build.0 = Release|Any CPU
{F7C53EBD-0075-474F-A083-419257D04080}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F7C53EBD-0075-474F-A083-419257D04080}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F7C53EBD-0075-474F-A083-419257D04080}.Debug|x86.ActiveCfg = Debug|Any CPU
{F7C53EBD-0075-474F-A083-419257D04080}.Debug|x86.Build.0 = Debug|Any CPU
{F7C53EBD-0075-474F-A083-419257D04080}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F7C53EBD-0075-474F-A083-419257D04080}.Release|Any CPU.Build.0 = Release|Any CPU
{F7C53EBD-0075-474F-A083-419257D04080}.Release|x86.ActiveCfg = Release|Any CPU
{F7C53EBD-0075-474F-A083-419257D04080}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -125,6 +135,7 @@ Global
{D96CC113-7D64-4B31-9DCC-13FDE92C1ECE} = {8537E50E-CF7F-49CB-B4EF-3E2A1B11F050}
{5BF3516D-5559-46A8-8362-0F4D931EEAB9} = {8537E50E-CF7F-49CB-B4EF-3E2A1B11F050}
{6CB12050-DC9B-4155-BADD-BFDD54CDD70F} = {8537E50E-CF7F-49CB-B4EF-3E2A1B11F050}
{F7C53EBD-0075-474F-A083-419257D04080} = {8537E50E-CF7F-49CB-B4EF-3E2A1B11F050}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C90AEECD-DB4C-4BE6-B506-16A449852FB8}
@@ -0,0 +1,54 @@
using GeoJSON.Net.Geometry;

namespace Npgsql.GeoJSON
{
sealed class BoundingBoxBuilder
{
bool _hasAltitude;
double _minLongitude, _maxLongitude;
double _minLatitude, _maxLatitude;
double _minAltitude, _maxAltitude;

internal BoundingBoxBuilder()
{
_hasAltitude = false;

_minLongitude = double.PositiveInfinity;
_minLatitude = double.PositiveInfinity;
_minAltitude = double.PositiveInfinity;

_maxLongitude = double.NegativeInfinity;
_maxLatitude = double.NegativeInfinity;
_maxAltitude = double.NegativeInfinity;
}

internal void Accumulate(Position position)
{
if (_minLongitude > position.Longitude)
_minLongitude = position.Longitude;
if (_maxLongitude < position.Longitude)
_maxLongitude = position.Longitude;

if (_minLatitude > position.Latitude)
_minLatitude = position.Latitude;
if (_maxLatitude < position.Latitude)
_maxLatitude = position.Latitude;

if (position.Altitude.HasValue)
{
var altitude = position.Altitude.Value;
if (_minAltitude > altitude)
_minAltitude = altitude;
if (_maxAltitude < altitude)
_maxAltitude = altitude;

_hasAltitude = true;
}
}

internal double[] Build()
=> _hasAltitude
? new[] { _minLongitude, _minLatitude, _minAltitude, _maxLongitude, _maxLatitude, _maxAltitude }
: new[] { _minLongitude, _minLatitude, _maxLongitude, _maxLatitude };
}
}
Oops, something went wrong.

0 comments on commit 35a910b

Please sign in to comment.
You can’t perform that action at this time.