-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update SPARQL in functions.py #47
Open
dr-shorthair
wants to merge
4
commits into
master
Choose a base branch
from
simplify-queries-to-core-ontology
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -286,7 +286,7 @@ async def get_datasets(count=1000, offset=0): | |
} | ||
UNION | ||
{ | ||
?d a loci:Dataset . | ||
?d a loci:Dataset . | ||
} | ||
UNION | ||
{ | ||
|
@@ -319,7 +319,7 @@ async def get_locations(count=1000, offset=0): | |
""" | ||
sparql = """\ | ||
PREFIX geo: <http://www.opengis.net/ont/geosparql#> | ||
PREFIX prov: <http://www.w3.org/ns/prov#> | ||
# PREFIX prov: <http://www.w3.org/ns/prov#> | ||
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> | ||
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> | ||
SELECT DISTINCT ?l | ||
|
@@ -336,19 +336,20 @@ async def get_locations(count=1000, offset=0): | |
rdf:predicate rdf:type ; | ||
rdf:object geo:Feature . | ||
} | ||
UNION | ||
{ ?l a prov:Location } | ||
UNION | ||
{ | ||
?c2 rdfs:subClassOf+ prov:Location . | ||
?l a ?c2 . | ||
} | ||
UNION | ||
{ | ||
?s2 rdf:subject ?l ; | ||
rdf:predicate rdf:type ; | ||
rdf:object prov:Location . | ||
} . | ||
# UNION | ||
# { ?l a prov:Location } | ||
# UNION | ||
# { | ||
# ?c2 rdfs:subClassOf+ prov:Location . | ||
# ?l a ?c2 . | ||
# } | ||
# UNION | ||
# { | ||
# ?s2 rdf:subject ?l ; | ||
# rdf:predicate rdf:type ; | ||
# rdf:object prov:Location . | ||
# } | ||
. | ||
} | ||
""" | ||
resp = await query_graphdb_endpoint(sparql, limit=count, offset=offset) | ||
|
@@ -635,40 +636,36 @@ async def get_location_overlaps(target_uri, output_featuretype_uri, include_area | |
overlaps_sparql = """\ | ||
PREFIX geo: <http://www.opengis.net/ont/geosparql#> | ||
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> | ||
PREFIX ipo: <http://purl.org/dc/terms/isPartOf> | ||
PREFIX dcterms: <http://purl.org/dc/terms/> | ||
# PREFIX ipo: <http://purl.org/dc/terms/isPartOf> | ||
PREFIX geox: <http://linked.data.gov.au/def/geox#> | ||
PREFIX qb4st: <http://www.w3.org/ns/qb4st/> | ||
# PREFIX qb4st: <http://www.w3.org/ns/qb4st/> | ||
PREFIX epsg: <http://www.opengis.net/def/crs/EPSG/0/> | ||
PREFIX dt: <http://linked.data.gov.au/def/datatype/> | ||
SELECT <SELECTS> | ||
WHERE { | ||
?p rdfs:subPropertyOf* geo:sfOverlaps . | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this would work, except we haven't loaded the geox ontology in the cache yet. question is should the cache load the geox ontology also? geox ontology here: https://github.com/CSIRO-enviro-informatics/geosparql-ext-ont/blob/master/geox-adds.ttl |
||
{ | ||
{ | ||
?s1 rdf:subject <URI> ; | ||
<LINKSET_FILTER> | ||
rdf:predicate geox:transitiveSfOverlap; | ||
rdf:object ?o . | ||
} UNION { | ||
?s2 rdf:subject <URI> ; | ||
<LINKSET_FILTER> | ||
rdf:predicate geo:sfOverlaps; | ||
rdf:object ?o . | ||
} | ||
?s2 rdf:subject <URI> ; | ||
<LINKSET_FILTER> | ||
rdf:predicate ?p ; | ||
rdf:object ?o . | ||
} | ||
UNION | ||
{ <URI> geox:transitiveSfOverlap ?o } | ||
UNION | ||
{ <URI> geo:sfOverlaps ?o } | ||
{ | ||
<URI> ?p ?o | ||
} | ||
<EXTRAS> | ||
} | ||
GROUP BY ?o | ||
""" | ||
contains_sparql = """\ | ||
PREFIX geo: <http://www.opengis.net/ont/geosparql#> | ||
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> | ||
PREFIX ipo: <http://purl.org/dc/terms/isPartOf> | ||
PREFIX dcterms: <http://purl.org/dc/terms/> | ||
# PREFIX ipo: <http://purl.org/dc/terms/isPartOf> | ||
PREFIX geox: <http://linked.data.gov.au/def/geox#> | ||
PREFIX qb4st: <http://www.w3.org/ns/qb4st/> | ||
# PREFIX qb4st: <http://www.w3.org/ns/qb4st/> | ||
PREFIX epsg: <http://www.opengis.net/def/crs/EPSG/0/> | ||
PREFIX dt: <http://linked.data.gov.au/def/datatype/> | ||
SELECT ?c <SELECTS> | ||
|
@@ -692,8 +689,9 @@ async def get_location_overlaps(target_uri, output_featuretype_uri, include_area | |
PREFIX geo: <http://www.opengis.net/ont/geosparql#> | ||
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> | ||
PREFIX geox: <http://linked.data.gov.au/def/geox#> | ||
PREFIX ipo: <http://purl.org/dc/terms/isPartOf> | ||
PREFIX qb4st: <http://www.w3.org/ns/qb4st/> | ||
PREFIX dcterms: <http://purl.org/dc/terms/> | ||
# PREFIX ipo: <http://purl.org/dc/terms/isPartOf> | ||
# PREFIX qb4st: <http://www.w3.org/ns/qb4st/> | ||
PREFIX epsg: <http://www.opengis.net/def/crs/EPSG/0/> | ||
PREFIX dt: <http://linked.data.gov.au/def/datatype/> | ||
SELECT ?w <SELECTS> | ||
|
@@ -723,11 +721,13 @@ async def get_location_overlaps(target_uri, output_featuretype_uri, include_area | |
areas_sparql = """\ | ||
OPTIONAL { | ||
<URI> geox:hasAreaM2 ?ha1 . | ||
# ?ha1 qb4st:crs epsg:3577 . | ||
?ha1 geox:inCRS epsg:3577 . | ||
?ha1 dt:value ?a1 . | ||
} | ||
OPTIONAL { | ||
?o geox:hasAreaM2 ?ha2 . | ||
# ?ha2 qb4st:crs epsg:3577 . | ||
?ha2 geox:inCRS epsg:3577 . | ||
?ha2 dt:value ?a2 . | ||
} | ||
|
@@ -753,8 +753,9 @@ async def get_location_overlaps(target_uri, output_featuretype_uri, include_area | |
} . | ||
OPTIONAL { | ||
?i geox:hasAreaM2 ?ha3 . | ||
?ha3 geox:inCRS epsg:3577 . | ||
?ha3 dt:value ?a3 . | ||
# ?ha3 qb4st:crs epsg:3577 . | ||
?ha3 geox:inCRS epsg:3577 . | ||
?ha3 dt:value ?a3 . | ||
} | ||
} | ||
""" | ||
|
@@ -770,13 +771,13 @@ async def get_location_overlaps(target_uri, output_featuretype_uri, include_area | |
sparql = sparql.replace("<EXTRAS>", extras) | ||
sparql = sparql.replace("<URI>", "<{}>".format(str(target_uri))) | ||
if not linksets_filter is None: | ||
sparql = sparql.replace("<LINKSET_FILTER>", "ipo: <{}> ;".format(str(linksets_filter))) | ||
sparql = sparql.replace("<LINKSET_FILTER>", "dcterms:isPartOf <{}> ;".format(str(linksets_filter))) | ||
else: | ||
sparql = sparql.replace("<LINKSET_FILTER>", "") | ||
overlaps = [] | ||
bindings = [] | ||
if not linksets_filter is None: | ||
sparql = sparql.replace("<LINKSET_FILTER>", "ipo: <{}> ;".format(str(linksets_filter))) | ||
sparql = sparql.replace("<LINKSET_FILTER>", "dcterms:isPartOf <{}> ;".format(str(linksets_filter))) | ||
else: | ||
sparql = sparql.replace("<LINKSET_FILTER>", "") | ||
await query_build_response_bindings(sparql, count, offset, bindings) | ||
|
@@ -791,7 +792,7 @@ async def get_location_overlaps(target_uri, output_featuretype_uri, include_area | |
sparql = sparql.replace("<EXTRAS>", extras) | ||
sparql = sparql.replace("<URI>", "<{}>".format(str(target_uri))) | ||
if not linksets_filter is None: | ||
sparql = sparql.replace("<LINKSET_FILTER>", "ipo: <{}> ;".format(str(linksets_filter))) | ||
sparql = sparql.replace("<LINKSET_FILTER>", "dcterms:isPartOf <{}> ;".format(str(linksets_filter))) | ||
else: | ||
sparql = sparql.replace("<LINKSET_FILTER>", "") | ||
await query_build_response_bindings(sparql, count, offset, bindings) | ||
|
@@ -805,7 +806,7 @@ async def get_location_overlaps(target_uri, output_featuretype_uri, include_area | |
sparql = sparql.replace("<EXTRAS>", extras) | ||
sparql = sparql.replace("<URI>", "<{}>".format(str(target_uri))) | ||
if not linksets_filter is None: | ||
sparql = sparql.replace("<LINKSET_FILTER>", "ipo: <{}> ;".format(str(linksets_filter))) | ||
sparql = sparql.replace("<LINKSET_FILTER>", "dcterms:isPartOf <{}> ;".format(str(linksets_filter))) | ||
else: | ||
sparql = sparql.replace("<LINKSET_FILTER>", "") | ||
await query_build_response_bindings(sparql, count, offset, bindings) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My best guess as to why this was here in the first place is because "overlaps" objects are treated as geo:Features but we want to exclude them from being returned as locations. I'm not sure though, @ashleysommer ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these computed ahead and cached? If so, I would prefer to see an explicit feature-type for overlaps. Maybe
loci:Overlap
? Then these can be explicitly excluded, rather than borrowing an unrelated feature-type.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I agree it shouldn't be a feature but I can't remember all the reasoning around it from our older discussions. I believe we can actually get rid of overlaps objects altogether because all that information should be elsewhere but @ashleysommer has more history and probably more insight on this. We need to break up scope here as well. It would be good to merge whatever is the minimum set of changes to support the new LDAPIs and deal with larger refactors, like overlaps, later.