1
- import exportToGeoJsonFile from '$lib/util/exportToGeoJsonFile' ;
2
- import fetchOverpass from '$lib/util/fetchOverpass' ;
3
- import fileToGeoJSON from '$lib/util/fileToGeoJson' ;
4
- import geoJSONToPolygon from '$lib/util/geoJsonToPolygon' ;
5
- import { AllGeoJSON , feature , featureCollection , geometry , point , simplify } from '@turf/turf' ;
1
+ import { AllGeoJSON , simplify } from '@turf/turf' ;
6
2
import osmtogeojson from 'osmtogeojson' ;
3
+ import { exportToGeoJsonFile , fileToGeoJSON , geoJsonToPolygon } from '$lib/util' ;
4
+ import fetchOverpass from '$lib/util/overpass/fetchOverpass' ;
7
5
8
6
export default async ( file , overpassQuery : Array < any > , filename , radius = 1 ) => {
9
7
let createdGeoJson : AllGeoJSON = await fileToGeoJSON ( file ) ;
10
8
11
- let polygon = geoJSONToPolygon ( createdGeoJson , radius ) ;
9
+ let polygon = geoJsonToPolygon ( createdGeoJson , radius ) ;
12
10
console . log ( polygon ) ;
13
11
14
12
let simplifiedPolygon = simplify ( polygon , { highQuality : true , mutate : false , tolerance : 0.05 } ) ;
@@ -24,11 +22,12 @@ export default async (file, overpassQuery: Array<any>, filename, radius = 1) =>
24
22
25
23
overpassQuery . map (
26
24
( overpassQueryObject ) =>
27
- ( middleQuery += `way ["${ Object . keys ( overpassQueryObject ) [ 0 ] } "="${
25
+ ( middleQuery += `nwr ["${ Object . keys ( overpassQueryObject ) [ 0 ] } "="${
28
26
overpassQueryObject [ Object . keys ( overpassQueryObject ) [ 0 ] ]
29
27
} "](poly:"${ polygonstring } ");`)
30
28
) ;
31
- const query = `[out:json][timeout:150];(${ middleQuery } );(._;>;);out meta;` ;
29
+
30
+ const query = `[out:json][timeout:150];(${ middleQuery } );(._;>;);out center;` ;
32
31
33
32
const data = await fetchOverpass ( query ) ;
34
33
console . log ( data ) ;
0 commit comments