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

David Smiley commented on LUCENE-7951:
--------------------------------------

I propose the contents of the Geo3dSpatialContextFactory class look like this:
{code:java}

  public static final PlanetModel DEFAULT_PLANET_MODEL = PlanetModel.SPHERE;

  public PlanetModel planetModel = DEFAULT_PLANET_MODEL;

  public Geo3dSpatialContextFactory() {
    this.binaryCodecClass = Geo3dBinaryCodec.class;
    this.shapeFactoryClass = Geo3dShapeFactory.class;
    this.distCalc = new Geo3dDistanceCalculator(planetModel);
  }

  @Override
  protected void init(Map<String, String> args, ClassLoader classLoader) {
    super.init(args, classLoader);
    initPlanetModel(args);
  }

  protected void initPlanetModel(Map<String, String> args) {
    String planetModel = args.get("planetModel");
    if (planetModel != null) {
      if (planetModel.equalsIgnoreCase("sphere")) {
        this.planetModel = PlanetModel.SPHERE;
      } else if (planetModel.equalsIgnoreCase("wgs84")) {
        this.planetModel = PlanetModel.WGS84;
      } else {
        throw new RuntimeException("Unknown planet model: " + planetModel);
      }
    }
  }

  @Override
  protected void initCalculator() {
    String calcStr = this.args.get("distCalculator");
    if (calcStr == null || calcStr.equals("geo3d")) {
      return;// we already have Geo3d
    }
    super.initCalculator(); // some other distance calculator
  }
{code}

Notice that you don't have to even call init(args).  Some tests (in Spatial4j) 
and some here create the factory, manually set some fields directly, and then 
finally called newSpatialContext() while never calling init(args).  init(args) 
is optional, designed for when you have name-value pair based configuration, 
e.g. Solr field type.

> New wrapper classes for Geo3d
> -----------------------------
>
>                 Key: LUCENE-7951
>                 URL: https://issues.apache.org/jira/browse/LUCENE-7951
>             Project: Lucene - Core
>          Issue Type: Improvement
>          Components: modules/spatial-extras
>            Reporter: Ignacio Vera
>            Assignee: David Smiley
>            Priority: Minor
>         Attachments: LUCENE_7951_build.patch, LUCENE-7951.patch, 
> LUCENE-7951.patch
>
>
> Hi,
> After the latest developments in the Geo3d library, in particular:
> [https://issues.apache.org/jira/browse/LUCENE-7906] : Spatial relationships 
> between GeoShapes
> [https://issues.apache.org/jira/browse/LUCENE-7936]: Serialization of 
> GeoShapes.
> I propose a new set of wrapper classes which can be for example linked to 
> Solr as they implement their own SpatialContextFactory. It provides the 
> capability of indexing shapes with 
>  spherical geometry.
> Thanks!



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

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

Reply via email to