public void TopoJsonWriterWrittenContentTest() { GeometryFactory factory = new GeometryFactory(); IMultiPolygon mp = factory.CreateMultiPolygon ( new List <IPolygon> { factory.CreatePolygon(factory.CreatePoint(10, 10), factory.CreatePoint(20, 10), factory.CreatePoint(25, 17), factory.CreatePoint(10, 10)), factory.CreatePolygon(factory.CreatePoint(50, 30), factory.CreatePoint(40, 20), factory.CreatePoint(20, 10), factory.CreatePoint(25, 17), factory.CreatePoint(30, 30), factory.CreatePoint(50, 30)) } ); Assert.AreEqual(2, mp.Count); IMultiPoint p = factory.CreateMultiPoint( new IPoint[2] { factory.CreatePoint(10, 10), factory.CreatePoint(23, 23) }); ILineString lstr = factory.CreateLineString( factory.CreatePoint(50, 60), factory.CreatePoint(55, 60), factory.CreatePoint(71, 71) ); List <IGeometry> geo = new List <IGeometry>() { p, lstr }; string outFileName = _outputPath + ".topojson"; TopoJsonWriter writer = new TopoJsonWriter(outFileName); writer.Write(mp as IGeometry); writer.Write(geo); writer.Close(); TopoJsonReader reader = new TopoJsonReader(outFileName); IList <IGeometry> geometries = reader.ReadToEnd(); reader.Close(); GeometryComparer comp = new GeometryComparer(); Assert.AreEqual(0, comp.Compare(geometries[0], mp)); Assert.AreEqual(0, comp.Compare(geometries[1], p)); Assert.AreEqual(0, comp.Compare(geometries[2], lstr)); }
private void CheckGeometry() { Message("Starting - Geometry Check"); GeometryComparer gc = new GeometryComparer(); Xbim3DModelContext baseContext = new Xbim3DModelContext(Baseline); Xbim3DModelContext revisionContext = new Xbim3DModelContext(Revision); //we have to sort out comparision and units, this assumes they are both in the same units at the moment //suggest all geometry is kept in metres SI var results = gc.Compare(baseContext, revisionContext, Baseline.ModelFactors.OneMilliMetre); //update working copies as we go with those still yet to resolve WorkingCopyBaseline.Clear(); WorkingCopyDelta.Clear(); foreach (var item in results.Where(x => x.Value == ChangeType.Matched)) { Message(String.Format("Found a Match for type {1} with GUID: {0}", item.Key.GlobalId, item.Key.GetType().ToString())); EntityLabelChanges[item.Key] = item.Value; } foreach (var item in results.Where(x => x.Value == ChangeType.Added)) { WorkingCopyDelta.Add(item.Key); Message(String.Format("Found a new item of type {1} with GUID: {0}", item.Key.GlobalId, item.Key.GetType().ToString())); EntityLabelChanges[item.Key] = item.Value; } foreach (var item in results.Where(x => x.Value == ChangeType.Deleted)) { WorkingCopyBaseline.Add(item.Key); Message(String.Format("Found a missing item of type {1} with GUID: {0}", item.Key.GlobalId, item.Key.GetType().ToString())); EntityLabelChanges[item.Key] = item.Value; } foreach (var item in results.Where(x => x.Value == ChangeType.Unknown)) { WorkingCopyBaseline.Add(item.Key); Message(String.Format("Found duplicate possibilities for item of type {1} with GUID: {0}", item.Key.GlobalId, item.Key.GetType().ToString())); EntityLabelChanges[item.Key] = item.Value; } var m = gc.GetMap(); foreach (var key in m) { EntityMapping[key.Key] = m[key.Key]; } Message("Geometry Check - complete"); }
public void TopoJsonReaderReadContentTest() { GeometryFactory factory = new GeometryFactory(); //test 1st input file TopoJsonReader reader = new TopoJsonReader(_inputFilePaths[0]); IGeometry result = reader.Read(); Assert.IsInstanceOf(typeof(IGeometryCollection <IGeometry>), result); IGeometryCollection <IGeometry> collection = result as IGeometryCollection <IGeometry>; Assert.AreEqual(2, collection.Count); Assert.IsInstanceOf(typeof(IPolygon), collection[0]); Assert.IsInstanceOf(typeof(IPolygon), collection[1]); IPolygon left_polygon = factory.CreatePolygon(new Coordinate[] { new Coordinate(1, 2), new Coordinate(1, 0), new Coordinate(0, 0), new Coordinate(0, 2), new Coordinate(1, 2) }); IPolygon right_polygon = factory.CreatePolygon(new Coordinate[] { new Coordinate(1, 2), new Coordinate(2, 2), new Coordinate(2, 0), new Coordinate(1, 0), new Coordinate(1, 2) }); GeometryComparer comp = new GeometryComparer(); //System.Diagnostics.Debug.WriteLine((collection[0] as IPolygon).Shell.ToString()); Assert.AreEqual(0, comp.Compare(collection[0], left_polygon)); Assert.AreEqual(0, comp.Compare(collection[1], right_polygon)); reader.Close(); }
public void SetUp() { this.factory = new GeometryFactory(); this.geometries = new IGeometry[] { this.factory.CreatePoint(1, 1), this.factory.CreateLineString(Enumerable.Range(1, 4).Select(i => new Coordinate(-i / 2.0, i / 2.0))), this.factory.CreatePolygon(Enumerable.Range(1, 4).Select(i => new Coordinate(i, i)), new Coordinate[][] { Enumerable.Range(1, 4).Select(i => new Coordinate(i, i)).ToArray(), Enumerable.Range(1, 4).Select(i => new Coordinate(i, i)).ToArray() }), this.factory.CreateMultiPoint(Enumerable.Range(1, 4).Select(i => this.factory.CreatePoint(i / 2.0, i / 2.0))), this.factory.CreateMultiLineString(new ILineString[] { this.factory.CreateLineString(Enumerable.Range(1, 4).Select(i => new Coordinate(i, i))), this.factory.CreateLineString(Enumerable.Range(1, 4).Select(i => new Coordinate(i / 2.0, i / 2.0))) }), this.factory.CreateMultiPolygon(new IPolygon[] { this.factory.CreatePolygon(Enumerable.Range(1, 4).Select(i => new Coordinate(i, i)), new Coordinate[][] { Enumerable.Range(1, 4).Select(i => new Coordinate(i, i)).ToArray(), Enumerable.Range(1, 4).Select(i => new Coordinate(i, i)).ToArray() }), this.factory.CreatePolygon(Enumerable.Range(1, 4).Select(i => new Coordinate(i / 2.0, i / 2.0))) }) }; this.geometriesText = new String[] { "POINT (1 1)", "LINESTRING (-0.5 0.5, -1 1, -1.5 1.5, -2 2)", "POLYGON ((1 1, 2 2, 3 3, 4 4, 1 1), (1 1, 2 2, 3 3, 4 4, 1 1), (1 1, 2 2, 3 3, 4 4, 1 1))", "MULTIPOINT (0.5 0.5, 1 1, 1.5 1.5, 2 2)", "MULTILINESTRING ((1 1, 2 2, 3 3, 4 4), (0.5 0.5, 1 1, 1.5 1.5, 2 2))", "MULTIPOLYGON (((1 1, 2 2, 3 3, 4 4, 1 1), (1 1, 2 2, 3 3, 4 4, 1 1), (1 1, 2 2, 3 3, 4 4, 1 1)), ((0.5 0.5, 1 1, 1.5 1.5, 2 2, 0.5 0.5)))" }; this.geometryComparer = new GeometryComparer(); }
public void SetUp() { _envelope = new Envelope(10, 20, 10, 20, 0, 0); _polygon = new List <Coordinate>() { new Coordinate(1, 0), new Coordinate(0, 2), new Coordinate(3, 2), new Coordinate(2, 0) }; _lineStrings = new List <List <Coordinate> >() { new List <Coordinate>() { new Coordinate(5, 15), new Coordinate(15, 15), new Coordinate(25, 15) }, new List <Coordinate>() { new Coordinate(0, 1), new Coordinate(2, 1), new Coordinate(3, 1) }, new List <Coordinate>() { new Coordinate(5, 22), new Coordinate(25, 22) } }; _comparer = new GeometryComparer(); }
public void SetUp() { this.factory = new GeometryFactory(); this.geometries = new IGeometry[] { this.factory.CreatePoint(1.5, 1.5), this.factory.CreateLineString(Enumerable.Range(1, 4).Select(i => new Coordinate(-i / 2.0, i / 2.0))), this.factory.CreatePolygon(Enumerable.Range(1, 4).Select(i => new Coordinate(i, i)), new Coordinate[][] { Enumerable.Range(1, 4).Select(i => new Coordinate(i, i)).ToArray(), Enumerable.Range(1, 4).Select(i => new Coordinate(i, i)).ToArray() }), this.factory.CreateMultiPoint(Enumerable.Range(1, 4).Select(i => this.factory.CreatePoint(i / 2.0, i / 2.0))), this.factory.CreateMultiLineString(new ILineString[] { this.factory.CreateLineString(Enumerable.Range(1, 4).Select(i => new Coordinate(i, i))), this.factory.CreateLineString(Enumerable.Range(1, 4).Select(i => new Coordinate(i / 2.0, i / 2.0))) }), this.factory.CreateMultiPolygon(new IPolygon[] { this.factory.CreatePolygon(Enumerable.Range(1, 4).Select(i => new Coordinate(i, i)), new Coordinate[][] { Enumerable.Range(1, 4).Select(i => new Coordinate(i, i)).ToArray(), Enumerable.Range(1, 4).Select(i => new Coordinate(i, i)).ToArray() }), this.factory.CreatePolygon(Enumerable.Range(1, 4).Select(i => new Coordinate(i / 2.0, i / 2.0))) }) }; this.mockReferenceSystem = new Mock <IReferenceSystem>(MockBehavior.Strict); this.mockReferenceSystem.Setup(referenceSystem => referenceSystem.Code).Returns(1000); this.mockReferenceSystem.Setup(referenceSystem => referenceSystem.Dimension).Returns(2); this.mockReferenceSystemFactory = new Mock <IReferenceSystemFactory>(MockBehavior.Strict); this.mockReferenceSystemFactory.Setup(factory => factory.CreateReferenceSystemFromIdentifier("EPSG::1000")).Returns(this.mockReferenceSystem.Object); GeometryFactory factoryWithReference = new GeometryFactory(this.mockReferenceSystem.Object); this.geometriesWithReference = new IGeometry[] { factoryWithReference.CreatePoint(1.5, 1.5), factoryWithReference.CreateLineString(Enumerable.Range(1, 4).Select(i => new Coordinate(-i / 2.0, i / 2.0))), factoryWithReference.CreatePolygon(Enumerable.Range(1, 4).Select(i => new Coordinate(i, i)), new Coordinate[][] { Enumerable.Range(1, 4).Select(i => new Coordinate(i, i)).ToArray(), Enumerable.Range(1, 4).Select(i => new Coordinate(i, i)).ToArray() }), factoryWithReference.CreateMultiPoint(Enumerable.Range(1, 4).Select(i => this.factory.CreatePoint(i / 2.0, i / 2.0))), factoryWithReference.CreateMultiLineString(new ILineString[] { this.factory.CreateLineString(Enumerable.Range(1, 4).Select(i => new Coordinate(i, i))), this.factory.CreateLineString(Enumerable.Range(1, 4).Select(i => new Coordinate(i / 2.0, i / 2.0))) }), factoryWithReference.CreateMultiPolygon(new IPolygon[] { factoryWithReference.CreatePolygon(Enumerable.Range(1, 4).Select(i => new Coordinate(i, i)), new Coordinate[][] { Enumerable.Range(1, 4).Select(i => new Coordinate(i, i)).ToArray(), Enumerable.Range(1, 4).Select(i => new Coordinate(i, i)).ToArray() }), factoryWithReference.CreatePolygon(Enumerable.Range(1, 4).Select(i => new Coordinate(i / 2.0, i / 2.0))) }) }; this.geometriesMarkup = new String[] { "<gml:Point xmlns:gml=\"http://www.opengis.net/gml/\"><gml:pos>1.5 1.5</gml:pos></gml:Point>", "<gml:LineString xmlns:gml=\"http://www.opengis.net/gml/\"><gml:posList>-0.5 0.5 -1 1 -1.5 1.5 -2 2</gml:posList></gml:LineString>", "<gml:Polygon xmlns:gml=\"http://www.opengis.net/gml/\"><gml:outerBoundaryIs><gml:LinearRing><gml:posList>1 1 2 2 3 3 4 4 1 1</gml:posList></gml:LinearRing></gml:outerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:posList>1 1 2 2 3 3 4 4 1 1</gml:posList></gml:LinearRing></gml:innerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:posList>1 1 2 2 3 3 4 4 1 1</gml:posList></gml:LinearRing></gml:innerBoundaryIs></gml:Polygon>", "<gml:MultiPoint xmlns:gml=\"http://www.opengis.net/gml/\"><gml:posList>0.5 0.5 1 1 1.5 1.5 2 2</gml:posList></gml:MultiPoint>", "<gml:MultiLineString xmlns:gml=\"http://www.opengis.net/gml/\"><gml:LineStringMember><gml:LineString><gml:posList>1 1 2 2 3 3 4 4</gml:posList></gml:LineString></gml:LineStringMember><gml:LineStringMember><gml:LineString><gml:posList>0.5 0.5 1 1 1.5 1.5 2 2</gml:posList></gml:LineString></gml:LineStringMember></gml:MultiLineString>", "<gml:MultiPolygon xmlns:gml=\"http://www.opengis.net/gml/\"><gml:PolygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:posList>1 1 2 2 3 3 4 4 1 1</gml:posList></gml:LinearRing></gml:outerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:posList>1 1 2 2 3 3 4 4 1 1</gml:posList></gml:LinearRing></gml:innerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:posList>1 1 2 2 3 3 4 4 1 1</gml:posList></gml:LinearRing></gml:innerBoundaryIs></gml:Polygon></gml:PolygonMember><gml:PolygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:posList>0.5 0.5 1 1 1.5 1.5 2 2 0.5 0.5</gml:posList></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:PolygonMember></gml:MultiPolygon>" }; this.identifier = "12345678"; this.geometriesMarkupWithIdentifier = new String[] { "<gml:Point gml:id=\"12345678\" xmlns:gml=\"http://www.opengis.net/gml/\"><gml:pos>1.5 1.5</gml:pos></gml:Point>", "<gml:LineString gml:id=\"12345678\" xmlns:gml=\"http://www.opengis.net/gml/\"><gml:posList>-0.5 0.5 -1 1 -1.5 1.5 -2 2</gml:posList></gml:LineString>", "<gml:Polygon gml:id=\"12345678\" xmlns:gml=\"http://www.opengis.net/gml/\"><gml:outerBoundaryIs><gml:LinearRing><gml:posList>1 1 2 2 3 3 4 4 1 1</gml:posList></gml:LinearRing></gml:outerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:posList>1 1 2 2 3 3 4 4 1 1</gml:posList></gml:LinearRing></gml:innerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:posList>1 1 2 2 3 3 4 4 1 1</gml:posList></gml:LinearRing></gml:innerBoundaryIs></gml:Polygon>", "<gml:MultiPoint gml:id=\"12345678\" xmlns:gml=\"http://www.opengis.net/gml/\"><gml:posList>0.5 0.5 1 1 1.5 1.5 2 2</gml:posList></gml:MultiPoint>", "<gml:MultiLineString gml:id=\"12345678\" xmlns:gml=\"http://www.opengis.net/gml/\"><gml:LineStringMember><gml:LineString><gml:posList>1 1 2 2 3 3 4 4</gml:posList></gml:LineString></gml:LineStringMember><gml:LineStringMember><gml:LineString><gml:posList>0.5 0.5 1 1 1.5 1.5 2 2</gml:posList></gml:LineString></gml:LineStringMember></gml:MultiLineString>", "<gml:MultiPolygon gml:id=\"12345678\" xmlns:gml=\"http://www.opengis.net/gml/\"><gml:PolygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:posList>1 1 2 2 3 3 4 4 1 1</gml:posList></gml:LinearRing></gml:outerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:posList>1 1 2 2 3 3 4 4 1 1</gml:posList></gml:LinearRing></gml:innerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:posList>1 1 2 2 3 3 4 4 1 1</gml:posList></gml:LinearRing></gml:innerBoundaryIs></gml:Polygon></gml:PolygonMember><gml:PolygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:posList>0.5 0.5 1 1 1.5 1.5 2 2 0.5 0.5</gml:posList></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:PolygonMember></gml:MultiPolygon>" }; this.geometriesMarkupWithReference = new String[] { "<gml:Point srsName=\"http://www.opengis.net/def/crs/EPSG/0/1000\" srsDimension=\"2\" xmlns:gml=\"http://www.opengis.net/gml/\"><gml:pos>1.5 1.5</gml:pos></gml:Point>", "<gml:LineString srsName=\"http://www.opengis.net/def/crs/EPSG/0/1000\" srsDimension=\"2\" xmlns:gml=\"http://www.opengis.net/gml/\"><gml:posList>-0.5 0.5 -1 1 -1.5 1.5 -2 2</gml:posList></gml:LineString>", "<gml:Polygon srsName=\"http://www.opengis.net/def/crs/EPSG/0/1000\" srsDimension=\"2\" xmlns:gml=\"http://www.opengis.net/gml/\"><gml:outerBoundaryIs><gml:LinearRing><gml:posList>1 1 2 2 3 3 4 4 1 1</gml:posList></gml:LinearRing></gml:outerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:posList>1 1 2 2 3 3 4 4 1 1</gml:posList></gml:LinearRing></gml:innerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:posList>1 1 2 2 3 3 4 4 1 1</gml:posList></gml:LinearRing></gml:innerBoundaryIs></gml:Polygon>", "<gml:MultiPoint srsName=\"http://www.opengis.net/def/crs/EPSG/0/1000\" srsDimension=\"2\" xmlns:gml=\"http://www.opengis.net/gml/\"><gml:posList>0.5 0.5 1 1 1.5 1.5 2 2</gml:posList></gml:MultiPoint>", "<gml:MultiLineString srsName=\"http://www.opengis.net/def/crs/EPSG/0/1000\" srsDimension=\"2\" xmlns:gml=\"http://www.opengis.net/gml/\"><gml:LineStringMember><gml:LineString><gml:posList>1 1 2 2 3 3 4 4</gml:posList></gml:LineString></gml:LineStringMember><gml:LineStringMember><gml:LineString><gml:posList>0.5 0.5 1 1 1.5 1.5 2 2</gml:posList></gml:LineString></gml:LineStringMember></gml:MultiLineString>", "<gml:MultiPolygon srsName=\"http://www.opengis.net/def/crs/EPSG/0/1000\" srsDimension=\"2\" xmlns:gml=\"http://www.opengis.net/gml/\"><gml:PolygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:posList>1 1 2 2 3 3 4 4 1 1</gml:posList></gml:LinearRing></gml:outerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:posList>1 1 2 2 3 3 4 4 1 1</gml:posList></gml:LinearRing></gml:innerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:posList>1 1 2 2 3 3 4 4 1 1</gml:posList></gml:LinearRing></gml:innerBoundaryIs></gml:Polygon></gml:PolygonMember><gml:PolygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:posList>0.5 0.5 1 1 1.5 1.5 2 2 0.5 0.5</gml:posList></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:PolygonMember></gml:MultiPolygon>" }; this.geometryComparer = new GeometryComparer(); }
public void SetUp() { _envelope = new Envelope(10, 20, 10, 20, 0, 0); _lineStrings = new List <List <Coordinate> >() { new List <Coordinate>() { new Coordinate(5, 15), new Coordinate(15, 15), new Coordinate(25, 15) }, new List <Coordinate>() { new Coordinate(5, 15), new Coordinate(14, 15), new Coordinate(18, 15), new Coordinate(25, 15) }, new List <Coordinate>() { new Coordinate(5, 15), new Coordinate(25, 15) }, new List <Coordinate>() { new Coordinate(5, 12), new Coordinate(25, 12), new Coordinate(25, 18), new Coordinate(5, 18) }, new List <Coordinate>() { new Coordinate(5, 25), new Coordinate(25, 25) } }; _basicLineString = new BasicLineString( new List <Coordinate>() { new Coordinate(5, 15), new Coordinate(15, 15), new Coordinate(25, 15) }); _basicPolygons = new List <IBasicPolygon>() { new BasicPolygon( new List <Coordinate>() { new Coordinate(5, 12), new Coordinate(25, 12), new Coordinate(25, 18), new Coordinate(5, 18) }), new BasicPolygon( new List <Coordinate>() { new Coordinate(5, 12), new Coordinate(25, 12), new Coordinate(25, 18), new Coordinate(5, 18) }) }; _comparer = new GeometryComparer(); }