Files
notifications-admin/notifications_utils/broadcast_areas/Countries.geojson

1 line
324 KiB
Plaintext
Raw Normal View History

Add broadcast area model, loading from GeoJSON This commit adds a new model class which can be used by any app to interact with a broadcast area. A broadcast area is one or more polygons representing geographical areas. It also adds some models that make browsing collections of these areas more straightforward. So the hierarchy looks like: > **BroadcastAreaLibraries* > Contains multiple libraries of broadcast area > > **BroadcastAreaLibrary** > > A collection of geographic areas, all of the same type, for example > > counties or electoral wards > > **BroadcastArea** > > Contains one or more shapes that make up an area, for example > > England > > > **BroadcastArea.polygons[n]** > > > A single shape, for example the Isle of Wight or Lindisfarne > > > > **BroadcastArea.polygons[n][o]** > > > > A single coordinate along a polygons The classes support iteration, so all the areas in a library can be looped over, for example if `countries` is an instance of `BroadcastAreaLibrary` you can do: ```python for country in countries: print(country.name) ``` The `BroadcastAreaLibraries` class also provides some useful methods for quickly getting the polygons for an area or areas, for example to render them on a map. So if `libraries` is an instance of `BroadcastAreaLibraries` you can do: ```python libraries.get_polygons_for_areas_long_lat('england', 'wales') ``` This will give polygons for the Welsh mainland, the Isle of Wight, Anglesey, etc. The models load data from GeoJSON files, which is an open standard for serialising geographic data. I’ve added a few example files taken from http://geoportal.statistics.gov.uk to show how it works.
2020-07-06 10:53:40 +01:00
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"objectid":1,"ctry19cd":"E92000001","ctry19nm":"England","ctry19nmw":"Lloegr","bng_e":394883,"bng_n":370883,"long":-2.07811,"lat":53.23497,"st_areashape":1.3065114177940941E11,"st_lengthshape":5017042.242875093},"geometry":{"type":"MultiPolygon","coordinates":[[[[-2.0343575091737702,55.81108536609426],[-2.086123094270196,55.79304527148796],[-2.085672407987408,55.76273963400317],[-2.102629738300013,55.76191119937048],[-2.107792732111394,55.76040558518672],[-2.119165350718702,55.7425975371987],[-2.118348887351864,55.74124152764889],[-2.1365456364610322,55.740400550597805],[-2.1429383027955438,55.73815569021456],[-2.1493001773976275,55.73592105480351],[-2.151751430537382,55.722506041398695],[-2.1767559970946246,55.71863057642118],[-2.166631370967197,55.70681142759736],[-2.21865916071879,55.67590713814159],[-2.2184527280460684,55.66426026833543],[-2.2481739376102374,55.65235319966173],[-2.234368585867574,55.64104210188375],[-2.3057897041683844,55.64704377458248],[-2.3360976191904905,55.63216764642542],[-2.3086260296766192,55.62887597723596],[-2.316094112570702,55.62045846899423],[-2.2892322950467006,55.603773696793624],[-2.2888105709281135,55.58030726678083],[-2.2403065059112004,55.55562716926648],[-2.228845515516989,55.50951878090202],[-2.2026492750732047,55.48954128857097],[-2.2013358331861093,55.47526752070873],[-2.165521232117697,55.46838189897577],[-2.1880779754986386,55.4621152753329],[-2.1948582004768777,55.44459028522482],[-2.231281912472405,55.42842929288265],[-2.260611289272045,55.43293399890582],[-2.3132535625994213,55.40678933510751],[-2.3356291447126547,55.40820806433906],[-2.3449468216079388,55.39931343188803],[-2.3300205206406543,55.381241567214964],[-2.346233211750529,55.37306105426292],[-2.3375299573480204,55.36719096768345],[-2.3789118066830577,55.349169438012375],[-2.3995050398320505,55.348221401949104],[-2.4149966435428736,55.35892190388617],[-2.475393463939452,55.35473992089292],[-2.520269658516117,55.32304709208137],[-2.5590083385159934,55.31785282301818],[-2.57336309653362,55.296884398157864],[-2.6092381032389924,55.28324802650198],[-2.6266560667346432,55.26222093851897],[-2.6467711812133294,55.26004386382465],[-2.611450858231068,55.24713443021103],[-2.630228980817351,55.244791496820405],[-2.6314142072214923,55.223698085795505],[-2.6668147893489995,55.221580390859884],[-2.689790234680944,55.18898421179085],[-2.703404626670129,55.173211300949674],[-2.7848749221006934,55.1417752165799],[-2.8255025752054364,55.13831407229351],[-2.827607943969693,55.12483686960102],[-2.8585400590199437,55.10834880422605],[-2.886292453386162,55.09480989561917],[-2.896879247218781,55.077949647870845],[-2.9404291160454386,55.0691281612352],[-2.936407423757778,55.05958592819337],[-2.9585935679891127,55.04929459207618],[-3.051051963495367,55.05273596056473],[-3.05341969195431,55.04728403809466],[-3.025874931641199,55.036458816984364],[-3.0534516874196833,54.99280455918759],[-3.048314721020662,54.9833971453348],[-3.049699119143661,54.983526270423745],[-3.0619331056861308,54.98466663537996],[-3.0854180254969252,54.965166954767014],[-3.1116080617724062,54.957627538585314],[-3.105599292674973,54.95066832328258],[-3.1172719423869584,54.95591125211312],[-3.1038154099739033,54.94860174425489],[-3.0957045713357303,54.94622200919196],[-3.127071639115175,54.95091619693406],[-3.1141940892344517,54.947196382916374],[-3.1219480588377655,54.944539265016346],[-3.113892741816551,54.940705517509336],[-3.125198238652199,54.944047564953465],[-3.11893710299614,54.93457423907596],[-3.08408551861442,54.92984466111255],[-3.118932872176629,54.925383509719836],[-3.1189299272761257,54.92554911016984],[-3.1186745510381595,54.92575896894714],[-3.1187949342335584,54.92617317290769],[-3.1533959961713873,54.93187591896878],[-3.2043969366034517,54.95373956663371],[-3.2320871627843006,54.95308507703804],[-3.2688448245682076,54.937078058461495],[-3.265280621490759,54.94304417819616],[-3.2851424853281856,54.94155607403842],[-3.3142835639427872,54.920337909835744],[-3.3085081624767967,54.911