David, thanks for the kind words.  Your Solr book is terrific.  Without
it, my project would not have succeeded.  I am in your debt.

    The above spatial query filter eliminates GIS layers that do not
intersect a given map.  I attempt to rank the intersecting layers according
to how similar they are to the map.  The concept is the user can manipulate
the map to find GIS layers for a region.  If the user zooms in to a city,
they most likely want some local data for the city.  If the user zooms out
so that map displays an entire continent, the user probably isn’t very
interested in city street data.  Zooming the map out to display a continent
tells the application to increase the score for continent scale data.

    The spatial query has four components.  Three of the components simply
compare the area, center latitude and center longitude of the map to the
layer.  The closer properties of the layer are to the properties of the map,
the higher their score.  I use a recip function to compute these three
scores.  Scoring based on area is weighted the most with a boost of 15.  The
boost for matching center latitude and center longitude is 3 for each.  

The fourth spatial query component boosts layers that are completely
contained within the map extents.  It counts how many of the four corners of
the layer are contained within the map.  If the number of contained corners
equals 4, the layer is given a boost of 10.  Like the filter query, the
“contained within” query computes a value and then maps it to between 0 and
1 to essentially implement an “if” statement.

The full query includes these four spatial components and keyword based
clauses.  The scoring is set up so that the spatial components dominate. 
Currently, the keyword based query terms have a boost of 2 or 3.  Additional
filter queries can limit search results based on the year the layer was
created or its data type (raster, vector, etc.).  

If anybody wants to see the code, there’s about 800 lines of JavaScript at
http://code.google.com/p/opengeoportal/source/browse/WebContent/javascript/solr.js.
 
It provides a JavaScript object you can instantiate, call set functions like
setBoundingBox, setDates, and then call sendToSolr to execute a search via
JSONP.

Rather then a single bounding box per GIS layer I would like to support
multiple shapes.  The bounding box works pretty well, there aren’t a lot of
diagonal states or countries.  However, if I could break down a single
bounding box into something more detailed, search would be better.  I
haven’t figured out how to do that yet!  The meta data associated with each
layer doesn’t provide anything more detailed then an axis aligned bounding
box.  

I’ll look into FieldCaches, that sounds like something I should know about. 
In my application I can run relatively expensive queries because I don’t
have all that much data to search.  Currently I have around 9k GIS data
layers.  Maybe that will reach 100k, but probably not even that.  



--
View this message in context: 
http://lucene.472066.n3.nabble.com/intersecting-map-extent-with-solr-spatial-documents-tp3104098p3108219.html
Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to