Re: Solr spatial search within the polygon

2014-03-10 Thread Javi
Hi all.

I need your help! I have read every post about Spatial in Solr because I 
need to check if a point (latitude,longitude) is inside a Polygon.

/**/
/* 1. library */
/**/

(1) I use "jts-1.13.jar" and "spatial4j-0.4.1.jar"
(I think they are the latest version)

/*/
/* 2. schema.xml */
/*/


(I omit geo="true" because it is the default)

...



(Here I dont know what means if I add multiValued="true")

/*/
/* Document contents */
/*/
I have tried with 3 different content for my documents (lat-lon refers to 
Madrid, Spain):


a) As it is WKT format, I tried "longitude latitude" (x y)


  -3.69278 40.442179



b) As it is WKT format, I tried "POINT(longitude latitude) (x y)



  POINT(-3.69278 40.442179)



and

c) I tried no WKT format by adding a comma and using "longitude,latitude"



  40.442179,-3.69278



d) I tried no WKT format by adding a comma and using "latitude,longitude"



  -3.69278,40.442179



/*/
/* My solr query */
/*/

a) 
_Description: This POLYGON (in WKT format, so "longitude latitude") is a 
triangle that cover Madrid at all, so my point would be inside them.
_Result: Query return 0 documents (which is wrong).
 
http://localhost:8983/solr/pisos22/select?q=*%3A*&;
fl=LOCATION&
wt=xml&
indent=true&
fq=LOCATION:"IsWithin(POLYGON((
-3.732605 40.531415,
-3.856201 40.336993,
-3.493652 40.332806,
-3.732605 40.531415
))) distErrPct=0"

b) 
_Descripcion: This POLYGON (in WKT format, so "longitude latitude") is a 
rectangle out of Madrid, so my point would not be inside them.
_Result: Query return 0 documents (which is correct).

http://localhost:8983/solr/pisos22/select?q=*%3A*&;
fl=LOCATION&
wt=xml&
indent=true&
fq=LOCATION:"IsWithin(POLYGON((
-4.0594 40.8708,
-4.0621 40.7211 ,
-3.8095 40.7127,
-3.8232 40.8687,
-4.0594 40.8708
))) distErrPct=0"

***I also tried modifying the order of lat/lon but I am not able to find out 
the solution to make it work.




Re: Intersect Circle is matching points way outside the radius ( Solr 4 Spatial)

2012-12-19 Thread Javi Molina
Hi David,

Your latest response was lost in my inbox, I just realised it was there.


You are right, I am using Open Layers, and even though I use the mercator
projection, there are elements that not adhere to that projection, in
particular the polygon that generates the circle and the scale control.

Precisely as you mention a circle drawn using the mrcator projection will
look more enlarged when drawn close to the poles than it really is (just as
Greenland)

I mentioned multiple times to my team, the complexity was not in learning
Open Layers but in grasping the concept of projections properly.


Javier

On 11 December 2012 16:28, David Smiley (@MITRE.org) wrote:

> Javier,
>
> I want to expand upon what I said; you might already get this point but
> others may come along and read this and might not.
>
> Naturally you are using a 2D map as most applications do (Google Earth is
> the stand-out exception), and fundamentally this means the map is projected
> -- it has to be.  There isn't a "right" (correct) projection, generally
> speaking.  Most/all web based map APIs are strictly "web mercator".  If you
> have a map GUI selection tool in which a circle is drawn, a perfect looking
> round circle, then it's a lie unless you're looking directly at the
> equator.
> If the intent is for the user to draw a distance based circle, then ideally
> your map tool should draw an elliptical looking circle if it's to be
> accurate.  This is why you got confused; you saw a circle yet the point
> wasn't drawn in the circle because that circle *should have been* stretched
> vertically to barely pass it.  If on the other hand you intend for the
> query
> shape to be exactly what it displays to be (what appears to be a perfect
> circle), even though this means the true geodetic shape is not a perfect
> circle, then you could use geo="false" (and configure some other
> attributes)
> such that you are using standard planar math, not geodetic.  Then your
> query
> shape would appear to work correctly but IMO its misleading over the first
> option (draw an ellipse, not a circle).  The circle misleads the user; it
> mislead you.
>
> ~ David
>
>
> Javier Molina wrote
> > Hi David,
> >
> > As it happens the points are using the right projection, I can see them
> in
> > the same position using the page you just provided.
> >
> > There is something wrong with the radius of the circle though I need to
> > investigate that but it is a relief to know that there is nothing wrong
> > with Solr and that I didn't mix the concepts, it is just as in many cases
> > the problem is somewhere else where you would never imagine.
> >
> > Thanks for the hint.
> >
> > Cheers,
> > Javier
> >
> >
> >
> >
> >
> > On 11 December 2012 02:47, David Smiley (@MITRE.org) <
>
> > DSMILEY@
>
> > >wrote:
> >
> >> Javi,
> >>   The center point of your query circle and the indexed point is just
> >> under
> >> 49.9km (just under your query radius); this is why it matched.  I
> plugged
> >> in
> >> your numbers here:
> >> http://www.movable-type.co.uk/scripts/latlong.html
> >> Perhaps you are misled by the projection you are using to view the map,
> >> on
> >> how far away the points are.
> >>
> >> FYI The default distErrPct of 0.025 should be fine in general and wasn't
> >> the
> >> issue.  You should (almost) never use 0.0 on the field type because that
> >> means your indexed non-point shapes (rectangles you said) will use a ton
> >> of
> >> indexed terms unless they are very small rectangles (relative to your
> >> grid
> >> resolution -- 1 meter in your case).  Using distErrPct=0 in the query is
> >> safe, on the other hand.
> >>
> >> Cheers,
> >>   David
> >>
> >>
> >>
> >> -
> >>  Author:
> >> http://www.packtpub.com/apache-solr-3-enterprise-search-server/book
> >> --
> >> View this message in context:
> >>
> http://lucene.472066.n3.nabble.com/Intersect-Circle-is-matching-points-way-outside-the-radius-Solr-4-Spatial-tp4025609p4025704.html
> >> Sent from the Solr - User mailing list archive at Nabble.com.
> >>
>
>
>
>
>
> -
>  Author:
> http://www.packtpub.com/apache-solr-3-enterprise-search-server/book
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Intersect-Circle-is-matching-points-way-outside-the-radius-Solr-4-Spatial-tp4025609p4025924.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>
>
>
>