Skip to content

Commit

Permalink
#45: more tests with wikidata queries for countries/territories
Browse files Browse the repository at this point in the history
  • Loading branch information
fititnt committed Jul 19, 2022
1 parent 53434d4 commit 91249b3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
33 changes: 28 additions & 5 deletions officina/999999999/1603_3_12.sh
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ ORDER BY ASC(?item__conceptum__codicem)
caput_csvnormali=$(head -n1 "$objectivum_archivum_temporarium")
caput_hxltm=$(caput_csvnormali_ad_hxltm "${caput_csvnormali}" ",")

echo "$caput_hxltm" > "$objectivum_archivum_temporarium_hxltm"
tail -n +2 "$objectivum_archivum_temporarium" >> "$objectivum_archivum_temporarium_hxltm"
echo "$caput_hxltm" >"$objectivum_archivum_temporarium_hxltm"
tail -n +2 "$objectivum_archivum_temporarium" >>"$objectivum_archivum_temporarium_hxltm"

file_update_if_necessary csv "$objectivum_archivum_temporarium" "$objectivum_archivum"
file_update_if_necessary csv "$objectivum_archivum_temporarium_hxltm" "$objectivum_archivum_hxltm"
Expand Down Expand Up @@ -224,6 +224,30 @@ GROUP BY ?item ?ix_iso3166p2
ORDER BY ASC(?item)
' >"$objectivum_archivum_temporarium"

# @see https://stackoverflow.com/questions/44718137/get-wikidata-identifier-for-city-by-gps-location
# shellcheck disable=SC2034
_wikidata_by_distance='
SELECT DISTINCT * WHERE {
?place (wdt:P31/(wdt:P279*)) wd:Q515.
SERVICE wikibase:around {
?place wdt:P625 ?location.
bd:serviceParam wikibase:center "Point(8.4024875340491 48.9993762209831)"^^geo:wktLiteral;
wikibase:radius "100";
wikibase:distance ?distance.
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY (?distance)
'

# https://www.wikidata.org/wiki/Wikidata:Request_a_query/Archive/2021/03#List_of_administrative_divisions_by_country
# shellcheck disable=SC2034
_ix_iso3166p2_only='
SELECT DISTINCT ?item ?itemLabel ?p300 WHERE {
?item wdt:P300 ?p300 .
SERVICE wikibase:label { bd:serviceParam wikibase:language "pt,en". }
}
'

# Source of the query
# https://www.wikidata.org/wiki/Wikidata_talk:WikiProject_Country_subdivision/Items
Expand Down Expand Up @@ -285,14 +309,13 @@ WHERE {
ORDER BY desc(?population)
'


frictionless validate "$objectivum_archivum_temporarium"

caput_csvnormali=$(head -n1 "$objectivum_archivum_temporarium")
caput_hxltm=$(caput_csvnormali_ad_hxltm "${caput_csvnormali}" ",")

echo "$caput_hxltm" > "$objectivum_archivum_temporarium_hxltm"
tail -n +2 "$objectivum_archivum_temporarium" >> "$objectivum_archivum_temporarium_hxltm"
echo "$caput_hxltm" >"$objectivum_archivum_temporarium_hxltm"
tail -n +2 "$objectivum_archivum_temporarium" >>"$objectivum_archivum_temporarium_hxltm"

file_update_if_necessary csv "$objectivum_archivum_temporarium" "$objectivum_archivum"
file_update_if_necessary csv "$objectivum_archivum_temporarium_hxltm" "$objectivum_archivum_hxltm"
Expand Down
2 changes: 2 additions & 0 deletions officina/999999999/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ gen-graphql 999999/0/personinfo-2.yaml > 999999/0/personinfo-2.graphql
gen-excel 999999/0/personinfo-2.yaml --output 999999/0/personinfo-2.xlsx
gen-excel --metadata 999999/0/personinfo-2.yaml --output 999999/0/personinfo-2.xlsx
pip install schema-automator
### @TODOs
- learn to manipulate geopackages (SQLite) with python
- https://gis.stackexchange.com/questions/342855/reading-geopackage-geometries-in-python
Expand Down

0 comments on commit 91249b3

Please sign in to comment.