Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

convert gml to sdo geomtry using sparql

TaxonicMay 22 2023

Hi There,

I'm facing an issue converting my data to sdo_geometry. The data is stored in a turtle file with the following content:

?s gwsw:hasValue "<gml:LineString srsName=\"SDO:28992\" xmlns:gml=\"http://www.opengis.net/gml"><gml:posList srsDimension=\"2\"> 143422.06 412389.24 143456.76 412397.88</gml:posList></gml:LineString>"^^geo:gmlLiteral

I'm attempting to use two methods for the conversion:

1- sql and sdo_utl.from_gml311geometry() and here is my query:

SELECT URI, sdo_utl.from_gml311geometry(geom) AS geom1, hoog_Beginpunt, hoog_endpunt, value_Begindatum, value_BreedteLeiding, value_LengteLeiding from table(sem_match('
value_Straatnaam from table(sem_match('
prefix : <http://sparql.gwsw.nl/id/060797#>
prefix aamaas: <http://sparql.gwsw.nl/id/040654#>
prefix geo: <http://www.opengis.net/ont/geosparql#>
prefix gwsw: <http://data.gwsw.nl/1.5/totaal/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX gml: <http://www.opengis.net/gml/3.2>
prefix : <http://sparql.gwsw.nl/id/060797#>
prefix aamaas: <http://sparql.gwsw.nl/id/040654#>
prefix geo: <http://www.opengis.net/ont/geosparql#>
prefix gwsw: <http://data.gwsw.nl/1.5/totaal/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX gml: <http://www.opengis.net/gml/3.2>
SELECT
?URI (SUBSTR(STR(?geo), 0, STRLEN(STR(?geo))) AS ?geom) ?hoog_Beginpunt ?hoog_endpunt ?value_Begindatum ?value_BreedteLeiding ?value_LengteLeiding
WHERE {
?URI gwsw:isPartOf ?s .
?s a gwsw:Rioleringsgebied .
?s rdfs:label "vlijmen" .
?p a gwsw:Lijn .
?p gwsw:hasValue ?geo .
FILTER (REGEX(STR(?geo), "^(<gml:LineString)"))
?BobEindpuntLeiding a gwsw:BobEindpuntLeiding .
?BobEindpuntLeiding gwsw:hasValue ?hoog_endpunt.
?BobBeginpuntLeiding a gwsw:BobBeginpuntLeiding.
?BobBeginpuntLeiding gwsw:hasValue ?hoog_Beginpunt.
?LengteLeiding a gwsw:LengteLeiding.
?LengteLeiding gwsw:hasValue ?value_LengteLeiding.
?BreedteLeiding a gwsw:BreedteLeiding.
?BreedteLeiding gwsw:hasValue ?value_BreedteLeiding.
?URI gwsw:hasAspect ?Begindatum.
?Begindatum a gwsw:Begindatum.
?Begindatum gwsw:hasValue ?value_Begindatum.
?URI gwsw:isPartOf ?aspect.
?aspect gwsw:hasAspect ?hasAspect.
}',sem_models('TEST'), null, null, null, null, ' ', null, null,'MARYAMSAJJADIAN', 'RDF_NETWORK'));

My error:

The issue arises with the select part highlighted in blue, and I'm encountering errors with the SELECT (SELECT URI, sdo_utl.from_gml311geometry(geom) AS geom1, hoog_Beginpunt, hoog_endpunt, value_Begindatum, value_BreedteLeiding, value_LengteLeiding FROM table(sem_match(')).

It appears that using "sdo_utl.from_gml311geometry(geom) AS geom1" might be incorrect. When I ignore sdo_utl.from_gml311geometry and replace it with geom, the query works fine.

2- I'm new to PL/SQL, and I tried the following query, which also didn't work:

DECLARE
allData CLOB;
BEGIN
SPARQL.SELECT('
prefix : <http://sparql.gwsw.nl/id/060797#>
prefix aamaas: <http://sparql.gwsw.nl/id/040654#>
prefix geo: <http://www.opengis.net/ont/geosparql#>
prefix gwsw: <http://data.gwsw.nl/1.5/totaal/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX gml: <http://www.opengis.net/gml/3.2>
prefix : <http://sparql.gwsw.nl/id/060797#>
prefix aamaas: <http://sparql.gwsw.nl/id/040654#>
prefix geo: <http://www.opengis.net/ont/geosparql#>
prefix gwsw: <http://data.gwsw.nl/1.5/totaal/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX gml: <http://www.opengis.net/gml/3.2>
SELECT
?URI ?geo ?hoog_Beginpunt ?hoog_endpunt ?value_Begindatum ?value_BreedteLeiding ?value_LengteLeiding ?value_Straatnaam
WHERE {
?URI gwsw:isPartOf ?s .
?s a gwsw:Rioleringsgebied .
?s rdfs:label "vlijmen" .
?p a gwsw:Lijn .
?p gwsw:hasValue ?geo .
FILTER (REGEX(STR(?geo), "^(<gml:LineString)"))
?BobEindpuntLeiding a gwsw:BobEindpuntLeiding .
?BobEindpuntLeiding gwsw:hasValue ?hoog_endpunt.
?BobBeginpuntLeiding a gwsw:BobBeginpuntLeiding.
?BobBeginpuntLeiding gwsw:hasValue ?hoog_Beginpunt.
?LengteLeiding a gwsw:LengteLeiding.
?LengteLeiding gwsw:hasValue ?value_LengteLeiding.
?BreedteLeiding a gwsw:BreedteLeiding.
?BreedteLeiding gwsw:hasValue ?value_BreedteLeiding.
?URI gwsw:hasAspect ?Begindatum.
?Begindatum a gwsw:Begindatum.
?Begindatum gwsw:hasValue ?value_Begindatum.
?URI gwsw:isPartOf ?aspect.
?aspect gwsw:hasAspect ?hasAspect.
?hasAspect a gwsw:Straatnaam;
gwsw:hasValue ?value_Straatnaam.
}', allData);
-- Print the SPARQL query result
DBMS_OUTPUT.PUT_LINE('SPARQL Query Result:');
DBMS_OUTPUT.PUT_LINE(allData);

END;
/

I would appreciate your assistance with this problem.

Kind regards,

Maryam

Comments
Post Details
Added on May 22 2023
3 comments
459 views