Skip to content

Commit

Permalink
Merge branch 'release/1.7.10'
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelmathot committed Oct 17, 2016
2 parents 712a4cb + 788b599 commit 354fec5
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 6 deletions.
33 changes: 33 additions & 0 deletions Terradue.GeoJson.Tests/Gml32Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Terradue.GeoJson.Gml321;
using System.IO;
using System.Xml.Linq;
using Terradue.GeoJson.GeoRss;

namespace Terradue.GeoJson.Tests {

Expand Down Expand Up @@ -151,6 +152,38 @@ public void Gml32MultiSurfaceToGeorss()

}

[Test()]
public void Gml32MultiSurfaceToGeorss4()
{

var fs = new FileStream("../Samples/multisurface32-4.xml", FileMode.Open, FileAccess.Read);

XmlReader reader = XmlReader.Create(fs);

var gml = Terradue.ServiceModel.Ogc.Gml321.GmlHelper.Deserialize(reader);

fs.Close();

var geom = Terradue.GeoJson.Gml321.Gml321Extensions.ToGeometry(gml);

Assert.IsTrue(geom is MultiPolygon);

GeoRssWhere georss = (GeoRssWhere)geom.ToGeoRss();

Assert.AreEqual("multipolygon", georss.Type);

GeoRssWhere georss2 = (GeoRssWhere)GeoRssHelper.Deserialize(georss.CreateReader());

Assert.AreEqual("multipolygon", georss2.Type);

var geom2 = georss.ToGeometry();

Assert.IsTrue(geom2 is MultiPolygon);

var json = new Terradue.GeoJson.Feature.Feature(geom, null);

}

}
}

21 changes: 21 additions & 0 deletions Terradue.GeoJson.Tests/Samples/multisurface32-4.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<MultiSurface xmlns="http://www.opengis.net/gml/3.2">
<surfaceMembers>
<Polygon id="Polygon.S1A_EW_GRDM_1SDV_20180718T024458_20180718T024550_006859_009400_2D59.SAFE">
<exterior>
<LinearRing>
<posList>
-22.590622 39.202515 -25.680344 38.328693 -26.632673 42.423180 -23.519297 43.203957 -22.590622 39.202515
</posList>
</LinearRing>
</exterior>
</Polygon>
<Polygon id="Polygon.S1A_EW_GRDM_1SDV_20180718T024458_20180718T024550_006859_009400_2D59_2.SAFE">
<exterior>
<LinearRing>
<posList>0 0 0 10 10 10 10 0 0 0</posList>
</LinearRing>
</exterior>
</Polygon>
</surfaceMembers>
</MultiSurface>
1 change: 1 addition & 0 deletions Terradue.GeoJson.Tests/Terradue.GeoJson.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
<None Include="Samples\multisurface321withDBS.xml" />
<None Include="Samples\noa-ers-georss.xml" />
<None Include="Samples\multisurface32-3.xml" />
<None Include="Samples\multisurface32-4.xml" />
</ItemGroup>
<ItemGroup>
<Folder Include="Samples\" />
Expand Down
15 changes: 15 additions & 0 deletions Terradue.GeoJson.Tests/WktTransformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,21 @@ public void WktToPolygon()
Assert.AreEqual("Latitude: 24.8289604843644, Longitude: 92.9993725045111", geometry.LineStrings.First().Positions.First().ToString());

}

[Test()]
public void WktMPToPolygon()
{

string wkt = "MULTIPOINT (( 10 10 ))";

MultiPoint geometry = (MultiPoint)WktExtensions.WktToGeometry(wkt);

Assert.IsTrue(geometry is MultiPoint);


Assert.AreEqual("Latitude: 10, Longitude: 10", geometry.Points.First().Position.ToString());

}
}
}

