* @constructor * @param context Global shared application context
(context)
| 36 | * @param context Global shared application context |
| 37 | */ |
| 38 | constructor(context) { |
| 39 | super(context); |
| 40 | this.id = 'locations'; |
| 41 | this.dependencies = new Set(); |
| 42 | |
| 43 | this._wp = null; // A which-polygon index |
| 44 | this._resolved = new Map(); // Map (id -> GeoJSON feature) |
| 45 | this._knownLocationSets = new Map(); // Map (locationSetID -> Number area) |
| 46 | this._locationIncludedIn = new Map(); // Map (locationID -> Set(locationSetID) ) |
| 47 | this._locationExcludedIn = new Map(); // Map (locationID -> Set(locationSetID) ) |
| 48 | |
| 49 | // BLOCKED REGIONS |
| 50 | this._blocks = [{ |
| 51 | locationSet: { include: ['Q7835', 'ua'] }, |
| 52 | text: 'Editing has been blocked in this region per request of the OSM Ukrainian community.', |
| 53 | url: 'https://wiki.openstreetmap.org/wiki/Russian%E2%80%93Ukrainian_war' |
| 54 | }]; |
| 55 | |
| 56 | const blockedFeatures = this._blocks.map(block => { |
| 57 | // Pre-resolve the blocked region locationSets into GeoJSON features |
| 58 | this._resolveLocationSet(block); |
| 59 | // Merge the info about the block into the GeoJSON's properties |
| 60 | let feature = this._resolved.get(block.locationSetID); |
| 61 | Object.assign(feature.properties, block); |
| 62 | return feature; |
| 63 | }); |
| 64 | |
| 65 | // Make a separate which-polygon just for these (static, very few features, very frequent lookups) |
| 66 | this._wpblocks = whichPolygon({ type: 'FeatureCollection', features: blockedFeatures }); |
| 67 | |
| 68 | // pre-resolve the worldwide locationSet |
| 69 | const world = { locationSet: { include: ['Q2'] } }; |
| 70 | this._resolveLocationSet(world); |
| 71 | this._rebuildIndex(); |
| 72 | } |
| 73 | |
| 74 | |
| 75 | /** |
nothing calls this directly
no test coverage detected