<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 04:14:35 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-27248] Provide a way to Calculate Centroid and Radius of Geo Records</title>
                <link>https://jira.mongodb.org/browse/SERVER-27248</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Consider the following use case:&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;We are developing a new feature for our system that revolves displaying documents from the database on a map. We need to filter the documents by various criteria (not location) and then display the matching documents on a map.&lt;/p&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;&lt;p&gt;In order to choose the center and zoom level of the map, we need the centroid of the returned records, and the radius that would contain them. Is there a way to retrieve that information using aggregation framework, or do I need to pull all records from MongoDB and do the calculation on our end?&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;It certainly seems like geoNear is the right solution for computing the distance on the last step so they can center their output, but there doesn&apos;t seem to be an easy way to do the centroid computation external to the pipeline and pass the resultant values into the geoNear call.  Would it be feasible to remove that restriiction on geoNear so that it could be placed anywhere within an aggregation pipeline?&lt;/p&gt;</description>
                <environment></environment>
        <key id="335460">SERVER-27248</key>
            <summary>Provide a way to Calculate Centroid and Radius of Geo Records</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="4">Incomplete</resolution>
                                        <assignee username="backlog-server-query">Backlog - Query Team</assignee>
                                    <reporter username="lorne.schachter">Lorne Schachter</reporter>
                        <labels>
                    </labels>
                <created>Thu, 1 Dec 2016 14:12:44 +0000</created>
                <updated>Tue, 6 Dec 2022 04:10:33 +0000</updated>
                            <resolved>Tue, 7 Aug 2018 16:55:13 +0000</resolved>
                                                                    <component>Aggregation Framework</component>
                    <component>Geo</component>
                                        <votes>2</votes>
                                    <watches>11</watches>
                                                                                                                <comments>
                            <comment id="1969336" author="asya" created="Tue, 7 Aug 2018 16:55:13 +0000"  >&lt;p&gt;It&apos;s not clear exactly what the feature would be, so closing as incomplete.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;</comment>
                            <comment id="1464301" author="asya" created="Thu, 22 Dec 2016 19:50:01 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=lorne.schachter&quot; class=&quot;user-hover&quot; rel=&quot;lorne.schachter&quot;&gt;lorne.schachter&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I don&apos;t believe moving $geoNear later in the pipeline would be sufficient, as it &lt;b&gt;takes&lt;/b&gt; a center point, it does not provide or calculate one.&lt;/p&gt;

&lt;p&gt;I&apos;m going to convert this ticket to a request for enhancement to allow such a calculation.&lt;/p&gt;

&lt;p&gt;Meanwhile, if the geometry of the points in question is flat (rather than spherical) you can approximate such a calculation by figuring out mix/max and average of X and Y coordinates.&lt;/p&gt;

&lt;p&gt;If the aggregation pipeline selects a subset of documents, do the following, assuming the documents output have coordinates &quot;loc.x&quot; and &quot;loc.y&quot;?:&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;   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;... {earlier pipeline}, &lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;    {$group:{_id:null, maxX:{$max:&quot;$loc.x&quot;}, minX:{$min:&quot;$loc.x&quot;}, maxY:{$max:&quot;$loc.y&quot;},minY:{$min:&quot;$loc.y&quot;} }}, &amp;lt;other fields if they need them&amp;gt;},&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;    {addFields:{center:{&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;          x:{$divide:[{$add:[&quot;$maxX&quot;,&quot;$minX&quot;]}, 2]},&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;          y:{$divide:[{$add:[&quot;$maxY&quot;,&quot;$minY&quot;]}, 2]}&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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-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;    }}}&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;
</comment>
                            <comment id="1464276" author="lorne.schachter" created="Thu, 22 Dec 2016 19:19:14 +0000"  >&lt;p&gt;Asya,&lt;/p&gt;

&lt;p&gt;So, is there no way to (easily) address this use case?  It doesn&apos;t seem that unreasonable and you can certainly imagine lots of applications that might want to do the same thing.&lt;/p&gt;

