lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Nix <...@spatially.com>
Subject Re: [spatial] Indexing polygons?
Date Mon, 11 Jan 2016 06:11:18 GMT
Hi David,

No worries. It looks like the CompositeSpatialStrategy was the piece I was
missing.

Thanks for the pointers,
Robert


On Sun, Jan 10, 2016 at 9:53 PM david.w.smiley@gmail.com <
david.w.smiley@gmail.com> wrote:

> Hi Robert,
>
> First, for the basics of the spatial module, see SpatialExample.java in the
> tests area.  It doesn't include a polygon example but shows the concepts of
> a SpatialContext, Shape, and SpatialStrategy which are the key
> abstractions.
>
> The default SpatialContext implementation doesn't handle polygons -- not
> yet any way.  So use JtsSpatialContext.GEO or some other configured variant
> created via JtsSpatialContextFactory and add JTS to your classpath (LGPL
> licensed, by the way).  With that, you can create polygons parsed from WKT
> or GeoJSON -- see the SpatialContext.getFormats().getWktReader() for
> example.  That'll produce a Shape instance parsed from a polygon WKT string
> you give it.  Then re-aquaint yourself with SpatialExample.java to see how
> to index a Shape and how to query by a Shape.  An important difference with
> the example is the choice of an appropriate SpatialStrategy.  The example
> uses RecursivePrefixTreeStrategy which is best for points-only data;
> otherwise I recommend CompositeSpatialStrategy.
>
> I'm actively working on a SpatialContext implementation for "Geo3d" which
> will be another option.  Your code wouldn't change other than choosing a
> different SpatialContext impl.
>
> By the way, the one-liner in your email I see you found in
> SpatialExample.java:
>   doc.add(new StoredField(strategy.getFieldName, pt.getX + " " + pt.getY))
> -- is purely for the "stored" version (for document retrieval in search
> results); not for indexing/search.  See the comments preceding it ;-)
>
> Good luck.  And sorry for leaving you hanging for a few days; I overlooked
> your email.
> ~ David
>
> On Wed, Jan 6, 2016 at 10:59 PM Robert Nix <rob@spatially.com> wrote:
>
> > Hi,
> >
> > Is there an example in the lucene-solr source to show how to index
> polygons
> > and how to search with and for indexed polys? I'm looking in
> > lucene/spatial/src/test/ and I see an example of a point and it seems
> > obvious:
> >
> > doc.add(new StoredField(strategy.getFieldName, pt.getX + " " + pt.getY))
> >
> > But nothing regarding polygons is jumping out at me. If there isn't such
> an
> > example, can someone provide a short one?
> >
> > Thanks
> > --
> > --nix
> >
> --
> Lucene/Solr Search Committer, Consultant, Developer, Author, Speaker
> LinkedIn: http://linkedin.com/in/davidwsmiley | Book:
> http://www.solrenterprisesearchserver.com
>
-- 
--nix

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message