gpt4 book ai didi

search - Solr 空间搜索输入点并查询其中的多边形

转载 作者:行者123 更新时间:2023-12-02 07:20:15 25 4
gpt4 key购买 nike

我在 Solr 中索引了一些多边形。是否可以查询一个点(纬度,经度)并查看哪个多边形内有该点?

最佳答案

是的,这是可能的,并在此处进行了描述:http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4您的 Solr 版本必须是 4 或更高,并且您必须导入 JTS jar 文件,您可以从 http://sourceforge.net/projects/jts-topo-suite/ 获取该文件。您必须定义一个 fieldType 为 location_rpt 的字段

<fieldType name="location_rpt"   class="solr.SpatialRecursivePrefixTreeFieldType"
spatialContextFactory="com.spatial4j.core.context.jts.JtsSpatialContextFactory"
distErrPct="0.025"
maxDistErr="0.000009"
units="degrees"
/>

在 schema.xml 中。然后你必须像这样索引多边形:

<field name="geo">POLYGON((-10 30, -40 40, -10 -20, 40 20, 0 0, -10 30))</field>

但我认为您已经这样做了,因为您写道您已经将它们编入索引。

对于查询,您只需使用过滤器查询fq=geo:"Intersects(10.12 50.02)",其中10.1250.02代表您所在点的纬度和经度。

关于search - Solr 空间搜索输入点并查询其中的多边形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19368588/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com