&lt;p&gt;Lorne&lt;/p&gt;</comment>
                            <comment id="1464245" author="asya" created="Thu, 22 Dec 2016 18:54:37 +0000"  >&lt;p&gt;I believe it&apos;s required to be first because it must be able to use a 2dsphere index.  &lt;/p&gt;</comment>
                            <comment id="1462437" author="lorne.schachter" created="Tue, 20 Dec 2016 19:21:17 +0000"  >&lt;p&gt;Asya,&lt;/p&gt;

&lt;p&gt;That&apos;s my understanding of how $geoNear works.&lt;/p&gt;

&lt;p&gt;Lorne&lt;/p&gt;</comment>
                            <comment id="1462378" author="asya" created="Tue, 20 Dec 2016 18:34:26 +0000"  >
&lt;p&gt;I see, both geoNear stage and $match with $nearSphere require fixed maxDistance - the issue is just that $match returns matching documents as they are, and $geoNear injects a new field showing actual distance, is that right?&lt;/p&gt;</comment>
                            <comment id="1455661" author="lorne.schachter" created="Mon, 12 Dec 2016 20:48:01 +0000"  >&lt;p&gt;Charles,&lt;/p&gt;

&lt;p&gt;I think that&apos;s exactly the use case they have - find nearest n and display.&lt;/p&gt;

&lt;p&gt;Lorne&lt;/p&gt;

&lt;p&gt;On Mon, Dec 12, 2016 at 3:35 PM, Charlie Swanson (JIRA) &amp;lt;jira@mongodb.org&amp;gt;&lt;/p&gt;




&lt;p&gt;&amp;#8211; &lt;br/&gt;
Lorne Schachter&lt;br/&gt;
Technical Services Engineer&lt;br/&gt;
MongoDB&lt;br/&gt;
lorne.schachter@mongodb.com&lt;br/&gt;
Deploy in the cloud with MongoDB Atlas, our new service that gets you up&lt;br/&gt;
and running in minutes. Learn more here &amp;lt;&lt;a href=&quot;https://www.mongodb.com/cloud&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://www.mongodb.com/cloud&lt;/a&gt;&amp;gt;!&#8203;&lt;/p&gt;</comment>
                            <comment id="1455634" author="charlie.swanson" created="Mon, 12 Dec 2016 20:31:30 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=asya&quot; class=&quot;user-hover&quot; rel=&quot;asya&quot;&gt;asya&lt;/a&gt; I will admit I am not experienced with geo queries, but it sounds like the desired radius for the $nearSphere is unknown. I could imagine something like &quot;find the closest grocery stores&quot;, where maybe there needs to be some $lookup or $redact or something to check if a user is allowed to see a grocery store (I don&apos;t know why that would be the case, but for something other than grocery stores it might make sense), then a useful display of your results would need to know how far to zoom the map. If I&apos;m in Manhattan I would want to zoom closer than if I were in say Kansas where the grocery stores are likely farther apart. Does that make sense?&lt;/p&gt;</comment>
                            <comment id="1452617" author="asya" created="Thu, 8 Dec 2016 19:08:40 +0000"  >&lt;p&gt;Couldn&apos;t you use $match with $nearSphere in later stage?&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                                        </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                <customfield id="customfield_12751" key="com.atlassian.jira.plugin.system.customfieldtypes:multiselect">
                        <customfieldname>Assigned Teams</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="25143"><![CDATA[Query]]></customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Thu, 8 Dec 2016 19:08:40 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        5 years, 27 weeks, 1 day 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>alexander.golin@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            5 years, 27 weeks, 1 day ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>asya.kamsky@mongodb.com</customfieldvalue>
            <customfieldvalue>backlog-server-query</customfieldvalue>
            <customfieldvalue>charlie.swanson@mongodb.com</customfieldvalue>
            <customfieldvalue>lorne.schachter</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrjpkn:</customfieldvalue>

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</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|hrjd93:</customfieldvalue>

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