-
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -277,13 +277,18 @@ async def get_datasets(count=1000, offset=0): | |
""" | ||
sparql = """\ | ||
PREFIX dcat: <http://www.w3.org/ns/dcat#> | ||
PREFIX loci: <http://linked.data.gov.au/def/loci#> | ||
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> | ||
SELECT DISTINCT ?d | ||
WHERE { | ||
{ | ||
?d a dcat:Dataset . | ||
} | ||
UNION | ||
{ | ||
?d a loci:Dataset . | ||
} | ||
UNION | ||
{ | ||
?c rdfs:subClassOf+ dcat:Dataset . | ||
?d a ?c . | ||
|
@@ -314,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 | ||
|
@@ -331,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) | ||
|
@@ -628,28 +634,29 @@ 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 { | ||
{ | ||
{ | ||
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. Note this bracket might not be closed and might need commenting 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. Which bracket? there is nothing in the change. |
||
?s1 rdf:subject <URI> ; | ||
<LINKSET_FILTER> | ||
rdf:predicate geox:transitiveSfOverlap; | ||
rdf:object ?o . | ||
} UNION { | ||
# ?s1 rdf:subject <URI> ; | ||
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. I don't think we can take this out until we've rebuilt the linksets and that is beyond the scope of the LDAPI refactors currently underway. AFAIK we use geox:transitiveSfOverlap still and can't depend on geo:sfOverlaps yet 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. Lets verify. 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. so in tests with excelerator use cases, we either have to: b) is more expedient; but a) is probably what we should do in the longer term 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. Sorry it is the bracket above this comment I think it also needs commenting. Not sure though it just looks like an extra line needs commenting. |
||
# <LINKSET_FILTER> | ||
# rdf:predicate geox:transitiveSfOverlap; | ||
# rdf:object ?o . | ||
# } UNION { | ||
?s2 rdf:subject <URI> ; | ||
<LINKSET_FILTER> | ||
rdf:predicate geo:sfOverlaps; | ||
rdf:object ?o . | ||
} | ||
} | ||
UNION | ||
{ <URI> geox:transitiveSfOverlap ?o } | ||
# UNION | ||
# { <URI> geox:transitiveSfOverlap ?o } | ||
UNION | ||
{ <URI> geo:sfOverlaps ?o } | ||
<EXTRAS> | ||
|
@@ -659,9 +666,10 @@ async def get_location_overlaps(target_uri, output_featuretype_uri, include_area | |
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> | ||
|
@@ -685,8 +693,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> | ||
|
@@ -716,12 +725,14 @@ 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 qb4st:crs epsg:3577 . | ||
?ha1 geox:inCRS epsg:3577 . | ||
?ha1 dt:value ?a1 . | ||
} | ||
OPTIONAL { | ||
?o geox:hasAreaM2 ?ha2 . | ||
?ha2 qb4st:crs epsg:3577 . | ||
# ?ha2 qb4st:crs epsg:3577 . | ||
?ha2 geox:inCRS epsg:3577 . | ||
?ha2 dt:value ?a2 . | ||
} | ||
""" | ||
|
@@ -746,8 +757,9 @@ async def get_location_overlaps(target_uri, output_featuretype_uri, include_area | |
} . | ||
OPTIONAL { | ||
?i geox:hasAreaM2 ?ha3 . | ||
?ha3 qb4st:crs epsg:3577 . | ||
?ha3 dt:value ?a3 . | ||
# ?ha3 qb4st:crs epsg:3577 . | ||
?ha3 geox:inCRS epsg:3577 . | ||
?ha3 dt:value ?a3 . | ||
} | ||
} | ||
""" | ||
|
@@ -763,13 +775,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) | ||
|
@@ -783,7 +795,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) | ||
|
@@ -797,7 +809,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) | ||
|
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.