예제 #1
0
        private static AreaCollection FromGeoJson(FeatureCollection jsonAreas, int sourceEpsgCode)
        {
            var areas = new AreaCollection();

            foreach (Feature t in jsonAreas.Features)
            {
                areas.Add(JsonFeatureToArea(t, sourceEpsgCode));
            }

            return(areas);
        }
예제 #2
0
        /// <summary>
        /// Convert features defined in a shape file to Areas.
        /// </summary>
        /// <param name="shapeFilePath">Path to the shape file</param>
        /// <param name="areaType">area type</param>
        /// <param name="sourceEpsgCode"></param>
        private static AreaCollection FromShapeFile(string shapeFilePath, AreaType areaType, int sourceEpsgCode)
        {
            var       areas     = new AreaCollection();
            Shapefile shapeFile = Shapefile.OpenFile(shapeFilePath);

            shapeFile.Reproject(ProjectionInfo.FromEpsgCode(sourceEpsgCode));

            foreach (var feature in shapeFile.Features)
            {
                var area   = new Area();
                var id     = feature.DataRow[0].ToString();
                var number = int.Parse(id.Replace("VV", ""));
                area.Number   = number;
                area.Name     = feature.DataRow[1].ToString();
                area.Type     = areaType;
                area.Geometry = SqlGeometry.STGeomFromText(new SqlChars(feature.BasicGeometry.ToString()),
                                                           Config.Settings.Map.SpatialReferenceSystemIdentifier);
                area.Category = feature.DataRow[3].ToString();
                areas.Add(area);
            }

            return(areas);
        }