1

I'm trying to create layers in Geoserver using MongoDB instance. However I want to create the layer in geoserver using RESTful interface or using geotools function. Similar to how layers is created using PostGIS instance.

I have tried creating the layers manually for MongoDB instance, works fine. (Link: https://docs.geoserver.org/latest/en/user/extensions/mongodb/index.html). But how do I create layers using RESTful interface

Tried to create Datastore using the below POST instance.

String data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                      "<as:AppSchemaDataAccess xmlns:as=\"http://www.geotools.org/app-schema\"\n" +
                       "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
                       "xsi:schemaLocation=\"http://www.geotools.org/app-schema AppSchemaDataAccess.xsd\">"

       + "<sourceDataStores>\n" +
"  <DataStore>\n" +
"    <id>data_source</id>\n" +
"    <parameters>\n" +
"      <Parameter>\n" +
"        <name>mongostore</name>\n" +
"        <value>mongodb://127.0.0.1:27017/geodatabase</value>\n" +
"      </Parameter>\n" +
"      <Parameter>\n" +
"        <name>namespace</name>\n" +
"        <value>http://www.stations.org/1.0</value>\n" +
"      </Parameter>\n" +
"      <Parameter>\n" +
"        <name>schema_store</name>\n" +
"        <value>file:///opt/schemas/database</value>\n" +
"      </Parameter>\n" +
"      <Parameter>\n" +
"        <name>data_store_type</name>\n" +
"        <value>complex</value>\n" +
"      </Parameter>\n" +
"    </parameters>\n" +
"  </DataStore>\n" +
"</sourceDataStores>"+
"</as:AppSchemaDataAccess>";

The above XML did not succeed, it gave me the following error: ERROR [geoserver.rest] - as:AppSchemaDataAccess com.thoughtworks.xstream.mapper.CannotResolveClassException: as:AppSchemaDataAccess. I am not sure whether this was the right way and also would like to know if I can create using geotools if it supports for MongoDB.

GeoFresher
  • 301
  • 2
  • 12
  • 1
    did you try creating one layer and requesting the REST representation of that as a template? – Ian Turton Apr 09 '19 at 09:47
  • No, I didnt try this way. Actually was thinking if my schema doesnt change, this could be the possible solution. However I tried to create a new layer for the mongoDB instance from scratch using REST representation following similar footsteps of PostGIS (I meant using the REST call ) – GeoFresher Apr 09 '19 at 10:02
  • I'm not sure if App-Schema datastores are accessible via REST – Ian Turton Apr 09 '19 at 10:06
  • The main idea was to store geojson objects to DB dynamically. Hence i tried using MongoDB. However I have a solution using `ogr2ogr`(saving geojson to postgis), not sure whether that's a good approach. – GeoFresher Apr 09 '19 at 10:21
  • 1
    GeoJSON is a very poor storage format, better to convert it to something binary and indexed on the server. – Ian Turton Apr 09 '19 at 10:30

0 Answers0