A MongoDB plugin for Geoserver.
Download Geoserver 2.19.0 (Platform Independent Binary)
- Download deployment zip from here
- Unzip the deployment
- Move the groovy jar, the mongo java driver jar and the mongodb-geoserver jar into geoserver/WEB-INF/lib
- Restart geoserver.
- Create a mapping file that includes a mapping for each mongo collection that will be published.
- In geoserver, click "Workspaces", then click "Add new workspace"
- Set the name to "DB" and the Namespace URI to "http://spida/db" and check Default Workspace
- In geoserver, click "Stores", then click "Add new Store", then click "Mongo DB"
- Select the DB workspace, name it SPIDADB, set MongoDB connection parameters, and the path to the mapping file.
- If automatically brought to the layers page to publish layers, skip the next step
- In geoserver, click "Layers", then click "Add new resource", then select "DB:SPIDADB"
- Publish each layer. Set Declared SRS to "EPSG:4326" and bounding box values all to 1
You can see all types and properties at this geoserver url. And here is a WFS Reference.
NOTE: When min builds this is all done automatically by copying files from min/scripts/docker/tomcat/geoserver
- Uncomment url so that asset service bean gets created.
- Start projectmanager
- Edit a permission group and add the spida db asset service.
The mapping file will map a feature collection to a mongo collection. If there is multiple objects nested in a collection each nested object can be published as a feature. Here is an example mapping.json file. There is also a location.json and design.json that the mapping file and tests use.
Top level fields in the mapping.json file:
- typeName: (Required) The typeName for the feature that geoserver will use
- collection: (Required) The MongoDB collection that the feature is located in.
- idAsAttribute: (Required) Whether or not to include the id of the object as an attribute for the features.
- geometry: (Not Required) The geometry for the collection, must include the name, crs and path.
- displayGeometry: (Not Required) Whether or not to add the geometry to the feature.
- attributes: (Not Required) Must add the name for the attribute and the path to the value, can also add a class(Double, Long or Boolean)
- subCollections: (Not Required)
- subCollectionPath: (Required) path to the subcollection.
- includeInDefaultQuery: (Required) If true the query for objects will include a criteria that the length of the array is greater than 0.
- attributes: (Not Required) Similar to attributes for top level objects but more options instead of just the path value.
- path: The path from the top level object, the main collection object.
- subCollectionPath: The path from the subCollection for the value.
- concatenate: Will concatenate these values together with an underscore example
- useKey: Use the key of the object for the value of the attribute [example](https://github.com/spidasoftware/mongodb-geoserver/blob/mongodb-geoserver-plugin/src/test/resources/mapping.json#L128(.
- useValue: Use the value of the object for the value of the attribute example.