Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
airbreather committed Jun 17, 2020
2 parents 3bdb017 + 3f0cada commit a036218
Show file tree
Hide file tree
Showing 36 changed files with 3,485 additions and 23 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
language: csharp
mono: none
sudo: false
dotnet: 2.2
dist: xenial
dotnet: 3.1
dist: bionic


script:
Expand All @@ -26,7 +26,7 @@ deploy:
branch: develop
provider: script
script:
- dotnet nuget push **/*.nupkg -s https://www.myget.org/F/nettopologysuite/api/v2/package -k $MYGET_API_KEY
- dotnet nuget push **/*.nupkg -s https://www.myget.org/F/nettopologysuite/api/v3/index.json -k $MYGET_API_KEY
skip_cleanup: true

env:
Expand Down
7 changes: 6 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@

<PropertyGroup>
<SolutionDir Condition=" '$(SolutionDir)' == '' ">$(MSBuildThisFileDirectory)</SolutionDir>
<LangVersion>7.3</LangVersion> <!-- latest version supported by VS2017 -->

<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)nts.snk</AssemblyOriginatorKeyFile>

<PackageIcon>icon.png</PackageIcon>
</PropertyGroup>

<ItemGroup>
<None Condition=" '$(IsPackable)' == 'true' " Include="$(MSBuildThisFileDirectory)icon.png" Pack="true" PackagePath="\" />
</ItemGroup>