6 changes: 3 additions & 3 deletions Terradue.GeoJson/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
@{
Terradue .NET GeoJson Library. Initially developed to provide an easy way to manage Geometry objects with serialization and deserialization functions and transformation functions from/to GeoJson, it also supports GML, georss and Well Known Text (WKT)
\xrefitem sw_version "Versions" "Software Package Version" 1.7.9
\xrefitem sw_version "Versions" "Software Package Version" 1.7.10
\xrefitem sw_link "Links" "Software Package List" [DotNetGeoJson](https://github.com/Terradue/DotNetGeoJson)
Expand Down Expand Up @@ -50,6 +50,6 @@
[assembly: AssemblyProjectUrl("https://github.com/Terradue/DotNetGeoJson")]
[assembly: AssemblyLicenseUrl("https://github.com/Terradue/DotNetGeoJson/blob/master/LICENSE")]
[assembly: AssemblyCopyright("Terradue")]
[assembly: AssemblyVersion("1.7.9.*")]
[assembly: AssemblyInformationalVersion("1.7.9")]
[assembly: AssemblyVersion("1.7.10.*")]
[assembly: AssemblyInformationalVersion("1.7.10")]

24 changes: 22 additions & 2 deletions Terradue.GeoJson/Terradue/GeoJson/GeoRss/GeoRssExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ public static GeometryObject ToGeometry(this Terradue.GeoJson.GeoRss.GeoRssWhere
return ((PolygonType)where.Item[0]).ToGeometry();
}

if (where.Item != null && where.Item.Count() > 0 && where.Item[0] is MultiPolygonType)
{
return ((MultiPolygonType)where.Item[0]).ToGeometry();
}

if (where.Item != null && where.Item.Count() > 0 && where.Item[0] is MultiCurveType) {
return ((MultiCurveType)where.Item[0]).ToGeometry();
}
Expand Down Expand Up @@ -249,12 +254,27 @@ public static Terradue.GeoJson.GeoRss.GeoRssWhere ToGeoRssWhere(this Point point

public static Terradue.GeoJson.GeoRss.GeoRssWhere ToGeoRssWhere(this MultiPolygon mpolygon) {

return new Terradue.GeoJson.GeoRss.GeoRssWhere(){ Item = mpolygon.Polygons.Select(p => p.ToGmlPolygon()).ToArray(), Type = mpolygon.Polygons.Count() > 1 ? "multipolygon" : null };
if (mpolygon.Polygons.Count() > 1)
{

return new Terradue.GeoJson.GeoRss.GeoRssWhere() { Item = new MultiPolygonType[] { mpolygon.ToGmlMultiPolygon() }, Type = "multipolygon" };
}
else {
return new Terradue.GeoJson.GeoRss.GeoRssWhere() { Item = new PolygonType[] { mpolygon.Polygons.First().ToGmlPolygon() } };
}
}

public static Terradue.GeoJson.GeoRss.GeoRssWhere ToGeoRssWhere(this MultiPoint mpoint) {

return new Terradue.GeoJson.GeoRss.GeoRssWhere(){ Item = mpoint.Points.Select(p => p.ToGmlPoint()).ToArray(), Type = mpoint.Points.Count() > 1 ? "multipoint" : null };
if (mpoint.Points.Count() > 1)
{

return new Terradue.GeoJson.GeoRss.GeoRssWhere() { Item = new MultiPointType[] { mpoint.ToGmlMultiPoint() }, Type = "multipoint" };
}
else {
return new Terradue.GeoJson.GeoRss.GeoRssWhere() { Item = new PointType[] { mpoint.Points.First().ToGmlPoint() } };
}

}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Terradue.GeoJson/Terradue/GeoJson/Wkt/WktExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public static MultiLineString MultiLineStringFromWKT(string wkt) {
/// <returns>The MultiPoint</returns>
/// <param name="wkt">WKT.</param>
public static MultiPoint MultiPointFromWKT(string wkt) {
string[] terms = wkt.TrimStart('(').TrimEnd(')').Split(',');
string[] terms = wkt.TrimStart('(').TrimEnd(')').Trim(' ').Split(',');
string[] values;
List<IPosition> points = new List<IPosition>(terms.Length);
for (int i = 0; i < terms.Length; i++) {
Expand Down

0 comments on commit 354fec5

Please sign in to comment.