[ 
https://issues.apache.org/jira/browse/SOLR-2268?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12968545#action_12968545
 ] 

Grant Ingersoll commented on SOLR-2268:
---------------------------------------

This is a work in progress.  Here are a few ideas:
I think this can all be accomplished via a few things:

For the case where the field is a polygon and the user supplies a point, we 
need a new FieldType, PolygonType.

I would propose the following format: vertices are separated by semi-colons, 
points are separated by commas just as they are for the other capabilities, 
i.e.: 1.0,1.0;0.0,0.0;3.0,3.0 gives the vertices <1.0,1.0> <0,0>, <3, 3>.  
Lines are assumed between each point.  See the java.awt.Polygon class 


Next, I think we can cover everything else through some function queries:
For case one above
{code}
pip(pt, dimension, boost) -- pt can be a PointType or a Vector.  Boost says how 
much score to give if a point is in a polygon

pipll(latlonPt, boost) -- Use spherical calculations to determine if the lat 
lon point is in the polygon, as it is laid on a sphere 
//Note, we may just fold this into the one above, but I think the calculations 
could be different enough that we would want to avoid instanceof checks.  Plus 
the parsing is simpler
{code}

For case two above, the user would pass in a polygon as defined above for the 
PolygonType.  In this case, we still need a function query:
{code}
pip(poly, boost) -- poly is the passed in polygon, boost is the value to give 
if the point is in a polygon
{code}

For PointType, we can just use capabilities of java.awt.Polygon, for lat lon, 
I'm still investigating.  It could be we still use Polygon, but maybe we can 
just scale it a little bit bigger and live with some error.  Otherwise, there 
seems to be some decent algorithms for doing it w/ lat/lon 
(http://msdn.microsoft.com/en-us/library/cc451895.aspx for one).  Not sure that 
one is practical at scale, but it could be a start.

While we are at it, it shouldn't be that hard to do the same for lines, i.e. is 
the point on a line.

> Add support for Point in Polygon searches
> -----------------------------------------
>
>                 Key: SOLR-2268
>                 URL: https://issues.apache.org/jira/browse/SOLR-2268
>             Project: Solr
>          Issue Type: New Feature
>            Reporter: Grant Ingersoll
>            Assignee: Grant Ingersoll
>
> In spatial applications, it is common to ask whether a point is inside of a 
> polygon.  Solr could support two forms of this: 
> # A field contains a polygon and the user supplies a point.  If it does, the 
> doc is returned.  
> # A document contains a point and the user supplies a polygon.  If the point 
> is in the polygon, return the document
> With both of these case, it would be good to support the negative assertion, 
> too.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to