</Project>
12 changes: 12 additions & 0 deletions NetTopologySuite.IO.GeoJSON.sln
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetTopologySuite.IO.GeoJSON
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetTopologySuite.IO.GeoJSON.Test", "test\NetTopologySuite.IO.GeoJSON.Test\NetTopologySuite.IO.GeoJSON.Test.csproj", "{1AA4E251-7124-4DD3-A643-B81AD8BB69C5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetTopologySuite.IO.GeoJSON4STJ", "src\NetTopologySuite.IO.GeoJSON4STJ\NetTopologySuite.IO.GeoJSON4STJ.csproj", "{91366C8B-C996-4801-A691-80C335924FCC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetTopologySuite.IO.GeoJSON4STJ.Test", "test\NetTopologySuite.IO.GeoJSON4STJ.Test\NetTopologySuite.IO.GeoJSON4STJ.Test.csproj", "{75BE3EBE-230E-4779-A265-D9FC05C01C78}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -28,6 +32,14 @@ Global
{1AA4E251-7124-4DD3-A643-B81AD8BB69C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1AA4E251-7124-4DD3-A643-B81AD8BB69C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1AA4E251-7124-4DD3-A643-B81AD8BB69C5}.Release|Any CPU.Build.0 = Release|Any CPU
{91366C8B-C996-4801-A691-80C335924FCC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{91366C8B-C996-4801-A691-80C335924FCC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91366C8B-C996-4801-A691-80C335924FCC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91366C8B-C996-4801-A691-80C335924FCC}.Release|Any CPU.Build.0 = Release|Any CPU
{75BE3EBE-230E-4779-A265-D9FC05C01C78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{75BE3EBE-230E-4779-A265-D9FC05C01C78}.Debug|Any CPU.Build.0 = Debug|Any CPU
{75BE3EBE-230E-4779-A265-D9FC05C01C78}.Release|Any CPU.ActiveCfg = Release|Any CPU
{75BE3EBE-230E-4779-A265-D9FC05C01C78}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 1 addition & 6 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@
</PropertyGroup>

<PropertyGroup Label="Version numbers">
<!-- MAJOR, MINOR, and PATCH are defined according to SemVer 2.0.0. -->
<NtsMajorVersion>2</NtsMajorVersion>
<NtsMinorVersion>0</NtsMinorVersion>
<NtsPatchVersion>2</NtsPatchVersion>

<NtsBuildTimestamp>$([System.DateTime]::UtcNow.Ticks)</NtsBuildTimestamp>
<NtsDaysSinceEpoch>$([System.DateTime]::op_Subtraction($([System.DateTime]::new($(NtsBuildTimestamp)).Date),$([System.DateTime]::new(621355968000000000))).TotalDays.ToString("00000"))</NtsDaysSinceEpoch>

Expand Down Expand Up @@ -92,7 +87,7 @@

<ItemGroup>
<!-- SourceLink adds stuff to let debuggers step into our code. -->
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-18618-05" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,23 @@ private static object InternalReadJson(JsonReader reader, JsonSerializer seriali
object attributeValue;
if (reader.TokenType == JsonToken.StartObject)
{
// inner object
attributeValue = InternalReadJson(reader, serializer, true);
if (reader.TokenType != JsonToken.EndObject)
if (serializer.TypeNameHandling != TypeNameHandling.Objects)
{
throw new ArgumentException("Expected token '}' not found.");
// inner object to AttributeTable
attributeValue = InternalReadJson(reader, serializer, true);
if (reader.TokenType != JsonToken.EndObject)
{
throw new ArgumentException("Expected token '}' not found.");
}

// read EndObject token
reader.Read();
}
else
{
// deserialize the inner object
attributeValue = serializer.Deserialize(reader);
}

// read EndObject token
reader.Read();
}
else if (reader.TokenType == JsonToken.StartArray)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace NetTopologySuite.IO.Converters
{
/// <summary>
/// Convertes <see cref="Envelope"/>s to and from JSON
/// Converts <see cref="Envelope"/>s to and from JSON
/// </summary>
public class EnvelopeConverter : JsonConverter
{
Expand Down
17 changes: 15 additions & 2 deletions src/NetTopologySuite.IO.GeoJSON/NetTopologySuite.IO.GeoJSON.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<Project>

<!-- Set these very early in the process, before Directory.Build.props is imported. -->
<PropertyGroup Label="Version numbers">
<!-- MAJOR, MINOR, and PATCH are defined according to SemVer 2.0.0. -->
<NtsMajorVersion Condition=" '$(NtsMajorVersion)' == '' ">2</NtsMajorVersion>
<NtsMinorVersion Condition=" '$(NtsMinorVersion)' == '' ">0</NtsMinorVersion>
<NtsPatchVersion Condition=" '$(NtsPatchVersion)' == '' ">3</NtsPatchVersion>
</PropertyGroup>

<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace>NetTopologySuite.IO</RootNamespace>
Expand All @@ -16,7 +27,6 @@
<Authors>NetTopologySuite - Team</Authors>
<Owners>NetTopologySuite - Team</Owners>
<PackageLicenseExpression>LGPL-2.1-or-later</PackageLicenseExpression>
<PackageIconUrl>https://raw.githubusercontent.com/NetTopologySuite/GeoAPI/master/icon.png</PackageIconUrl>
<Description>This package contains the GeoJSON IO library.</Description>
<PackageTags>NTS;GeoJSON</PackageTags>
</PropertyGroup>
Expand All @@ -26,4 +36,7 @@
<PackageReference Include="NetTopologySuite.Features" Version="[2.0.0, 3.0.0-A)" />
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
</ItemGroup>

<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;
using NetTopologySuite.Features;
using NetTopologySuite.Geometries;

namespace NetTopologySuite.IO.Converters
{
/// <inheritdoc cref="JsonConverterFactory"/>>
public class GeoJsonConverterFactory : JsonConverterFactory
{
/// <summary>
/// The default name that, when seen on <see cref="IAttributesTable"/> or the "properties"
/// object of a feature, indicates that it should "really" be the feature's "id", not stored
/// in "properties" as-is.
/// </summary>
public static readonly string DefaultIdPropertyName = "_NetTopologySuite_id";

private static readonly HashSet<Type> GeometryTypes = new HashSet<Type>
{
typeof(Geometry),
typeof(Point),
typeof(LineString),
typeof(Polygon),
typeof(MultiPoint),
typeof(MultiLineString),
typeof(MultiPolygon),
typeof(GeometryCollection),
};

private readonly GeometryFactory _factory;

private readonly bool _writeGeometryBBox;

private readonly string _idPropertyName;

/// <summary>
/// Creates an instance of this class using the defaults.
/// </summary>
public GeoJsonConverterFactory()
: this(NtsGeometryServices.Instance.CreateGeometryFactory(4326), false)
{
}

/// <summary>
/// Creates an instance of this class using the provided <see cref="GeometryFactory"/> and
/// defaults for other values.
/// </summary>
/// <param name="factory"></param>
public GeoJsonConverterFactory(GeometryFactory factory)
: this(factory, false)
{
}

/// <summary>
/// Creates an instance of this class using the provided <see cref="GeometryFactory"/>, the
/// given value for whether or not we should write out a "bbox" for a plain geometry, and
/// defaults for all other values.
/// </summary>
/// <param name="factory"></param>
/// <param name="writeGeometryBBox"></param>
public GeoJsonConverterFactory(GeometryFactory factory, bool writeGeometryBBox)
: this(factory, writeGeometryBBox, DefaultIdPropertyName)
{
}

/// <summary>
/// Creates an instance of this class using the provided <see cref="GeometryFactory"/>, the
/// given value for whether or not we should write out a "bbox" for a plain geometry, and
/// the given "magic" string to signal when an <see cref="IAttributesTable"/> property is
/// actually filling in for a Feature's "id".
/// </summary>
/// <param name="factory"></param>
/// <param name="writeGeometryBBox"></param>
/// <param name="idPropertyName"></param>
public GeoJsonConverterFactory(GeometryFactory factory, bool writeGeometryBBox, string idPropertyName)
{
_factory = factory;
_writeGeometryBBox = writeGeometryBBox;
_idPropertyName = idPropertyName ?? DefaultIdPropertyName;
}

///<inheritdoc cref="JsonConverter.CanConvert(Type)"/>
public override bool CanConvert(Type typeToConvert)
{
return GeometryTypes.Contains(typeToConvert)
|| typeof(IFeature).IsAssignableFrom(typeToConvert)
|| typeToConvert == typeof(FeatureCollection)
|| typeof(IAttributesTable).IsAssignableFrom(typeToConvert);
}

///<inheritdoc cref="JsonConverterFactory.CreateConverter(Type, JsonSerializerOptions)"/>
public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options)
{
if (GeometryTypes.Contains(typeToConvert))
return new StjGeometryConverter(_factory, _writeGeometryBBox);
if (typeToConvert == typeof(FeatureCollection))
return new StjFeatureCollectionConverter();
if (typeof(IFeature).IsAssignableFrom(typeToConvert))
return new StjFeatureConverter(_idPropertyName);
if (typeof(IAttributesTable).IsAssignableFrom(typeToConvert))
return new StjAttributesTableConverter(_idPropertyName);

throw new ArgumentException(nameof(typeToConvert));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
namespace NetTopologySuite.IO.Converters
{
/// <summary>
/// Defines the GeoJSON Objects types as defined in the <a href="https://tools.ietf.org/html/rfc7946#section-3.1">RFC7946 of the Internet Engineering Task Force (IETF)</a>.
/// </summary>
internal enum GeoJsonObjectType
{
/// <summary>
/// Defines the <a href="https://tools.ietf.org/html/rfc7946#section-3.1.2">Point</a> type.
/// </summary>
Point,

/// <summary>
/// Defines the <a href="https://tools.ietf.org/html/rfc7946#section-3.1.3">MultiPoint</a> type.
/// </summary>
MultiPoint,

/// <summary>
/// Defines the <a href="https://tools.ietf.org/html/rfc7946#section-3.1.4">LineString</a> type.
/// </summary>
LineString,

/// <summary>
/// Defines the <a href="https://tools.ietf.org/html/rfc7946#section-3.1.5">MultiLineString</a> type.
/// </summary>
MultiLineString,

/// <summary>
/// Defines the <a href="https://tools.ietf.org/html/rfc7946#section-3.1.6">Polygon</a> type.
/// </summary>
Polygon,

/// <summary>
/// Defines the <a href="https://tools.ietf.org/html/rfc7946#section-3.1.7">MultiPolygon</a> type.
/// </summary>
MultiPolygon,

/// <summary>
/// Defines the <a href="https://tools.ietf.org/html/rfc7946#section-3.1.8">GeometryCollection</a> type.
/// </summary>
GeometryCollection,

/// <summary>
/// Defines the <a href="https://tools.ietf.org/html/rfc7946#section-3.2">Feature</a> type.
/// </summary>
Feature,

/// <summary>
/// Defines the <a href="https://tools.ietf.org/html/rfc7946#section-3.3">FeatureCollection</a> type.
/// </summary>
FeatureCollection
}
}
Loading

0 comments on commit a036218

Please sign in to comment.