<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:36:27 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[SERVER-14948] Find Points near LineString</title>
                <link>https://jira.mongodb.org/browse/SERVER-14948</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;I couldn&apos;t find an existing ticket, so let me try my luck.&lt;/p&gt;

&lt;p&gt;I would like the ability to search for GeoJSON points that are within x meters of a GeoJSON Polyline. This is currently a costly query to implement outside of a database server, as I either have to; build a Polygon from a Polyline before using a $geoWithin, or hit Mongo multiple times using a $near, then filter all results for a distinct list of Points.&lt;/p&gt;

&lt;p&gt;An approach that could be achieved in the server would be (likely a naive implementation):&lt;br/&gt;
1. make a  LineString into a &apos;complex&apos; LineString by reducing the distance between each point to a small distance. JS example: &lt;a href=&quot;https://github.com/rwt-to/GeoJSON-Tools#complexify&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/rwt-to/GeoJSON-Tools#complexify&lt;/a&gt;&lt;br/&gt;
2. convert the LineString into a Polygon by creating a circle out of each point in the LineString, then merging them (haven&apos;t found an effective way of doing that yet, my Polygons become huge)&lt;br/&gt;
3. use $geoWithin internally to find Points in the Polygon.&lt;/p&gt;

&lt;p&gt;The second approach would be to perform step 1. above, then just use a $near for each point in the LineString, then filtering all the Points before returning a result.&lt;/p&gt;

&lt;p&gt;In case I haven&apos;t explained it clearly, here&apos;s a SO question explaining the issue: &lt;a href=&quot;http://stackoverflow.com/questions/19015861/find-points-near-linestring-in-mongodb-sorted-by-distance&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://stackoverflow.com/questions/19015861/find-points-near-linestring-in-mongodb-sorted-by-distance&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There is likely a more efficient way, but I haven&apos;t had the time to try find it. I think the query would still perform decently if ran internally on Mongo, as either method above would use indices while avoiding round-trips.&lt;/p&gt;

&lt;p&gt;Lastly, just for control, it seems like this is easily achievable in PostgreSQL &lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/smile.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt; : &lt;a href=&quot;http://stackoverflow.com/questions/10286899/find-the-nearest-points-along-the-linestring-in-specified-distance-limit-and-ord&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://stackoverflow.com/questions/10286899/find-the-nearest-points-along-the-linestring-in-specified-distance-limit-and-ord&lt;/a&gt;&lt;/p&gt;
</description>
                <environment></environment>
        <key id="153450">SERVER-14948</key>
            <summary>Find Points near LineString</summary>
                <type id="2" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14711&amp;avatarType=issuetype">New Feature</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</priority>
                        <status id="1" iconUrl="https://jira.mongodb.org/images/icons/statuses/open.png" description="">Open</status>
                    <statusCategory id="2" key="new" colorName="default"/>
                                    <resolution id="-1">Unresolved</resolution>
                                        <assignee username="backlog-query-integration">Backlog - Query Integration</assignee>
                                    <reporter username="nevi_me">Neville Dipale</reporter>
                        <labels>
                    </labels>
                <created>Mon, 18 Aug 2014 21:04:12 +0000</created>
                <updated>Wed, 22 Mar 2023 18:52:22 +0000</updated>
                                            <version>2.4.10</version>
                    <version>2.6.4</version>
                                    <fixVersion>features we&amp;#39;re not sure of</fixVersion>
                                    <component>Geo</component>
                                        <votes>3</votes>
                                    <watches>11</watches>
                                                                                                                <comments>
                            <comment id="2122034" author="jtuskan@usxpress.com" created="Mon, 21 Jan 2019 17:12:50 +0000"  >&lt;p&gt;@Siyuan Zhou My use case is having a collection of line strings representing vehicle routes. A vehicle&apos;s driver may only be able to complete the next 4 hours of driving along their current route, Route A. Route A is time critical. I need to find another vehicle route, Route B (non-critical), that is close to Route A in order to fulfill Route A.&lt;/p&gt;

&lt;p&gt;Using linear referencing, I slice the route into time segments of say 30 minutes. Then perform a $near query on each valid time segment point. But this does not match my use case. Because a circular or spherical distance without an excessively large query will have gaps without having a lot of overlapping $near queries. As well as, linear referencing being resource expensive. My query is not returning the entire data set.&lt;/p&gt;</comment>
                            <comment id="971318" author="siyuan.zhou@10gen.com" created="Tue, 21 Jul 2015 18:45:16 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=nevi_me&quot; class=&quot;user-hover&quot; rel=&quot;nevi_me&quot;&gt;nevi_me&lt;/a&gt;, I don&apos;t think MongoDB supports this feature currently. The following query gives an error of &lt;tt&gt;&quot;invalid point in geo near query $geometry argument&quot;&lt;/tt&gt;.&lt;/p&gt;

