public void TestMultiCurveRead() { string xml = @"<gml:MultiCurve xmlns:gml=""http://www.opengis.net/gml""> <gml:curveMember> <gml:LineString> <gml:posList>10 10 20 20 10 40</gml:posList> </gml:LineString> </gml:curveMember> <gml:curveMember> <gml:LineString> <gml:posList>40 40 30 30 40 20 30 10</gml:posList> </gml:LineString> </gml:curveMember> </gml:MultiCurve>"; var gr = new GMLReader(); foreach (var readMethod in GetReadMethods()) { var gc = (MultiLineString)readMethod(gr, xml); Assert.IsTrue(gc.NumGeometries == 2); for (int i = 0; i < 1; i++) { var g = gc.GetGeometryN(i); Assert.IsNotNull(g); Assert.IsInstanceOf(typeof(LineString), g); } } }
private static void DoTest(Type expectedType) { string name = expectedType.Name; string file = String.Format("{0}s", name.ToLowerInvariant().Substring(1)); string resname = String.Format("NetTopologySuite.Tests.NUnit.TestData.{0}.xml", file); string path = EmbeddedResourceManager.SaveEmbeddedResourceToTempFile(resname); var doc = #if !PCL new XmlDocument(); doc.Load(path); #else XDocument.Load(path); #endif GMLReader gr = new GMLReader(); IGeometryCollection gc = (IGeometryCollection)gr.Read(doc); Assert.IsTrue(gc.NumGeometries == 25); for (int i = 0; i < 25; i++) { IGeometry g = gc.GetGeometryN(i); Assert.IsNotNull(g); Assert.IsInstanceOf(expectedType, g); } }
public void CustomGeometryFactoryShouldBeAllowedWithSRID() { var pm = new PrecisionModel(10); const int initialSRID = 0; var csf = PackedCoordinateSequenceFactory.FloatFactory; const LinearRingOrientation orientation = LinearRingOrientation.Clockwise; var gf = new GeometryFactoryEx(pm, initialSRID, csf) { OrientationOfExteriorRing = orientation, }; const int expectedSRID = 4326; string xml = $@" <gml:Point srsName='urn:ogc:def:crs:EPSG::{expectedSRID}' xmlns:gml='http://www.opengis.net/gml'> <gml:coordinates>45.67, 65.43</gml:coordinates> </gml:Point>"; var gr = new GMLReader(gf); foreach (var readMethod in GetReadMethods()) { var pt = (Point)readMethod(gr, xml); Assert.That(pt.Factory, Is.InstanceOf <GeometryFactoryEx>() .With.Property(nameof(GeometryFactoryEx.SRID)).EqualTo(expectedSRID) .With.Property(nameof(GeometryFactoryEx.OrientationOfExteriorRing)).EqualTo(orientation) .With.Property(nameof(GeometryFactoryEx.PrecisionModel)).EqualTo(pm) .With.Property(nameof(GeometryFactoryEx.CoordinateSequenceFactory)).EqualTo(csf)); } }
private static GeometryCollection DoTest(Type expectedType) { string name = expectedType.Name; string file = string.Format("{0}s", name.ToLowerInvariant()); string resname = string.Format("NetTopologySuite.Tests.NUnit.TestData.{0}.xml", file); string xml = new StreamReader(EmbeddedResourceManager.GetResourceStream(resname)).ReadToEnd(); var gr = new GMLReader(); GeometryCollection gc = null; // different target frameworks have different overload sets... foreach (var readMethod in GetReadMethods()) { gc = (GeometryCollection)readMethod(gr, xml); Assert.IsTrue(gc.NumGeometries == 25); for (int i = 0; i < 25; i++) { var g = gc.GetGeometryN(i); Assert.IsNotNull(g); Assert.IsInstanceOf(expectedType, g); } } return(gc); }
public void TestPointWithBlankAfterCoordinates() { const string gml = "<gml:Point srsName=\"SDO:8265\" xmlns:gml=\"http://www.opengis.net/gml\"><gml:coordinates decimal=\".\" cs=\",\" ts=\" \">-89.5589359049658,44.535657997424 </gml:coordinates></gml:Point>"; var reader = new GMLReader(); var geom = reader.Read(gml); Assert.IsNotNull(geom); Assert.IsInstanceOf <IPoint>(geom); }
public void gml_reader_can_read_ToGMLFeature() { GMLReader reader = new GMLReader(); Point geom = new Point(52, -0.9); IGeometry actual = reader.Read(geom.ToGMLFeature()); Assert.That(actual, Is.Not.Null); Assert.That(actual.EqualsExact(geom), Is.True); }
public void gml_reader_can_read_gml_fragment() { GMLReader reader = new GMLReader(); string testFragment = GenerateTestFragment(); IGeometry actual = reader.Read(testFragment); Assert.That(actual, Is.Not.Null); Point geom = new Point(52, -0.9); Assert.That(actual.EqualsExact(geom), Is.True); }
/// <summary> /// Called when the "Import" button is clicked /// </summary> private void OnWizardCreate() { GameObject parentGameObject = new GameObject(); parentGameObject.name = this.ParentName; try { GMLReader gmlReader = new GMLReader(this.GMLSource.name /*RootElementName*/, this.GMLSource.text); MapBounds bounds = gmlReader.Bounds; // project geographic to web mercator... bounds.ProjectToWebMercator(); bounds.SetScale(this.HorizontalScale); this.UpdateCameraParameters(bounds.Center.ToVector3(), this.HorizontalScale, this.VerticalScale); foreach (MapFeature feature in gmlReader.Features) { if (feature.Geometry.IsEmpty) { continue; } // project geographic to web mercator... feature.Geometry.ProjectToWebMercator(); feature.Geometry.SetScale(this.HorizontalScale); // calculate object's centroid Vector3 cityOrigin = feature.Geometry.GetCentroid(); GameObject go = feature.ToGameObject(); go.transform.position = cityOrigin - bounds.Center.ToVector3(); go.transform.parent = parentGameObject.transform; Material material = new Material(Shader.Find("Standard")); material.color = UnityEngine.Random.ColorHSV(); go.GetComponent <Renderer>().material = material; //if (this.Extrude == true) //{ // // TODO: get extrusion values from a field.... // // TODO: use this.ExtrusionFactor // MeshExtrusion.Extrude(go, UnityEngine.Random.Range(1, 500), this.InvertFaces); //} } } catch (Exception ex) { Debug.Log(ex); } }
public static IGeometry GetGeometryFromGml(string gml) { gml = ReplaceObsoleteGmlTag(gml); try { IGeometry geometry = new GMLReader().Read(gml); return(geometry); } catch (Exception ex) { throw new ArgumentException("Input not instance of geometry", ex); } }
public LaixerBagReader() { Console.WriteLine("Starting to open the file..........."); gmlReader = new GMLReader(); XmlReaderSettings settings = new XmlReaderSettings { Async = true }; reader = XmlReader.Create(filename, settings); var table = reader.NameTable; manager = new XmlNamespaceManager(table); FillXMLNSManager(); }
public GMLTesting() { _point = Factory.CreatePoint(new Coordinate(100, 100)); Coordinate[] coordinates = { new Coordinate(10, 10), new Coordinate(20, 20), new Coordinate(20, 10) }; _line = Factory.CreateLineString(coordinates); coordinates = new[] { new Coordinate(100, 100), new Coordinate(200, 100), new Coordinate(200, 200), new Coordinate(100, 200), new Coordinate(100, 100) }; Coordinate[] interior1 = { new Coordinate(120, 120), new Coordinate(180, 120), new Coordinate(180, 180), new Coordinate(120, 180), new Coordinate(120, 120) }; var linearRing = Factory.CreateLinearRing(coordinates); LinearRing[] holes = { Factory.CreateLinearRing(interior1) }; _polygon = Factory.CreatePolygon(linearRing, holes); coordinates = new[] { new Coordinate(100, 100), new Coordinate(200, 200), new Coordinate(300, 300), new Coordinate(400, 400), new Coordinate(500, 500) }; _multiPoint = Factory.CreateMultiPointFromCoords(coordinates); _writer = new GMLWriter(); _reader = new GMLReader(); }
/// <summary> /// /// </summary> public GMLTesting() { point = Factory.CreatePoint(new Coordinate(100, 100)); ICoordinate[] coordinates = new ICoordinate[] { new Coordinate(10, 10), new Coordinate(20, 20), new Coordinate(20, 10), }; line = Factory.CreateLineString(coordinates); coordinates = new ICoordinate[] { new Coordinate(100, 100), new Coordinate(200, 100), new Coordinate(200, 200), new Coordinate(100, 200), new Coordinate(100, 100), }; ICoordinate[] interior1 = new ICoordinate[] { new Coordinate(120, 120), new Coordinate(180, 120), new Coordinate(180, 180), new Coordinate(120, 180), new Coordinate(120, 120), }; ILinearRing linearRing = Factory.CreateLinearRing(coordinates); ILinearRing[] holes = new ILinearRing[] { Factory.CreateLinearRing(interior1), }; polygon = Factory.CreatePolygon(linearRing, holes); coordinates = new ICoordinate[] { new Coordinate(100, 100), new Coordinate(200, 200), new Coordinate(300, 300), new Coordinate(400, 400), new Coordinate(500, 500), }; multiPoint = Factory.CreateMultiPoint(coordinates); writer = new GMLWriter(); reader = new GMLReader(); }
public void gml_writer_generates_fragment_with_namespace_if_needed() { XmlDocument doc = new XmlDocument(); Point geom = new Point(52, -0.9); doc.Load(geom.ToGMLFeature()); string content = doc.OuterXml; Assert.That(content, Is.Not.Null); Assert.That(content.StartsWith("<gml:Point xmlns:gml=\"http://www.opengis.net/gml\""), Is.True); GMLReader reader = new GMLReader(); IGeometry actual = reader.Read(content); Assert.That(actual, Is.Not.Null); Assert.That(actual.EqualsExact(geom), Is.True); }
public void TestMultiSurfaceRead() { string xml = @"<gml:MultiSurface xmlns:gml=""http://www.opengis.net/gml\""> <gml:surfaceMember> <gml:Polygon> <gml:exterior> <gml:LinearRing> <gml:posList>40 40 20 45 45 30 40 40</gml:posList> </gml:LinearRing> </gml:exterior> </gml:Polygon> </gml:surfaceMember> <gml:surfaceMember> <gml:Polygon> <gml:exterior> <gml:LinearRing> <gml:posList>20 35 10 30 10 10 30 5 45 20 20 35</gml:posList> </gml:LinearRing> </gml:exterior> <gml:interior> <gml:LinearRing> <gml:posList>30 20 20 15 20 25 30 20</gml:posList> </gml:LinearRing> </gml:interior> </gml:Polygon> </gml:surfaceMember> </gml:MultiSurface>"; var gr = new GMLReader(); foreach (var readMethod in GetReadMethods()) { var gc = (MultiPolygon)readMethod(gr, xml); Assert.IsTrue(gc.NumGeometries == 2); for (int i = 0; i < 1; i++) { var g = gc.GetGeometryN(i); Assert.IsNotNull(g); Assert.IsInstanceOf(typeof(Polygon), g); } } }
private void CheckRead(string gml, string wktExpected, int srid) { gml = gml.Replace("gml:", ""); var gr = new GMLReader(geometryFactory); Geometry g = null; try { g = gr.Read(gml); } catch (Exception e) { //e.printStackTrace(); Assert.Fail(e.Message); } var expected = Read(wktExpected); CheckEqual(expected, g); Assert.AreEqual(srid, g.SRID, "SRID incorrect - "); }
/// <summary> /// Initializes a new instance of the <see cref="Geometry"/> class. /// </summary> /// <param name="gml">The GML.</param> public Geometry(string gml) { GMLReader gmlReader = new GMLReader(); this.Value = gmlReader.Read(gml); }
public static Geometry FromGml(string gml) { var reader = new GMLReader(); return(reader.Read(gml)); }