Git Product home page Git Product logo

mongodb-geoserver's Introduction

mongodb-geoserver

A MongoDB plugin for Geoserver.

Download Geoserver 2.19.0 (Platform Independent Binary)

To setup a dev environment:

  1. Download deployment zip from here
  2. Unzip the deployment
  3. Move the groovy jar, the mongo java driver jar and the mongodb-geoserver jar into geoserver/WEB-INF/lib
  4. Restart geoserver.

Add a store and layers for development

  1. Create a mapping file that includes a mapping for each mongo collection that will be published.
  2. In geoserver, click "Workspaces", then click "Add new workspace"
  3. Set the name to "DB" and the Namespace URI to "http://spida/db" and check Default Workspace
  4. In geoserver, click "Stores", then click "Add new Store", then click "Mongo DB"
  5. Select the DB workspace, name it SPIDADB, set MongoDB connection parameters, and the path to the mapping file.
  6. If automatically brought to the layers page to publish layers, skip the next step
  7. In geoserver, click "Layers", then click "Add new resource", then select "DB:SPIDADB"
  8. 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

Point projectmanager at geoserver

  1. Uncomment url so that asset service bean gets created.
  2. Start projectmanager
  3. Edit a permission group and add the spida db asset service.

Mapping file

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.

mongodb-geoserver's People

Contributors

charlieaspida avatar jasongarrett avatar jeremywen avatar nestharken avatar spidabrianb avatar spidadeveloper avatar spidamikeford avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mongodb-geoserver's Issues

Access to nested json fields

Hi, I've created a new WMS service using a mongodb data store. Below you can see the layer preview and an extract of the mongodb json schema.

I used the plugin in order to create a new layer in geoserver, but it seems that it cannot parse all the json fields.
In particular the field "external" which is a nested array is not present in the list of my layers.

Regards
Maurizio

image

...
  "description": "FLUMENDOSA D",
  "geometry": {
    "type": "Point",
    "coordinates": [
      9.53485566216458,
      39.9593062203704
    ]
  },
  "external": [
    {
      "k": "building_type_id",
      "t": "int",
      "vs": null,
      "vb": null,
      "vi": 9,
      "vf": null,
      "vt": null
    },
....    
  ]
}```

Error when a view is present in the mongo db

Hi, during the creation of a new mongo data store , I refer to a "gis" database but, if the db includes any view, an error is generated :

Command failed with error 166 (CommandNotSupportedOnView): 'Namespace gis.tibe-geojson is a view, not a collection' on server 12.3.4:27017. The full response is {"operationTime": {"$timestamp": {"t": 123481, "i": 165}}, "ok": 0.0, "errmsg": "Namespace gis.tibe-geojson is a view, not a collection", "code": 166, "codeName": "CommandNotSupportedOnView", "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1630415490, "i": 165}}, "signature": {"hash": {"$binary": {"base64": "sGR84PiFUnfH7YAoLhEpi6z/IC0=", "subType": "00"}}, "keyId": 123481}}}

How to avoid this error and then to create a data store that access a view, with the plugin?

thanks
M+

GeometryAttributeImpl cannot be cast to com.vividsolutions.jts.geom.Geometry

Hello,

I tried a GET for GetFeature in a layer published from MongoDB store and got the following error:

<ows:ExceptionReport version="2.0.0" xsi:schemaLocation="http://www.opengis.net/ows/1.1 http://mylocalgeoserver:8080/geoserver/schemas/ows/1.1.0/owsAll.xsd">
<ows:Exception exceptionCode="NoApplicableCode">
<ows:ExceptionText>java.lang.ClassCastException: org.geotools.feature.GeometryAttributeImpl cannot be cast to com.vividsolutions.jts.geom.Geometry org.geotools.feature.GeometryAttributeImpl cannot be cast to com.vividsolutions.jts.geom.Geometry</ows:ExceptionText>
</ows:Exception>
</ows:ExceptionReport>

It even happens if I try Layer Preview in GeoServer, asking for GeoJSON.

Here's my mapping:

[{
		"typeName": "occurrence",
		"collection": "occurrences",
		"idAsAttribute": true,
		"geometry": {
			"name": "location",
			"crs": "EPSG:4326",
			"path": "location"
		},
		"displayGeometry": true,
		"attributes": [{
				"name": "type",
				"path": "type"
			}, {
				"name": "description",
				"path": "description"
			}, {
				"name": "status",
				"path": "status"
			}
		]
	}
]

and an item sample:

{
	type: "Some type",
	location: {
		type: "Point",
		coordinates: [-51.216039, -30.047548]
	},
	description: "Some description"
}

If I ask Layer Preview with format GML 2.0, it seems to work:

<wfs:FeatureCollection xmlns="http://www.opengis.net/wfs" xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:mongo="mongo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://mylocalgeoserver:8080/geoserver/schemas/wfs/1.0.0/WFS-basic.xsd mongo http://mylocalgeoserver:8080/geoserver/mongo/wfs?service=WFS&version=1.0.0&request=DescribeFeatureType&typeName=mongo%3Aoccurrence">
<gml:boundedBy>
<gml:null>unknown</gml:null>
</gml:boundedBy>
<gml:featureMember>
<mongo:occurrence fid="fid--641acbe7_1593bdeffad_-7b2c">
<mongo:location>
GeometryAttributeImpl:location<location crs=GEOGCS["WGS 84", DATUM["World Geodetic System 1984", SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH], AUTHORITY["EPSG","4326"]]>=POINT (-51.216039 -30.047548)
</mongo:location>
<mongo:type>Some type</mongo:type>
<mongo:description>
Some description
</mongo:description>
</mongo:occurrence>
</gml:featureMember>
</wfs:FeatureCollection>

My GeoServer is version 2.7.2.

Any ideas?

Thanks in advance!

URI has an authority component

If try to add datastore with URI mongodb://192.168.100.3/test, the following error occurs:

Error creating data store, check the parameters. Error message: URI has an authority component

GeoServer Version: 2.20.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.