You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Bar Rotstein (JIRA)" <ji...@apache.org> on 2019/02/22 09:01:00 UTC

[jira] [Comment Edited] (SOLR-13263) Facet Heat Map should support GeoJSON

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

Bar Rotstein edited comment on SOLR-13263 at 2/22/19 9:00 AM:
--------------------------------------------------------------

Uploaded a no-commit patch, showcasing the non deprecated parsing function.
SpatialUtils#parseGeomSolrException:45
{code:java}  /**
   * Parses a 'geom' parameter (might also be used to parse shapes for indexing). {@code geomStr} can either be WKT or
   * a rectangle-range syntax (see {@link #parseRectangle(String, org.locationtech.spatial4j.context.SpatialContext)}.
   */
  public static Shape parseGeomSolrException(String geomStr, SpatialContext ctx) {
    if (geomStr.length() == 0) {
      throw new IllegalArgumentException("0-length geometry string");
    }
    char c = geomStr.charAt(0);
    if (c == '[' || c == '{') {
      return parseRectangeSolrException(geomStr, ctx);
    }
    //TODO parse a raw point?
    try {
      return ctx.getFormats().read(geomStr);
      // return ctx.readShapeFromWkt(geomStr);
    } catch (InvalidShapeException e) {
      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
          "Could not parse string into a shape': " + e, e);
    }

  }{code}
Ran all non bad apple Solr tests, which all passed successfully.
One minor gripe is that Spatial4J does not support parsing GeoJSON polygons, and throws an exception, asking to use JTS instead.
I'll try and set up a new test suite for this.
This makes me wonder though, how does Solr currently deal with error caused since Spatial4J is not as feature rich as JTS?
I have not found a Solr test suite that includes JTS, only a Lucene oriented one.
Is anyone aware of a test suite which includes JTS in its Solr Core instance?


was (Author: brot):
Uploaded a no-commit patch, showcasing the non deprecated parsing function.
SpatialUtils#parseGeomSolrException:45
{code:java}  /**
   * Parses a 'geom' parameter (might also be used to parse shapes for indexing). {@code geomStr} can either be WKT or
   * a rectangle-range syntax (see {@link #parseRectangle(String, org.locationtech.spatial4j.context.SpatialContext)}.
   */
  public static Shape parseGeomSolrException(String geomStr, SpatialContext ctx) {
    if (geomStr.length() == 0) {
      throw new IllegalArgumentException("0-length geometry string");
    }
    char c = geomStr.charAt(0);
    if (c == '[' || c == '{') {
      return parseRectangeSolrException(geomStr, ctx);
    }
    //TODO parse a raw point?
    try {
      return ctx.getFormats().read(geomStr);
      // return ctx.readShapeFromWkt(geomStr);
    } catch (InvalidShapeException e) {
      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
          "Could not parse string into a shape': " + e, e);
    }

  }{code}
Ran all non bad apple Solr tests, which all passed successfully.
One minor gripe is that Spatial4J does not support parsing GeoJSON polygons, and throws an exception, asking to use JTS instead.
I'll try and set up a new test suite for this.
This makes me wonder though, how does Solr currently deal with error caused since Spatial4J is not as feature rich as JTS?

> Facet Heat Map should support GeoJSON
> -------------------------------------
>
>                 Key: SOLR-13263
>                 URL: https://issues.apache.org/jira/browse/SOLR-13263
>             Project: Solr
>          Issue Type: Bug
>      Security Level: Public(Default Security Level. Issues are Public) 
>    Affects Versions: 8.0, 8.x, master (9.0)
>            Reporter: Bar Rotstein
>            Priority: Major
>         Attachments: SOLR-13263-nocommit.patch
>
>
> Currently Facet Heatmap(Geographical facets) do not support any other subjects other than WKT or '[ ]'. This seems to be caused since FacetHeatmap.Parser#parse uses SpatialUtils#parseGeomSolrException, which in turn uses a deprecated JTS method (SpatialContext#readShapeFromWkt) to parse the string input.
> The newer method of parsing a String to a Shape object should be used, makes the code a lot cleaner and should support more formats (including GeoJSON).



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

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