* locationSetsAt * Find all the locationSets valid at the given location. * Results include the area (in km²) to facilitate sorting. * * Object of locationSetIDs to areas (in km²) * { * "+[Q2]": 511207893.3958111, * "+[Q30]": 21817019.17, * "+[new_jersey.geojson]": 2239
(loc)
| 361 | * @return Object of locationSetIDs valid at given location |
| 362 | */ |
| 363 | locationSetsAt(loc) { |
| 364 | let result = {}; |
| 365 | |
| 366 | const hits = this._wp(loc, true) || []; |
| 367 | const thiz = this; |
| 368 | |
| 369 | // locationSets |
| 370 | hits.forEach(prop => { |
| 371 | if (prop.id[0] !== '+') return; // skip - it's a location |
| 372 | const locationSetID = prop.id; |
| 373 | const area = thiz._knownLocationSets.get(locationSetID); |
| 374 | if (area) { |
| 375 | result[locationSetID] = area; |
| 376 | } |
| 377 | }); |
| 378 | |
| 379 | // locations included |
| 380 | hits.forEach(prop => { |
| 381 | if (prop.id[0] === '+') return; // skip - it's a locationset |
| 382 | const locationID = prop.id; |
| 383 | const included = thiz._locationIncludedIn.get(locationID); |
| 384 | (included || []).forEach(locationSetID => { |
| 385 | const area = thiz._knownLocationSets.get(locationSetID); |
| 386 | if (area) { |
| 387 | result[locationSetID] = area; |
| 388 | } |
| 389 | }); |
| 390 | }); |
| 391 | |
| 392 | // locations excluded |
| 393 | hits.forEach(prop => { |
| 394 | if (prop.id[0] === '+') return; // skip - it's a locationset |
| 395 | const locationID = prop.id; |
| 396 | const excluded = thiz._locationExcludedIn.get(locationID); |
| 397 | (excluded || []).forEach(locationSetID => { |
| 398 | delete result[locationSetID]; |
| 399 | }); |
| 400 | }); |
| 401 | |
| 402 | return result; |
| 403 | } |
| 404 | |
| 405 | |
| 406 | /** |
no test coverage detected