private static RegionInternal ConvertOSMMultyPolToInternal(OSMRegionExternalMultyPolygon OSMMP) { var polygons = OSMMP.geojson.coordinates.Select( polygon => polygon.Select(outline => outline.Select(coordList => ListToPoint( coordList)).ToList()).ToList()).ToList(); var regInternal = new RegionInternal(OSMMP.display_name, polygons); return(regInternal); }
private static RegionInternal ConvertOSMPolToInternal(OSMRegionExternalPolygon OSMP) { var polygon = OSMP.geojson.coordinates.Select(outline => outline.Select(coordList => ListToPoint( coordList)).ToList()).ToList(); List <List <List <PointF> > > polygons = new List <List <List <PointF> > >() { polygon }; var regInternal = new RegionInternal(OSMP.display_name, polygons); return(regInternal); }
public static RegionInternal ProcessMessage(string msg) { RegionInternal result; var RegList = JsonConvert.DeserializeObject <IList <OSMTypeOnly> >(msg); var RegType = RegList[0].geojson.type; if (RegType == "Polygon") { result = ConvertOSMPolToInternal(JsonConvert.DeserializeObject <IList <OSMRegionExternalPolygon> >(msg)[0]); } else if (RegType == "MultiPolygon") { result = ConvertOSMMultyPolToInternal(JsonConvert.DeserializeObject <IList <OSMRegionExternalMultyPolygon> >(msg)[0]); } else { result = new RegionInternal(); } return(result); }