How to create layers from mongo collection with more than one geometry field in MongoDB plugin

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:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>{
"_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"
}
</code>
<code>{ "_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" } </code>
{
  "_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:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>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)
.
.
.
</code>
<code>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) . . . </code>
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:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>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)
</code>
<code>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) </code>
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

New contributor

cbrautigam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật