private static void GjettOmrådetype(Feature jsonFeature, Area area) { var properties = jsonFeature.Properties; if (properties.ContainsKey("objtype") && properties["objtype"] == "Fylke") { area.Type = AreaType.Fylke; area.Number = int.Parse(properties["fylkesnr"]); } else if (properties.ContainsKey("objtype") && properties["objtype"] == "Kommune") { area.Type = AreaType.Kommune; area.Number = int.Parse(properties["komm"]); } else { throw new AreaConverterException("Unknown source file"); } }
private static Area JsonFeatureToArea(Feature jsonFeature, int sourceEpsgCode) { var area = new Area { Name = jsonFeature.Properties["navn"] }; GjettOmrådetype(jsonFeature, area); var geometry = new SqlGeometryBuilder(); geometry.SetSrid(sourceEpsgCode); geometry.BeginGeometry(OpenGisGeometryType.Polygon); var coordinates = jsonFeature.Geometry.Coordinates; foreach (var feature in coordinates) { for (int j = 0; j < feature.Count; ++j) { var coordinate = feature[j]; if (j == 0) { geometry.BeginFigure(coordinate[0], coordinate[1]); } else { geometry.AddLine(coordinate[0], coordinate[1]); } } geometry.EndFigure(); } geometry.EndGeometry(); area.Geometry = geometry.ConstructedGeometry.MakeValid(); return(area); }