I’m using the MongoDB GeoTools plugin on GeoServer 2.25. I can successfully expose one if my collections as a layer in GeoServer with a single geometry in it. However, I want to expose a collection with 4 separate geometry fields (each with a 2dsphere index) using each geometry field in a separate layer. It appears that when I go to create the first layer only the first of the 4 geometry fields is recognized as a geometry field. I’ve tried manually adding the rest, and GeoServer throws an error saying those additional attributes are unavailable in the data source. I can not figure a way to get MongoDB plugin to see more than the first geometry in the collection.
Next, I tried making 4 mongo views that exposes just 1 of the 4 geometries. When trying to create a layer in that case I get an error saying something to the effect that only collections can be used for layers and not views.
I’m struggling to find a workaround. Any ideas?
Sample data:
{
"_id": {
"$oid": "668307dc0cea1f71f75781f0"
},
"precisionTimeStamp": {
"$date": "2015-10-07T06:50:32.800Z"
},
"contentId": "668305fc55e8630aed5786e8",
"objectCountryCodes": "AU",
"sensorLocation": {
"type": "Point",
"coordinates": [
138.58231316254583,
-34.78620206694408
]
},
"targetLocation": {
"type": "Point",
"coordinates": [
138.54022846489224,
-34.80597711392025
]
},
"frameShape": {
"type": "Polygon",
"coordinates": [
[
[
138.53940091959174,
-34.80800670795515
],
[
138.53780081427556,
-34.805197555015425
],
[
138.54105299270762,
-34.80407505054217
],
[
138.54253491318903,
-34.80667683519734
],
[
138.53940091959174,
-34.80800670795515
]
]
]
},
"frameCenterLocation": {
"type": "Point",
"coordinates": [
138.54022846489224,
-34.80597711392025
]
},
"_class": "extr.common.model.klv.KlvMetadata"
}
Error message attribute unavailable:
org.geoserver.catalog.ValidationException: The CQL source expression for attribute targetLocation refers to attributes unavailable in the data source: [targetLocation]
at org.geoserver.catalog.impl.FeatureTypeValidator.validate(FeatureTypeValidator.java:130)
at org.geoserver.catalog.impl.FeatureTypeValidator.validate(FeatureTypeValidator.java:69)
at org.geoserver.catalog.impl.CatalogImpl.validate(CatalogImpl.java:515)
at org.geoserver.security.SecureCatalogImpl.validate(SecureCatalogImpl.java:1320)
.
.
.
View not supported error:
02 Jul 13:22:21 ERROR [geoserver.web] - Error retrieving layers for the specified store
java.lang.RuntimeException: Could not list layers for this store, an error occurred retrieving them: Command failed with error 166 (CommandNotSupportedOnView): 'Namespace extractions-db.klvMetadata_target_location is a view, not a collection' on server extractions-db:27017. The full response is {"ok": 0.0, "errmsg": "Namespace extractions-db.klvMetadata_target_location is a view, not a collection", "code": 166, "codeName": "CommandNotSupportedOnView"}
at org.geoserver.web.data.layer.NewLayerPageProvider.getItemsInternal(NewLayerPageProvider.java:181)
at org.geoserver.web.data.layer.NewLayerPageProvider.getItems(NewLayerPageProvider.java:60)
at org.geoserver.web.data.layer.NewLayerPage$8.onUpdate(NewLayerPage.java:294)
at org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior.onEvent(AjaxFormComponentUpdatingBehavior.java:156)
.
.
.
Caused by: com.mongodb.MongoCommandException: Command failed with error 166 (CommandNotSupportedOnView): 'Namespace extractions-db.klvMetadata_target_location is a view, not a collection' on server extractions-db:27017. The full response is {"ok": 0.0, "errmsg": "Namespace extractions-db.klvMetadata_target_location is a view, not a collection", "code": 166, "codeName": "CommandNotSupportedOnView"}
at com.mongodb.internal.connection.ProtocolHelper.getCommandFailureException(ProtocolHelper.java:175)
at com.mongodb.internal.connection.InternalStreamConnection.receiveCommandMessageResponse(InternalStreamConnection.java:302)
at com.mongodb.internal.connection.InternalStreamConnection.sendAndReceive(InternalStreamConnection.java:258)
at com.mongodb.internal.connection.UsageTrackingInternalConnection.sendAndReceive(UsageTrackingInternalConnection.java:99)
I expect the mongo plugin to support views, and I expect the mongo plugin to recognize more than the first geometry in a collection
cbrautigam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.