希腊夏季,第2卷 [英] Summer in Greece, vol.2

查看:157
本文介绍了希腊夏季,第2卷的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

继此qeustion之后: SPARQL希腊夏季,因为我的记忆用完了当执行这个查询时,我想约束两个区域单元之间的查询,但是我不能将它们分组:

Following this qeustion: Summer in Greece with SPARQL, since my memory runs out when executing this query, I would like to constrain the query between two regional units, but I can't group them:

SELECT * #?municipality (?bwCount1+?bwCount2 as ?bwCount)
WHERE { 
{
    SELECT (COUNT(?bw) as ?bwCount1) WHERE 
    {
           ?regional_unit geo:έχει_επίσημο_όνομα "ΠΕΡΙΦΕΡΕΙΑΚΗ ΕΝΟΤΗΤΑ ΗΡΑΚΛΕΙΟΥ" .
           ?municipality1 geo:ανήκει_σε ?regional_unit .
           ?municipality1 geo:έχει_γεωμετρία ?geometry .

           ?bw geos:hasGeometry ?bw_geo .
           ?bw_geo geos:asWKT ?bw_geo_wkt .
           FILTER(strdf:within(?geometry, ?bw_geo_wkt)) .
           ?bw unt:has_concie_0 ?concie_0 .
           FILTER(?concie_0 > 40)
    }
}
UNION
{
    SELECT (COUNT(?bw) as ?bwCount2) WHERE 
    {
           ?regional_unit geo:έχει_επίσημο_όνομα "ΠΕΡΙΦΕΡΕΙΑΚΗ ΕΝΟΤΗΤΑ ΛΕΣΒΟΥ" .
           ?municipality2 geo:ανήκει_σε ?regional_unit .
           ?municipality2 geo:έχει_γεωμετρία ?geometry .

           ?bw geos:hasGeometry ?bw_geo .
           ?bw_geo geos:asWKT ?bw_geo_wkt .
           FILTER(strdf:within(?geometry, ?bw_geo_wkt)) .
           ?bw unt:has_concie_0 ?concie_0 .
           FILTER(?concie_0 > 40)
    }
}
}
#GROUP BY ?municipality
#ORDER BY DESC(?bwCount)

我缺少什么?

What am I missing?

推荐答案

您可能再次将自己与子选择混淆,这可能导致内存使用效率低下。我看到了一些获得我想要的结果的方法(这有点不清楚)。第一种是使用 UNION

You may again be confusing yourself with the sub-selects, and this could be causing inefficient use of memory. I see a couple of way of getting the results I believe you want (it is a bit unclear). The first is by using UNION:

SELECT (COUNT(?bw1) as ?bwCount1) (COUNT(?bw2) as ?bwCount2)
WHERE { 
   ?municipality1 geo:ανήκει_σε ?regional_unit .
   ?municipality1 geo:έχει_γεωμετρία ?geometry .
   {
     ?regional_unit geo:έχει_επίσημο_όνομα "ΠΕΡΙΦΕΡΕΙΑΚΗ ΕΝΟΤΗΤΑ ΗΡΑΚΛΕΙΟΥ" .
     ?bw2 geos:hasGeometry ?bw_geo .
   }
   UNION
   {
     ?regional_unit geo:έχει_επίσημο_όνομα "ΠΕΡΙΦΕΡΕΙΑΚΗ ΕΝΟΤΗΤΑ ΛΕΣΒΟΥ" .
     ?bw1 geos:hasGeometry ?bw_geo .
   }
   ?bw_geo geos:asWKT ?bw_geo_wkt .
   FILTER(strdf:within(?geometry, ?bw_geo_wkt)) .
   ?bw unt:has_concie_0 ?concie_0 .
   FILTER(?concie_0 > 40)
}

是不要在 UNION 内重复三重模式,除非它们是分离计算的一部分。

A best practice here is to not repeat triple patterns inside the UNION unless they are part of the disjunction computation.

你也可以做 on?regional_unit:

You could also do this with a group by on ?regional_unit:

SELECT (COUNT(?bw) as ?bwCount1)
WHERE { 
  VALUES ?name {"ΠΕΡΙΦΕΡΕΙΑΚΗ ΕΝΟΤΗΤΑ ΗΡΑΚΛΕΙΟΥ" "ΠΕΡΙΦΕΡΕΙΑΚΗ ΕΝΟΤΗΤΑ ΛΕΣΒΟΥ"}
  ?municipality1 geo:ανήκει_σε ?regional_unit .
  ?municipality1 geo:έχει_γεωμετρία ?geometry .
  ?regional_unit geo:έχει_επίσημο_όνομα ?name .
  ?bw geos:hasGeometry ?bw_geo .
  ?bw_geo geos:asWKT ?bw_geo_wkt .
  FILTER(strdf:within(?geometry, ?bw_geo_wkt)) .
  ?bw unt:has_concie_0 ?concie_0 .
  FILTER(?concie_0 > 40)
} GROUP BY ?regional_unit

这篇关于希腊夏季,第2卷的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