User:Polarbear/chamber
Jump to navigation
Jump to search
< cc.json jq '[.[]] | group_by(.city)[] | {(.[0].city): (. | length)}'
chamber.jq
{ "type": "FeatureCollection", "features": [ .[] | select(.member_type | test("Friend of the Chamber|Email List Only|Staff Access Only") | not) | { "type": "Feature", "geometry": { "type": "Point", "coordinates": [.lng, .lat] }, "properties": { address_1, "addr:housenumber": (.address_1 | capture("^\\s*(?<a>[0-9]+)") | .a), "addr:street": ( if (.address_1 | test("(?<!,).*suite";"i")) #suite without comma then (.address_1|capture("^\\s*[0-9]+[\\s-]+(?<a>.+) (suite.*)";"i") | .a) elif (.address_1 | test(",";"i")) #suite or unit with comma then (.address_1|capture("^\\s*[0-9]+[\\s-]+(?<a>.+),";"i") | .a) else (.address_1|capture("^\\s*[0-9]+[\\s-]+(?<a>.+)";"i") | .a) #no suite end ), "addr:unit": ( if (.address_1 | test("(?<!,).*suite";"i")) #suite without comma then (.address_1|capture("(?<a>suite.*)";"i") | .a) elif (.address_1 | test(",";"i")) #with comma then (.address_1|capture(",\\s*(<a>.*)";"i") | .a) else "" #no suite end ), "addr:city": .city, "addr:postcode": .zip_postal, "addr:state": .state_province, "phone": ("+1 " + .phone), "name": .business_name, "contact:email": .email, "office": "company", "cc:category": (.categories | values[] | join(";")), "cc:member_type": .member_type } } ] }
curl "https://www.chamberorganizer.com/members/mem_xml/CCCC_members.json" | jq -f chamber.jq > chamber.geojson