Add a continents GeoJSON. Will need to add indexing for it.

master
Sander Vocke 6 years ago
parent e4ec985db4
commit cd0bfe1cf8
  1. 1
      public/continent_polygons.geojson
  2. 19
      src/database.js
  3. 13
      src/geo_store.js

File diff suppressed because one or more lines are too long

@ -1,7 +1,7 @@
import React, { useEffect, useState, useContext } from 'react';
import {
initialize_image_index, image_in_area
initialize_image_index, image_in_area, load_static_geo_polygons
} from './geo_store.js';
export async function sqljs_async_queries(sqljs_object, queries) {
@ -113,13 +113,16 @@ export function ProvideDB(props) {
.then(db => {
add_full_tag_info(db)
.then((newdb) => {
initialize_image_index(newdb).then(() => {
db.create_function("REGEXP", regexp_match);
db.create_function("IS_IN_GEO", is_in_geo_polygon_from_store);
//polygons_benchmark(db);
setError(false);
setDb(newdb);
})
initialize_image_index(newdb)
.then(() => {
load_static_geo_polygons()
.then(() => {
db.create_function("REGEXP", regexp_match);
db.create_function("IS_IN_GEO", is_in_geo_polygon_from_store);
setError(false);
setDb(newdb);
})
})
})
})
.catch(error => { setError(error); });

@ -140,4 +140,17 @@ export function image_in_area(image_id, area_hash) {
//console.log("Is ", parseInt(image_id), " inside ", g_GeoStore["area_query_results"][area_hash], "?");
return g_GeoStore["area_query_results"][area_hash].includes(parseInt(image_id));
}
// Nominatim doesn't provide (multi-) polygons for everything.
// We want to have our own cache of named
export function load_static_geo_polygons() {
return new Promise((resolve, reject) => {
fetch('/continent_polygons.geojson')
.then(res => res.json())
.then(json => {
console.log("Continents:", json);
resolve(json);
});
});
}
Loading…
Cancel
Save