forked from MapComplete/MapComplete
Reformat all files with prettier
This commit is contained in:
parent
e22d189376
commit
b541d3eab4
382 changed files with 50893 additions and 35566 deletions
|
@ -1,11 +1,13 @@
|
|||
import * as fs from "fs";
|
||||
import {TagUtils} from "../Logic/Tags/TagUtils";
|
||||
import {writeFileSync} from "fs";
|
||||
import {TagsFilter} from "../Logic/Tags/TagsFilter";
|
||||
import * as fs from "fs"
|
||||
import { TagUtils } from "../Logic/Tags/TagUtils"
|
||||
import { writeFileSync } from "fs"
|
||||
import { TagsFilter } from "../Logic/Tags/TagsFilter"
|
||||
|
||||
function main(args) {
|
||||
if (args.length < 2) {
|
||||
console.log("Given a single geojson file and a filter specification, will print all the entries to std-out which pass the property")
|
||||
console.log(
|
||||
"Given a single geojson file and a filter specification, will print all the entries to std-out which pass the property"
|
||||
)
|
||||
console.log("USAGE: perProperty `file.geojson` `key=value` [outputfile]")
|
||||
return
|
||||
}
|
||||
|
@ -14,32 +16,38 @@ function main(args) {
|
|||
const output = args[2]
|
||||
|
||||
const data = JSON.parse(fs.readFileSync(path, "UTF8"))
|
||||
let filter : TagsFilter ;
|
||||
try{
|
||||
filter = TagUtils.Tag(JSON.parse(spec))
|
||||
|
||||
}catch(e){
|
||||
let filter: TagsFilter
|
||||
try {
|
||||
filter = TagUtils.Tag(JSON.parse(spec))
|
||||
} catch (e) {
|
||||
filter = TagUtils.Tag(spec)
|
||||
}
|
||||
const features = data.features.filter(f => filter.matchesProperties(f.properties))
|
||||
const features = data.features.filter((f) => filter.matchesProperties(f.properties))
|
||||
|
||||
if(features.length === 0){
|
||||
if (features.length === 0) {
|
||||
console.log("Warning: no features matched the filter. Exiting now")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
const collection = {
|
||||
type:"FeatureCollection",
|
||||
features
|
||||
type: "FeatureCollection",
|
||||
features,
|
||||
}
|
||||
const stringified = JSON.stringify(collection, null, " ")
|
||||
if(output === undefined){
|
||||
if (output === undefined) {
|
||||
console.log(stringified)
|
||||
}else{
|
||||
console.log("Filtered "+path+": kept "+features.length+" out of "+data.features.length+" objects")
|
||||
} else {
|
||||
console.log(
|
||||
"Filtered " +
|
||||
path +
|
||||
": kept " +
|
||||
features.length +
|
||||
" out of " +
|
||||
data.features.length +
|
||||
" objects"
|
||||
)
|
||||
writeFileSync(output, stringified)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
main(process.argv.slice(2))
|
||||
main(process.argv.slice(2))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue