/// <summary> /// Aktualisiert diesen Layer und den <see cref="AreaOfInterest"/>. /// </summary> internal async Task UpdateAsync() { Overlay.Graphics.Clear(); var geometries = new List <Geometry>(); var featureCollection = await _service.Query(_url); foreach (var feature in featureCollection.Features) { var roadGeometry = feature.Geometry; switch (roadGeometry.Type) { case @"MultiLineString": var roadGraphic = CreateRoadGraphic(feature, SpatialReferences.Wgs84, _mapSpatialReference); Overlay.Graphics.Add(roadGraphic); geometries.Add(roadGraphic.Geometry); break; } } // Ausdehnung neu berechnen var union = GeometryEngine.Union(geometries); AreaOfInterest = union.Extent; }
public static async Task Run([TimerTrigger("0 */15 * * * *")] TimerInfo timer, ILogger log) { #if DEBUG log.LogInformation("Update traffic layer . . ."); #endif var trafficUrl = Environment.GetEnvironmentVariable(@"traffic.url"); #if DEBUG log.LogInformation($"Connecting to {trafficUrl}"); #endif var portalUrl = Environment.GetEnvironmentVariable(@"portal.url"); var appId = Environment.GetEnvironmentVariable(@"portal.appid"); var clientId = Environment.GetEnvironmentVariable(@"portal.clientid"); var featureService = Environment.GetEnvironmentVariable(@"portal.featureservice"); try { var roadFeatureCollection = await TrafficServiceInstance.Query(trafficUrl); var wgs84 = new Crs { Type = @"EPSG", Properties = new CrsProperties { Wkid = 4326 } }; roadFeatureCollection.CoordinateReferenceSystem = wgs84; var roadFeatures = roadFeatureCollection.ToFeatures(); using (var gateway = new PortalGateway(portalUrl, tokenProvider: new ArcGISOnlineAppLoginOAuthProvider(appId, clientId))) { #if DEBUG var info = await gateway.Info(); log.LogInformation($"Connecting to {info.FullVersion}"); #endif var featureServiceEndpoint = featureService.AsEndpoint(); var queryAllIds = new QueryForIds(featureServiceEndpoint); queryAllIds.Where = @"1=1"; var queryAllIdsResult = await gateway.QueryForIds(queryAllIds); var deleteAll = new ApplyEdits <IGeometry>(featureServiceEndpoint); deleteAll.Deletes.AddRange(queryAllIdsResult.ObjectIds); var deleteAllResult = await gateway.ApplyEdits(deleteAll); var addRoads = new ApplyEdits <IGeometry>(featureServiceEndpoint); foreach (var roadFeature in roadFeatures) { roadFeature.Geometry.SpatialReference = SpatialReference.WGS84; var serviceDateTime = (DateTime)roadFeature.Attributes[@"auswertezeit"]; roadFeature.Attributes[@"auswertezeit"] = DateTimeUtils.ConvertServiceTimeToUniversalTime(serviceDateTime); addRoads.Adds.Add(roadFeature); } var addRoadsResult = await gateway.ApplyEdits(addRoads); } } catch (Exception ex) { log.LogError(ex.Message); } }
public void TestQueryCityOfBonn() { using (var service = new TrafficService()) { var featureCollection = service.Query(@"http://stadtplan.bonn.de/geojson?Thema=19584").Result; Assert.IsNotNull(featureCollection, @"Die FeatureCollection muss instanziert sein!"); foreach (var feature in featureCollection.Features) { Assert.IsNotNull(feature, @"Ein jedes Feature muss instanziert sein!"); var geometry = feature.Geometry; Assert.IsNotNull(geometry, @"Die Geometrie muss instanziert sein!"); var properties = feature.Properties; Assert.IsNotNull(properties, @"Die Eigenschaften müssen instanziert sein!"); } } }