Strabon

annotate scripts/example-query.py @ 1422:f86d1129ce79

it turns out that there is no simple way of having the datatype of a constant geometry available in the query builder, thus it is not easy for geof:getSRID to determine the correct datatype and return the appropriate URI for the CRS, when that has SRID 4326. Therefore, we choose to always return CRS84, even for strdf:WKT arguments. Notice, that when geof:getSRID is called evaluated in Java, we have such information available and we can return the correct result. However, we chose in changeset 1420:37792dd7041b to always push the evaluation of all spatial functions in the database. The respective tests have been updated as well.
author Babis Nikolaou <charnik@di.uoa.gr>
date Tue Sep 23 14:05:26 2014 +0300 (2014-09-23)
parents
children
rev   line source
kkyzir@126 1 #!/usr/bin/env python
kkyzir@126 2
kkyzir@126 3 import sys, re, os
kkyzir@126 4 import os
kkyzir@126 5 import glob
kkyzir@126 6 import time
kkyzir@126 7 import shutil
kkyzir@126 8 import httplib, urllib
kkyzir@126 9
kkyzir@126 10 def main(argv):
kkyzir@126 11
kkyzir@126 12 query = 'PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX strdf: <http://strdf.di.uoa.gr/ontology#> PREFIX noa: <http://teleios.di.uoa.gr/ontologies/noaOntology.owl#> SELECT ?H (strdf:transform(?HGEO, <http://www.opengis.net/def/crs/EPSG/0/4326>) AS ?GEO) WHERE { ?H rdf:type noa:Hotspot . ?H noa:hasAcquisitionTime ?HAT . FILTER(str(?HAT) = "2010-08-21T21:20:00") . ?H noa:isDerivedFromSensor ?HS . FILTER(str(?HS) = "MSG1_RSS" ) . ?H noa:hasGeometry ?HGEO . }'
kkyzir@126 13 params = urllib.urlencode({'SPARQLQuery': query, 'format': "XML"})
kkyzir@126 14 headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/xml"}
kkyzir@126 15
kkyzir@126 16 #conn = httplib.HTTPConnection("papos.space.noa.gr:8080")
kkyzir@126 17 #conn.request("POST", "/endpoint/Query", params, headers)
kkyzir@126 18
kkyzir@126 19 conn = httplib.HTTPConnection("test.strabon.di.uoa.gr")
kkyzir@126 20 conn.request("POST", "/NOA/Query", params, headers)
kkyzir@126 21
kkyzir@126 22 response = conn.getresponse()
kkyzir@126 23 print response.status, response.reason
kkyzir@126 24 print response.msg
kkyzir@126 25 print response.read()
kkyzir@126 26 return 0
kkyzir@126 27
kkyzir@126 28 if __name__ == "__main__":
kkyzir@126 29 sys.exit(main(sys.argv))