&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;coll.find({loc: {$near : {$geometry: {type: &quot;LineString&quot;, coordinates: [[0,0],[1,1],[2,2]]}}}});&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;The functions mentioned in the description and its references on StackOverflow are actually different. To my understanding, there are at least 3 different queries.&lt;br/&gt;
1. Find points $within a buffer of line, where a buffer means the area that&apos;s within a certain distance from the line.&lt;br/&gt;
2. Find points $within a buffer of line, then sort the results according to the distance from the line.&lt;br/&gt;
3. Find points $within a buffer of line, then sort the results along the driving order along the road.&lt;/p&gt;

&lt;p&gt;The first is a $within query, the second looks like a $near query and MongoDB doesn&apos;t have a counterpart of the third function. Could you please talk more about your use cases?&lt;/p&gt;

&lt;p&gt;Thanks,&lt;br/&gt;
Siyuan&lt;/p&gt;</comment>
                            <comment id="969327" author="nevi_me" created="Sat, 18 Jul 2015 11:57:31 +0000"  >&lt;p&gt;This looks fixed in 3.0. I was able to query a point against a polyline using `$near` successfully. I think the issue can be closed. The last time I tried it I was still using 2.6.&lt;/p&gt;</comment>
                            <comment id="696956" author="nevi_me" created="Wed, 20 Aug 2014 16:08:14 +0000"  >&lt;p&gt;Understandable.&lt;/p&gt;

&lt;p&gt;It&apos;s something I&apos;ve wanted to efficiently implement, so I&apos;ll keep working on it in JavaScript and see how efficient I can make it. C++ isn&apos;t my forte so maybe if someone else is interested in doing that on Mongo they could then port the implementation and submit a pull request.&lt;/p&gt;

&lt;p&gt;In terms of the $near interface, there shouldn&apos;t be significant/any change to how the API works externally. I reckon that the user should be able to specify a valid GeoJSON object, then Mongo should apply the existing logic for Points, and whatever the potential implementation would be for other types.&lt;/p&gt;

&lt;p&gt;Logically, all of this is possible, the pain is just in implementing it outside of the server as one can&apos;t enforce query limits properly, and the roundtrip cost. If I want to select 100 closest points, but I pull 120 from Mongo, and 30 of them are duplicates, I would end up with 90. Similarly, if&lt;br/&gt;
I construct a Polygon out of the LineString range, I&apos;d still need to calculate each Point&apos;s distance to the nearest boundary so I can filter by distance before applying limits.&lt;/p&gt;

&lt;p&gt;Finally, to reduce the frequency of &quot;I want this feature now or else ...&quot; comments on issues that we follow, more work could be done on server-side scripting so that interested parties could roll out our own enhancements to Mongo without pulling a TokuTek. Probably something to consider for 2.10 or 3.0.&lt;/p&gt;</comment>
                            <comment id="696716" author="greg_10gen" created="Wed, 20 Aug 2014 13:31:13 +0000"  >&lt;p&gt;Generalized near-to-shape isn&apos;t a bad idea, but would require some significant work (and potentially some changes to the $near interface).&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="25189">SERVER-4339</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>5.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                <customfield id="customfield_12751" key="com.atlassian.jira.plugin.system.customfieldtypes:multiselect">
                        <customfieldname>Assigned Teams</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="25467"><![CDATA[Query Integration]]></customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Wed, 20 Aug 2014 13:31:13 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        5 years, 3 weeks, 2 days ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[]]></customfieldvalue>


                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>dbeng-pm-bot</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            5 years, 3 weeks, 2 days ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>backlog-query-integration</customfieldvalue>
            <customfieldvalue>greg_10gen</customfieldvalue>
            <customfieldvalue>jtuskan@usxpress.com</customfieldvalue>
            <customfieldvalue>nevi_me</customfieldvalue>
            <customfieldvalue>siyuan.zhou@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrlpn3:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hr2j3b:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>133212</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_22870" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Triagers</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrizjb:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                    </customfields>
    </item>
</channel>
</rss>