Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[spatial4j-dev] Writing shapes to WKT/GeoJSON

I am looking for a nice way to expose Shapes in an Apache Solr response writer.

I have hacked something together that will convert a Shape (JTS or otherwise) to a NamedList in a DocTransformer.  This works OK -- it is a bit ugly and not something that could generally work in Solr since it is JTS specific.  It also uses a lot more memory than necessary because creates temporary NamedList objects.

I have seen this comment:
<b>Spatial4j in the near future won't support writing shapes to strings.</b>

https://github.com/spatial4j/spatial4j/blob/master/src/main/java/com/spatial4j/core/context/SpatialContext.java#L324


Are we sure this is a good idea?   If the problem is that we do not have a consistent format (WKT vs 'x, y') can't we just pick a standard format?


Are there objections to adding 'write' functions on the Shape interface?  Maybe:


  public void writeGeoJSON(Writer writer) throws IOException;

  public void writeWKT(Writer writer) throws IOException;


Alternatively, should this be done in the SpatialContext?  If so, is there a reason we do not have:


  public SpatialContext getSpatialContext();


With some write options available, we could add out-of-the-box support for Shapes in the Solr response.  As is, we kind of require the output to be a stored text field, and have no option if the Shape is modified (clipped, whatever)



thoughts?


ryan


Back to the top