-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
84 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using NUnit.Framework; | ||
using Wkx; | ||
|
||
namespace Triangulate.Tests | ||
{ | ||
public class GeometryExtensionsTests | ||
{ | ||
[Test] | ||
public void MultilinestringToPolyhedralSurfaceTest() | ||
{ | ||
var wkt = "MULTILINESTRING ((280986.414 5657433.423 41.401,280986.416 5657433.416 41.402,280986.527 5657433.0 41.426,280986.627 5657432.627 41.451,280986.795 5657432.0 41.502,280986.838 5657431.838 41.508,280987.0 5657431.232 41.525,280987.049 5657431.049 41.531,280987.062 5657431.0 41.529,280987.126 5657430.761 41.524),(280986.414 5657433.423 41.401,280986.423 5657433.423 41.402,280987.0 5657433.438 41.418,280987.45 5657433.45 41.431,280988.0 5657433.464 41.458,280988.476 5657433.476 41.476,280989.0 5657433.49 41.491,280989.503 5657433.503 41.505,280990.0 5657433.516 41.524,280990.529 5657433.529 41.534,280991.0 5657433.542 41.542,280991.556 5657433.556 41.541,280992.0 5657433.567 41.549,280992.198 5657433.572 41.558),(280992.198 5657433.572 41.558,280992.231 5657433.231 41.591,280992.254 5657433.0 41.605,280992.322 5657432.322 41.64,280992.354 5657432.0 41.657,280992.412 5657431.412 41.658,280992.421 5657431.324 41.659),(280992.421 5657431.324 41.659,280992.453 5657431.0 41.664,280992.485 5657430.68 41.649),(280987.126 5657430.761 41.524,280987.752 5657430.752 41.518,280988.0 5657430.748 41.525,280988.737 5657430.737 41.54,280989.0 5657430.733 41.545,280989.722 5657430.722 41.596,280990.0 5657430.718 41.599,280990.707 5657430.707 41.605,280991.0 5657430.702 41.608,280991.692 5657430.692 41.628,280992.0 5657430.687 41.634,280992.485 5657430.68 41.649))"; | ||
var multilinestring = (MultiLineString)Wkx.Geometry.Deserialize<WktSerializer>(wkt); | ||
var polyhedralsurface = multilinestring.ToPolyhedralSurface(); | ||
Assert.IsTrue(polyhedralsurface != null); | ||
Assert.IsTrue(polyhedralsurface.Geometries.Count == multilinestring.Geometries.Count); | ||
} | ||
|
||
[Test] | ||
public void MultipolygonZToPolyhedralSurfaceTest() | ||
{ | ||
var buildingWkt = "MULTIPOLYGON(((43603.770435546874 361514.6418164063 1.2790000438690186,43603.50600073242 361509.7590039063 1.2790000438690186,43598.60899755859 361510.0461132813 1.2790000438690186,43603.770435546874 361514.6418164063 1.2790000438690186)),((43599.11101171875 361520.242890625 1.2790000438690186,43604.058002685546 361519.95211914065 1.2790000438690186,43598.85057470703 361514.95309570315 1.2790000438690186,43599.11101171875 361520.242890625 1.2790000438690186)),((43598.85057470703 361514.95309570315 1.2790000438690186,43603.770435546874 361514.6418164063 1.2790000438690186,43598.60899755859 361510.0461132813 1.2790000438690186,43598.85057470703 361514.95309570315 1.2790000438690186)),((43604.058002685546 361519.95211914065 1.2790000438690186,43603.770435546874 361514.6418164063 1.2790000438690186,43598.85057470703 361514.95309570315 1.2790000438690186,43604.058002685546 361519.95211914065 1.2790000438690186)),((43598.60899755859 361510.0461132813 6.778176307678223,43598.85057470703 361514.95309570315 7.397906303405762,43598.85057470703 361514.95309570315 1.2790000438690186,43598.60899755859 361510.0461132813 6.778176307678223)),((43598.60899755859 361510.0461132813 1.2790000438690186,43598.60899755859 361510.0461132813 6.778176307678223,43598.85057470703 361514.95309570315 1.2790000438690186,43598.60899755859 361510.0461132813 1.2790000438690186)),((43603.770435546874 361514.6418164063 1.2790000438690186,43603.50600073242 361509.7590039063 6.764927387237549,43603.50600073242 361509.7590039063 1.2790000438690186,43603.770435546874 361514.6418164063 1.2790000438690186)),((43603.770435546874 361514.6418164063 1.2790000438690186,43603.770435546874 361514.6418164063 7.381703853607178,43603.50600073242 361509.7590039063 6.764927387237549,43603.770435546874 361514.6418164063 1.2790000438690186)),((43598.85057470703 361514.95309570315 1.2790000438690186,43599.11101171875 361520.242890625 6.854876518249512,43599.11101171875 361520.242890625 1.2790000438690186,43598.85057470703 361514.95309570315 1.2790000438690186)),((43598.85057470703 361514.95309570315 1.2790000438690186,43598.85057470703 361514.95309570315 7.397906303405762,43599.11101171875 361520.242890625 6.854876518249512,43598.85057470703 361514.95309570315 1.2790000438690186)),((43604.058002685546 361519.95211914065 6.836284160614014,43603.770435546874 361514.6418164063 7.381703853607178,43603.770435546874 361514.6418164063 1.2790000438690186,43604.058002685546 361519.95211914065 6.836284160614014)),((43604.058002685546 361519.95211914065 1.2790000438690186,43604.058002685546 361519.95211914065 6.836284160614014,43603.770435546874 361514.6418164063 1.2790000438690186,43604.058002685546 361519.95211914065 1.2790000438690186)),((43599.11101171875 361520.242890625 1.2790000438690186,43604.058002685546 361519.95211914065 6.836284160614014,43604.058002685546 361519.95211914065 1.2790000438690186,43599.11101171875 361520.242890625 1.2790000438690186)),((43599.11101171875 361520.242890625 1.2790000438690186,43599.11101171875 361520.242890625 6.854876518249512,43604.058002685546 361519.95211914065 6.836284160614014,43599.11101171875 361520.242890625 1.2790000438690186)),((43603.50600073242 361509.7590039063 6.764927387237549,43598.60899755859 361510.0461132813 6.778176307678223,43598.60899755859 361510.0461132813 1.2790000438690186,43603.50600073242 361509.7590039063 6.764927387237549)),((43603.50600073242 361509.7590039063 1.2790000438690186,43603.50600073242 361509.7590039063 6.764927387237549,43598.60899755859 361510.0461132813 1.2790000438690186,43603.50600073242 361509.7590039063 1.2790000438690186)),((43603.770435546874 361514.6418164063 7.381703853607178,43598.60899755859 361510.0461132813 6.778176307678223,43603.50600073242 361509.7590039063 6.764927387237549,43603.770435546874 361514.6418164063 7.381703853607178)),((43603.770435546874 361514.6418164063 7.381703853607178,43598.85057470703 361514.95309570315 7.397906303405762,43598.60899755859 361510.0461132813 6.778176307678223,43603.770435546874 361514.6418164063 7.381703853607178)),((43604.058002685546 361519.95211914065 6.836284160614014,43598.85057470703 361514.95309570315 7.397906303405762,43603.770435546874 361514.6418164063 7.381703853607178,43604.058002685546 361519.95211914065 6.836284160614014)),((43604.058002685546 361519.95211914065 6.836284160614014,43599.11101171875 361520.242890625 6.854876518249512,43598.85057470703 361514.95309570315 7.397906303405762,43604.058002685546 361519.95211914065 6.836284160614014)))"; | ||
var multipolygon = (MultiPolygon)Wkx.Geometry.Deserialize<WktSerializer>(buildingWkt); | ||
var polyhedralsurface = multipolygon.ToPolyhedralSurface(); | ||
Assert.IsTrue(polyhedralsurface != null); | ||
Assert.IsTrue(polyhedralsurface.Geometries.Count == multipolygon.Geometries.Count); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using Wkx; | ||
|
||
namespace Triangulate | ||
{ | ||
public static class GeometryExtensions | ||
{ | ||
public static PolyhedralSurface ToPolyhedralSurface(this MultiPolygon multipolygon) | ||
{ | ||
var polyhedralsurface = new PolyhedralSurface | ||
{ | ||
Dimension = Dimension.Xyz | ||
}; | ||
|
||
foreach (var polygon in multipolygon.Geometries) | ||
{ | ||
polyhedralsurface.Geometries.Add(polygon); | ||
} | ||
|
||
return polyhedralsurface; | ||
} | ||
|
||
public static PolyhedralSurface ToPolyhedralSurface(this MultiLineString multilinestring) | ||
{ | ||
var polyhedralsurface = new PolyhedralSurface | ||
{ | ||
Dimension = Dimension.Xyz | ||
}; | ||
|
||
foreach (var linestring in multilinestring.Geometries) | ||
{ | ||
var polygon = GetPolygon(linestring); | ||
polyhedralsurface.Geometries.Add(polygon); | ||
} | ||
|
||
return polyhedralsurface; | ||
} | ||
|
||
private static Polygon GetPolygon(LineString linestring) | ||
{ | ||
var polygon = new Polygon() | ||
{ | ||
Dimension = Dimension.Xyz | ||
}; | ||
|
||
polygon.ExteriorRing.Points.AddRange(linestring.Points); | ||
polygon.ExteriorRing.Points.Add(linestring.Points[linestring.Points.Count - 1]); | ||
|
||
return polygon; | ||
} | ||
} | ||
} |