Ejemplo n.º 1
0
        /// <summary>
        /// A way to add a multipolygon. Avoids erroneous conversion from multiple polygons containing holes to a simple list of coordinates.
        /// </summary>
        public async Task Add(GeoJsonMultiPolygonJsonString geoJsonMultiPolygonJsonString, Catchment otherCatchmentInfo)
        {
            var geographyFactory = await this.GeometryFactoryProvider.GetGeometryFactoryAsync();

            var multiPolygonGeometry = geoJsonMultiPolygonJsonString.ToMultiPolygon(geographyFactory);

            var catchmentEntity = new Entities.Catchment {
                Identity = otherCatchmentInfo.Identity.Value,
                Name     = otherCatchmentInfo.Name,
                Boundary = multiPolygonGeometry,
            };

            await this.AddCatchmentEntity(catchmentEntity, otherCatchmentInfo.Identity);
        }
Ejemplo n.º 2
0
        public async Task SetBoundary(CatchmentIdentity identity, GeoJsonMultiPolygonJsonString newGeoJsonMultiPolygonJsonString)
        {
            var geographyFactory = await this.GeometryFactoryProvider.GetGeometryFactoryAsync();

            var newMultiPolygonGeometry = newGeoJsonMultiPolygonJsonString.ToMultiPolygon(geographyFactory);

            await this.ExecuteInContextAsync(async dbContext =>
            {
                var entity = await dbContext.Catchments.GetByIdentity(identity).SingleAsync();

                entity.Boundary = newMultiPolygonGeometry;

                await dbContext.SaveChangesAsync();
            });
        }