ngageoint / elasticgeo

ElasticGeo provides a GeoTools data store that allows geospatial features from an Elasticsearch index to be published via OGC services using GeoServer.
GNU General Public License v3.0
169 stars 85 forks source link

NPE on basic usage #105

Closed timrobertson100 closed 5 years ago

timrobertson100 commented 5 years ago

Hi folks

I have a ES server with a coordinate field as follows:

...
"coordinates": {
  "type": "geo_point"
},
...

When I configure a layer it seems to map correctly to the point type and is picked up as the default geometry. However, on any request I get the following NPE:

Caused by: java.io.IOException: Error executing query search
    at mil.nga.giat.data.elasticsearch.ElasticFeatureSource.getReaderInternal(ElasticFeatureSource.java:132)
    at org.geotools.data.store.ContentFeatureSource.getReader(ContentFeatureSource.java:610)
    at org.geotools.data.store.ContentFeatureCollection.features(ContentFeatureCollection.java:164)
    ... 133 more
Caused by: java.lang.NullPointerException
    at mil.nga.giat.data.elasticsearch.FilterToElasticHelper.visitGeoPointBinarySpatialOperator(FilterToElasticHelper.java:262)
    at mil.nga.giat.data.elasticsearch.FilterToElasticHelper.visitBinarySpatialOperator(FilterToElasticHelper.java:202)
    at mil.nga.giat.data.elasticsearch.FilterToElasticHelper.visitComparisonSpatialOperator(FilterToElasticHelper.java:172)
    at mil.nga.giat.data.elasticsearch.FilterToElasticHelper.visitBinarySpatialOperator(FilterToElasticHelper.java:113)
    at mil.nga.giat.data.elasticsearch.FilterToElastic.visitBinarySpatialOperator(FilterToElastic.java:1163)
    at mil.nga.giat.data.elasticsearch.FilterToElastic.visitBinarySpatialOperator(FilterToElastic.java:734)
    at mil.nga.giat.data.elasticsearch.FilterToElastic.visit(FilterToElastic.java:682)
    at org.geotools.renderer.lite.FastBBOX.accept(FastBBOX.java:132)
    at mil.nga.giat.data.elasticsearch.FilterToElastic.encode(FilterToElastic.java:208)
    at mil.nga.giat.data.elasticsearch.FilterToElastic.encode(FilterToElastic.java:221)
    at mil.nga.giat.data.elasticsearch.ElasticFeatureSource.prepareSearchRequest(ElasticFeatureSource.java:183)
    at mil.nga.giat.data.elasticsearch.ElasticFeatureSource.getReaderInternal(ElasticFeatureSource.java:117)
    ... 135 more

This is Geoserver 2.14.3

timrobertson100 commented 5 years ago

I've just updated to 2.14.2RC2 and now see:

Caused by: java.lang.Exception: Error transforming bbox
    at org.geotools.renderer.lite.StreamingRenderer.getStyleQuery(StreamingRenderer.java:1099)
    at org.geotools.renderer.lite.StreamingRenderer.getFeatures(StreamingRenderer.java:2026)
    at org.geotools.renderer.lite.StreamingRenderer.processStylers(StreamingRenderer.java:1990)
    at org.geotools.renderer.lite.StreamingRenderer.paint(StreamingRenderer.java:861)
    at org.geoserver.wms.map.RenderedImageMapOutputFormat.produceMap(RenderedImageMapOutputFormat.java:565)
    ... 127 more
Caused by: java.lang.IllegalArgumentException: Argument "targetCRS" should not be null.
    at org.geotools.referencing.operation.AbstractCoordinateOperationFactory.ensureNonNull(AbstractCoordinateOperationFactory.java:789)
    at org.geotools.referencing.operation.BufferedCoordinateOperationFactory.createOperation(BufferedCoordinateOperationFactory.java:229)
    at org.geotools.referencing.CRS.findMathTransform(CRS.java:1260)
    at org.geotools.referencing.CRS.findMathTransform(CRS.java:1228)
    at org.geotools.renderer.crs.GeographicHandlerFactory.isWrappingException(GeographicHandlerFactory.java:95)
    at org.geotools.renderer.crs.GeographicHandlerFactory.getHandler(GeographicHandlerFactory.java:82)
    at org.geotools.renderer.crs.ProjectionHandlerFinder.getHandler(ProjectionHandlerFinder.java:103)
    at org.geotools.renderer.lite.StreamingRenderer.getStyleQuery(StreamingRenderer.java:1070)
    ... 131 more
timrobertson100 commented 5 years ago

It seems required that the name of the field be mapped to "geometry"

sjudeng commented 5 years ago

Can you clarify what the issue was? I don't think geometry fields need to be named "geometry". But there may be a problem with having it named "coordinates" as that's also a relevant field in GeoJSON. If so I think it's a bug in the plugin and we can reopen this to track.

timrobertson100 commented 5 years ago

All I did was change the mapping from coordinates to geometry and it worked.