列结果意外不返回任何内容

时间:2019-03-26 11:37:26

标签: sparql

有一个SPARQL查询,我认为应该Airport_Name不返回任何内容。

 PREFIX nas: <https://data.nasa.gov/ontologies/atmonto/NAS#>
 PREFIX gen: <https://data.nasa.gov/ontologies/atmonto/general#>


SELECT *
WHERE{
{
{SELECT ?Airport_Name{
    ?Airport rdf:type nas:Airport ;
    nas:airportName ?Airport_Name .
    }
}

}UNION{
    ?Location rdf:type gen:PointLocation;
    gen:longitude ?X ;
    gen:latitude ?Y .

}


?Location rdf:type gen:PointLocation;
gen:longitude ?X ;
gen:latitude ?Y .
FILTER (?X > -80 && ?X < -64 && ?Y > 18 && ?Y < 32)

}

预期结果应返回LocationXYAirport_Name

Example result

当我尝试在底部返回Airport_Name时,Location列将显示为空白,因此我不确定做错了什么。如果有人能指出我正确的方向,那将不胜感激。

1 个答案:

答案 0 :(得分:1)

您的查询有几个问题,正确的查询如下所示。

查询

SELECT  *
WHERE
  { ?airport  rdf:type/rdfs:subClassOf*  nas:Airport ;
              nas:airportName      ?Airport_Name ;
              nas:airportLocation  ?location .
    ?location  gen:longitude       ?X ;
               gen:latitude        ?Y
    FILTER ( ?X > "-80"^^xsd:float && ?X < "-64"^^xsd:float && ?Y > "18"^^xsd:float && ?Y < "32"^^xsd:float )
  }

结果(带有LIMIT 10的示例)

--------------------------------------------------------------------------------------------------------------------------
| airport         | Airport_Name                | location            | X                       | Y                      |
==========================================================================================================================
| nas:MYEMairport | "Governors Harbour"         | nas:MYEMcoordinates | "-76.330178"^^xsd:float | "25.283586"^^xsd:float |
| nas:MDPCairport | "Punta Cana Intl"           | nas:MDPCcoordinates | "-68.366186"^^xsd:float | "18.570781"^^xsd:float |
| nas:MUGTairport | "Mariana Grajales"          | nas:MUGTcoordinates | "-75.158333"^^xsd:float | "20.085278"^^xsd:float |
| nas:MDSTairport | "Cibao Intl"                | nas:MDSTcoordinates | "-70.604689"^^xsd:float | "19.406092"^^xsd:float |
| nas:MYLSairport | "Stella Maris"              | nas:MYLScoordinates | "-75.268778"^^xsd:float | "23.583047"^^xsd:float |
| nas:MBNCairport | "North Caicos"              | nas:MBNCcoordinates | "-71.939658"^^xsd:float | "21.917486"^^xsd:float |
| nas:MUMOairport | "Orestes Acosta"            | nas:MUMOcoordinates | "-74.922222"^^xsd:float | "20.653889"^^xsd:float |
| nas:MYRPairport | "New Port Nelson"           | nas:MYRPcoordinates | "-74.836186"^^xsd:float | "23.684378"^^xsd:float |
| nas:MYEGairport | "George Town"               | nas:MYEGcoordinates | "-75.781670"^^xsd:float | "23.466667"^^xsd:float |
| nas:MUBYairport | "Carlos Manuel De Cespedes" | nas:MUBYcoordinates | "-76.621389"^^xsd:float | "20.396389"^^xsd:float |
--------------------------------------------------------------------------------------------------------------------------

请注意,查询使用属性路径rdf:type/rdfs:subClassOf*,该属性路径仅在您还加载了本体(NAS.ttl)时才有效。属性路径是必需的,因为实例数据(airportInst.ttl使用nas:Airport的子类,例如nas:InternationAirportnas:CanadianAirport