public void TestGetPropertiesAmsterdam() { Config.activeConfiguration = new ConfigurationFile(); Config.activeConfiguration.sewerageApiType = Amsterdam3D.Sewerage.SewerageApiType.Amsterdam; SewerageLayer seweragelayer = new SewerageLayer(); GeoJSON geojson = new GeoJSON(testStringAmsterdam); geojson.GotoNextFeature(); double diameter1 = geojson.getPropertyFloatValue(seweragelayer.DiameterString); double bobBeginPunt1 = geojson.getPropertyFloatValue(seweragelayer.BobBeginPuntString); double bobEindPunt1 = geojson.getPropertyFloatValue(seweragelayer.BobEindPuntString); Assert.AreEqual(297, diameter1); Assert.AreEqual(-1, bobBeginPunt1); Assert.AreEqual(-1.6, bobEindPunt1, 0.1); geojson.GotoNextFeature(); double diameter2 = geojson.getPropertyFloatValue(seweragelayer.DiameterString); double bobBeginPunt2 = geojson.getPropertyFloatValue(seweragelayer.BobBeginPuntString); double bobEindPunt2 = geojson.getPropertyFloatValue(seweragelayer.BobEindPuntString); Assert.AreEqual(234, diameter2); Assert.AreEqual(-1, bobBeginPunt2); Assert.AreEqual(-1.1, bobEindPunt2, 0.1); }
public void TestManholesPropertiesPdok() { Config.activeConfiguration = new ConfigurationFile(); Config.activeConfiguration.sewerageApiType = Amsterdam3D.Sewerage.SewerageApiType.Pdok; SewerageLayer seweragelayer = new SewerageLayer(); GeoJSON geojson = new GeoJSON(testStringManholesPdok); geojson.GotoNextFeature(); var putdekselhoogte1 = geojson.getPropertyFloatValue(seweragelayer.PutdekselhoogteString); var point1 = geojson.getGeometryPoint2DDouble(); Assert.AreEqual(1.530, putdekselhoogte1, 0.001); Assert.AreEqual(2, point1.Length); Assert.AreEqual(132303.35, point1[0], 0.001); Assert.AreEqual(457990.35, point1[1], 0.001); geojson.GotoNextFeature(); var putdekselhoogte2 = geojson.getPropertyFloatValue(seweragelayer.PutdekselhoogteString); var point2 = geojson.getGeometryPoint2DDouble(); Assert.AreEqual(1.540, putdekselhoogte2, 0.001); Assert.AreEqual(2, point2.Length); Assert.AreEqual(132347.73, point2[0], 0.001); Assert.AreEqual(457958.06, point2[1], 0.001); }
public void TestManholesPropertiesAmsterdam() { Config.activeConfiguration = new ConfigurationFile(); Config.activeConfiguration.sewerageApiType = Amsterdam3D.Sewerage.SewerageApiType.Amsterdam; SewerageLayer seweragelayer = new SewerageLayer(); GeoJSON geojson = new GeoJSON(testStringManholesAmsterdam); geojson.GotoNextFeature(); var putdekselhoogte1 = geojson.getPropertyFloatValue(seweragelayer.PutdekselhoogteString); var point1 = geojson.getGeometryPoint2DDouble(); Assert.AreEqual(0.20, putdekselhoogte1, 0.001); Assert.AreEqual(2, point1.Length); Assert.AreEqual(4.91561158208928, point1[0], 0.001); Assert.AreEqual(52.342962335247, point1[1], 0.001); geojson.GotoNextFeature(); var putdekselhoogte2 = geojson.getPropertyFloatValue(seweragelayer.PutdekselhoogteString); var point2 = geojson.getGeometryPoint2DDouble(); Assert.AreEqual(0.68, putdekselhoogte2, 0.001); Assert.AreEqual(2, point2.Length); Assert.AreEqual(4.90876406244186, point2[0], 0.001); Assert.AreEqual(52.3425051475584, point2[1], 0.001); }
public void TestCoordinatesPdok() { Config.activeConfiguration = new ConfigurationFile(); Config.activeConfiguration.sewerageApiType = Amsterdam3D.Sewerage.SewerageApiType.Pdok; SewerageLayer seweragelayer = new SewerageLayer(); GeoJSON geojson = new GeoJSON(testStringPdok); geojson.GotoNextFeature(); var geom1 = geojson.getGeometryLineString(); Assert.AreEqual(4, geom1.Count); Assert.AreEqual(geom1[0], 132803.42, 0.1); Assert.AreEqual(geom1[1], 457145.83, 0.1); Assert.AreEqual(geom1[2], 132798.02, 0.1); Assert.AreEqual(geom1[3], 457153.57, 0.1); geojson.GotoNextFeature(); var geom2 = geojson.getGeometryLineString(); Assert.AreEqual(4, geom2.Count); Assert.AreEqual(geom2[0], 132652.29, 0.1); Assert.AreEqual(geom2[1], 457103.23, 0.1); Assert.AreEqual(geom2[2], 132655.03, 0.1); Assert.AreEqual(geom2[3], 457110.39, 0.1); }
public void TestCoordinatesAmsterdam() { Config.activeConfiguration = new ConfigurationFile(); Config.activeConfiguration.sewerageApiType = Amsterdam3D.Sewerage.SewerageApiType.Amsterdam; SewerageLayer seweragelayer = new SewerageLayer(); GeoJSON geojson = new GeoJSON(testStringAmsterdam); geojson.GotoNextFeature(); var geom1 = geojson.getGeometryLineString(); Assert.AreEqual(4, geom1.Count); Assert.AreEqual(geom1[0], 4.90698478562009, 0.000001); Assert.AreEqual(geom1[1], 52.3429529014738, 0.000001); Assert.AreEqual(geom1[2], 4.90702608778446, 0.000001); Assert.AreEqual(geom1[3], 52.3428382055533, 0.000001); geojson.GotoNextFeature(); var geom2 = geojson.getGeometryLineString(); Assert.AreEqual(4, geom2.Count); Assert.AreEqual(geom2[0], 4.90698478562009, 0.000001); Assert.AreEqual(geom2[1], 52.3429529014738, 0.000001); Assert.AreEqual(geom2[2], 4.90665251262403, 0.000001); Assert.AreEqual(geom2[3], 52.3429023897671, 0.000001); }
private IEnumerator SpawnManHoleObjects(string geoJSONtext, TileChange tileChange, Tile tile, System.Action <TileChange> callback = null) { tile.gameObject.SetActive(isEnabled); GeoJSON customJsonHandler = new GeoJSON(geoJSONtext); yield return(null); double[] point2D; Vector3 point; int parseCounter = 0; while (customJsonHandler.GotoNextFeature()) { parseCounter++; if ((parseCounter % maxParsesPerFrame) == 0) { yield return(new WaitForEndOfFrame()); } if (customJsonHandler.PropertyValueStringEquals("objectsoort", "Knikpunt")) { point2D = customJsonHandler.getGeometryPoint2DDouble(); double putdekselhoogte = customJsonHandler.getPropertyFloatValue("putdekselhoogte"); point = ConvertCoordinates.CoordConvert.WGS84toUnity(new Vector3WGS(point2D[0], point2D[1], putdekselhoogte + Config.activeConfiguration.zeroGroundLevelY)); sewerManholeSpawner.CreateManhole(point, 1.50f, tile.gameObject); } } StartCoroutine(CombineSewerage(tileChange, tile, callback)); }
// [Test] public void TestFilePdok() { Config.activeConfiguration = new ConfigurationFile(); Config.activeConfiguration.sewerageApiType = Amsterdam3D.Sewerage.SewerageApiType.Pdok; SewerageLayer seweragelayer = new SewerageLayer(); //var jsontext = System.IO.File.ReadAllText(@"F:\Data\sewerage\data_utrecht_leidingen.json"); //var jsontext = System.IO.File.ReadAllText(@"F:\Data\sewerage\data_utrecht_leidingen_128000_456000_129000_457000.json"); var jsontext = System.IO.File.ReadAllText(@"F:\Data\sewerage\data_utrecht_leidingen_count_error.json"); GeoJSON geojson = new GeoJSON(jsontext); while (geojson.GotoNextFeature()) { double diameter = geojson.getPropertyFloatValue(seweragelayer.DiameterString); double bobBeginPunt = geojson.getPropertyFloatValue(seweragelayer.BobBeginPuntString); double bobEindPunt = geojson.getPropertyFloatValue(seweragelayer.BobEindPuntString); var geom = geojson.getGeometryLineString(); Assert.AreEqual(4, geom.Count); // Debug.Log($"diameter:{diameter} bobBeginPunt:{bobBeginPunt} bobEindPunt:{bobEindPunt}"); } }
IEnumerator GetSewerLinesInBoundingBox(TileChange tileChange, Tile tile, Vector3RD boundingBoxMinimum, Vector3RD boundingBoxMaximum, System.Action <TileChange> callback = null) { yield return(null); yield return(new WaitUntil(() => activeCount < maxSimultaneous)); activeCount++; tile.gameObject.SetActive(true); string escapedUrl = sewerPipesWfsUrl; escapedUrl += UnityWebRequest.EscapeURL((boundingBoxMinimum.x).ToString(CultureInfo.InvariantCulture) + "," + (boundingBoxMinimum.y).ToString(CultureInfo.InvariantCulture) + "," + (boundingBoxMaximum.x).ToString(CultureInfo.InvariantCulture) + "," + (boundingBoxMaximum.y).ToString(CultureInfo.InvariantCulture)); var sewerageRequest = UnityWebRequest.Get(escapedUrl); yield return(sewerageRequest.SendWebRequest()); if (!sewerageRequest.isNetworkError && !sewerageRequest.isHttpError) { GeoJSON customJsonHandler = new GeoJSON(sewerageRequest.downloadHandler.text); yield return(null); Vector3 startpoint; Vector3 endpoint; int parseCounter = 0; while (customJsonHandler.GotoNextFeature()) { parseCounter++; if ((parseCounter % maxParsesPerFrame) == 0) { yield return(null); } double diameter = customJsonHandler.getPropertyFloatValue("diameter"); double bobBeginPunt = customJsonHandler.getPropertyFloatValue("bob_beginpunt"); List <double> coordinates = customJsonHandler.getGeometryLineString(); endpoint = ConvertCoordinates.CoordConvert.WGS84toUnity(new Vector3WGS(coordinates[0], coordinates[1], bobBeginPunt + Config.activeConfiguration.zeroGroundLevelY)); for (int i = 2; i < coordinates.Count; i += 2) { startpoint = endpoint; double bobEindPunt = customJsonHandler.getPropertyFloatValue("bob_eindpunt"); endpoint = ConvertCoordinates.CoordConvert.WGS84toUnity(new Vector3WGS(coordinates[i], coordinates[(i + 1)], bobEindPunt + Config.activeConfiguration.zeroGroundLevelY)); sewerPipeSpawner.CreateSewerLine(startpoint, endpoint, diameter, tile.gameObject); } } StartCoroutine(GetSewerManholesInBoundingBox(tileChange, boundingBoxMinimum, boundingBoxMaximum, tile, callback)); } else { //callback if weberror Debug.Log("sewerlinedata not found"); activeCount--; callback(tileChange); } yield return(null); }
//[UnityTest] public IEnumerator TestApiPdok() { Config.activeConfiguration = new ConfigurationFile(); Config.activeConfiguration.sewerageApiType = Amsterdam3D.Sewerage.SewerageApiType.Pdok; Config.activeConfiguration.sewerPipesWfsUrl = "https://geodata.nationaalgeoregister.nl/rioned/gwsw/wfs/v1_0?SERVICE=WFS&language=eng&SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=gwsw:beheer_leiding&SRSNAME=urn:ogc:def:crs:EPSG::28992&outputFormat=application/json&BBOX="; Config.activeConfiguration.sewerManholesWfsUrl = "https://geodata.nationaalgeoregister.nl/rioned/gwsw/wfs/v1_0?SERVICE=WFS&language=eng&SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=gwsw:beheer_put&SRSNAME=urn:ogc:def:crs:EPSG::28992&outputFormat=application/json&BBOX="; SewerageLayer seweragelayer = new SewerageLayer(); int Xmin = 123000; int Ymin = 443000; int Xmax = 145000; int Ymax = 463000; string url; int counter = 0; for (int x = Xmin; x < Xmax; x += 1000) { for (int y = Ymin; y < Ymax; y += 1000) { counter++; url = Config.activeConfiguration.sewerPipesWfsUrl + $"{x},{y},{x + 1000},{y + 1000}"; var sewerageRequest = UnityWebRequest.Get(url); yield return(sewerageRequest.SendWebRequest()); if (!sewerageRequest.isNetworkError && !sewerageRequest.isHttpError) { try { GeoJSON geojson = new GeoJSON(sewerageRequest.downloadHandler.text); while (geojson.GotoNextFeature()) { double diameter = geojson.getPropertyFloatValue(seweragelayer.DiameterString); double bobBeginPunt = geojson.getPropertyFloatValue(seweragelayer.BobBeginPuntString); double bobEindPunt = geojson.getPropertyFloatValue(seweragelayer.BobEindPuntString); //var coordinates = geojson.getGeometryLineString(); //Assert.AreEqual(4, coordinates.Count); } } catch (Exception e) { Debug.Log($"url:{url} exception:{e.Message}"); } } yield return(null); } } }
public void TestCoordinatesMultipleSegmentsPdok() { Config.activeConfiguration = new ConfigurationFile(); Config.activeConfiguration.sewerageApiType = Amsterdam3D.Sewerage.SewerageApiType.Pdok; SewerageLayer seweragelayer = new SewerageLayer(); GeoJSON geojson = new GeoJSON(testStringMultipleSegmentPdok); geojson.GotoNextFeature(); var geom1 = geojson.getGeometryLineString(); // Assert.AreEqual(4, geom1.Count); Assert.AreEqual(geom1[0], 128714.08, 0.1); Assert.AreEqual(geom1[1], 456715.91, 0.1); Assert.AreEqual(geom1[2], 128726.92, 0.1); Assert.AreEqual(geom1[3], 456784.05, 0.1); geojson.GotoNextFeature(); var geom2 = geojson.getGeometryLineString(); //Assert.AreEqual(4, geom2.Count); Assert.AreEqual(geom2[0], 129029.42, 0.1); Assert.AreEqual(geom2[1], 456653.39, 0.1); Assert.AreEqual(geom2[2], 129029.21, 0.1); Assert.AreEqual(geom2[3], 456654.99, 0.1); geojson.GotoNextFeature(); var geom3 = geojson.getGeometryLineString(); //Assert.AreEqual(4, geom2.Count); Assert.AreEqual(geom3[0], 128995.88, 0.1); Assert.AreEqual(geom3[1], 456709.91, 0.1); Assert.AreEqual(geom3[2], 128980.46, 0.1); Assert.AreEqual(geom3[3], 456704.58, 0.1); }
public void TestApiPdokEmpty() { Config.activeConfiguration = new ConfigurationFile(); Config.activeConfiguration.sewerageApiType = Amsterdam3D.Sewerage.SewerageApiType.Pdok; SewerageLayer seweragelayer = new SewerageLayer(); GeoJSON geojson = new GeoJSON(testStringPdokEmpty); int counter = 0; while (geojson.GotoNextFeature()) { counter++; } Assert.AreEqual(0, counter); }
public void TestApiAmsterdamOne() { Config.activeConfiguration = new ConfigurationFile(); Config.activeConfiguration.sewerageApiType = Amsterdam3D.Sewerage.SewerageApiType.Amsterdam; SewerageLayer seweragelayer = new SewerageLayer(); GeoJSON geojson = new GeoJSON(testStringAmsterdamOne); geojson.GotoNextFeature(); double diameter = geojson.getPropertyFloatValue(seweragelayer.DiameterString); double bobBeginPunt = geojson.getPropertyFloatValue(seweragelayer.BobBeginPuntString); double bobEindPunt = geojson.getPropertyFloatValue(seweragelayer.BobEindPuntString); var geom = geojson.getGeometryLineString(); Assert.AreEqual(297, diameter); Assert.AreEqual(-1, bobBeginPunt); Assert.AreEqual(-1.60, bobEindPunt, 0.1); Assert.AreEqual(4, geom.Count); }
public void TestApiPdokOneWhile() { Config.activeConfiguration = new ConfigurationFile(); Config.activeConfiguration.sewerageApiType = Amsterdam3D.Sewerage.SewerageApiType.Pdok; SewerageLayer seweragelayer = new SewerageLayer(); GeoJSON geojson = new GeoJSON(testStringPdokOne); while (geojson.GotoNextFeature()) { double diameter = geojson.getPropertyFloatValue(seweragelayer.DiameterString); double bobBeginPunt = geojson.getPropertyFloatValue(seweragelayer.BobBeginPuntString); double bobEindPunt = geojson.getPropertyFloatValue(seweragelayer.BobEindPuntString); var geom = geojson.getGeometryLineString(); Assert.AreEqual(800, diameter); Assert.AreEqual(0.06, bobBeginPunt, 0.001); Assert.AreEqual(0.05, bobEindPunt, 0.001); Assert.AreEqual(4, geom.Count); } }
IEnumerator GetSewerLinesInBoundingBox(TileChange tileChange, Tile tile, Vector3RD boundingBoxMinimum, Vector3RD boundingBoxMaximum, System.Action <TileChange> callback = null) { yield return(new WaitForEndOfFrame()); var ownCoroutine = tile.runningCoroutine; yield return(new WaitUntil(() => CoroutineSlotsAvailable())); coroutinesWaiting[ownCoroutine] = false; string escapedUrl = Config.activeConfiguration.sewerPipesWfsUrl; escapedUrl += UnityWebRequest.EscapeURL($"{boundingBoxMinimum.x.ToInvariant()},{boundingBoxMinimum.y.ToInvariant()},{boundingBoxMaximum.x.ToInvariant()},{boundingBoxMaximum.y.ToInvariant()}"); var sewerageRequest = UnityWebRequest.Get(escapedUrl); tile.runningWebRequest = sewerageRequest; yield return(sewerageRequest.SendWebRequest()); tile.runningWebRequest = null; if (!sewerageRequest.isNetworkError && !sewerageRequest.isHttpError) { GeoJSON customJsonHandler = new GeoJSON(sewerageRequest.downloadHandler.text); yield return(null); Vector3 startpoint; Vector3 endpoint; int parseCounter = 0; while (customJsonHandler.GotoNextFeature()) { parseCounter++; if ((parseCounter % maxParsesPerFrame) == 0) { yield return(null); } double diameter = customJsonHandler.getPropertyFloatValue(DiameterString); double bobBeginPunt = customJsonHandler.getPropertyFloatValue(BobBeginPuntString); List <double> coordinates = customJsonHandler.getGeometryLineString(); endpoint = GetUnityPoint(coordinates[0], coordinates[1], bobBeginPunt + Config.activeConfiguration.zeroGroundLevelY); for (int i = 2; i < coordinates.Count; i += 2) { startpoint = endpoint; double bobEindPunt = customJsonHandler.getPropertyFloatValue(BobEindPuntString); endpoint = GetUnityPoint(coordinates[i], coordinates[(i + 1)], bobEindPunt + Config.activeConfiguration.zeroGroundLevelY); sewerPipeSpawner.CreateSewerLine(startpoint, endpoint, diameter, tile.gameObject); } } yield return(GetSewerManholesInBoundingBox(tileChange, boundingBoxMinimum, boundingBoxMaximum, tile, callback)); } else { //callback if weberror Debug.Log("sewerlinedata not found"); callback(tileChange); } if (coroutinesWaiting.ContainsKey(ownCoroutine)) { coroutinesWaiting.Remove(ownCoroutine); } yield return(null); }