[GeoNode-devel] Programmatically create layers and maps from own Django App

EFTAS Carsten Stemmler carsten.stemmler at eftas.com
Wed Sep 25 03:22:53 PDT 2019


Hello Toni,

you were right with your assumptions in your last mail. When the missing parameters were added via the admin interface the map is shown like expected, however my goal is to add these by using the script too.

I experienced also, that the basemaps are not present in the map created by the create_from_layer_list method. Setting the zoom and center to a valid value worked, however it did not solve the problem with the owl url and sourceparams and layerparams.

Unfortunately I was not able to identify the code, were these parameters are set when creating the map via the MapStore2 GUI.

Is there maybe another function, which needs to be called after initially creating a map for setting these parameters correctly?

Any hints from you, or anyone else on the list, are appreciated,
Carsten
________________________________
Von: Toni Schönbuchner [toni.schoenbuchner at csgis.de]
Gesendet: Mittwoch, 11. September 2019 17:59
An: EFTAS Carsten Stemmler
Cc: geonode-devel at lists.osgeo.org
Betreff: Re: Programmatically create layers and maps from own Django App

Hi Steffen,

sorry. Did not test it before sending. But darkly remember I did something like this with 2.4.
Anyways from a quick look the problem is that your map has wrong
zoom
center-x
center-y

further your added layer is missing:
OWS URL
Layer params
Source params

You can test it by manually creating a map with same layer and afterwards by django shell.
As soon as you fix those values in django admin it works.

Unfortuanately I'm facing a strict deadline and cannot say when there will be time for further tests.
But would suggest that you start by having a look at the maps model.

Cheers,

Toni

Am 11.09.2019 um 17:06 schrieb EFTAS Carsten Stemmler <carsten.stemmler at eftas.com<mailto:carsten.stemmler at eftas.com>>:

Hello Toni,

thank you for your help, this was already quite useful.
Maybe you can also help with a follow-up question:

I created a new map using the way you pointed out and the map is visible in the Geonode maps overview.
But when I try to view the map, the layers are unfortunately not visible to the user (who created the map). All layers are also owned by the same user.
To check for general errors on the system, I created a map manually with the same layers using the Mapstore GUI and this map is displayed without a problem.
I was unfortunately also not able to spot any error messages on the server or client, which hint to a problem with the map.

Any hints are appreciated,
Carsten

--
Carsten Stemmler
- Research & Development

E F T A S    Fernerkundung
Technologietransfer GmbH
Oststraße 2-18
48145 Münster
Fon: +49 251 13307-0      E-Mail: carsten.stemmler at eftas.com<mailto:carsten.stemmler at eftas.com>
Fax: +49 251 13307-33     Web:   http://www.eftas.com<http://www.eftas.com/>
Geschäftsführer:
Dipl.-Ing. Georg Altrogge

Sitz der Gesellschaft: Münster
Amtsgericht Münster, HRB 2999
USt.-IdNr. DE 126038986
________________________________
Von: Toni Schönbuchner [toni.schoenbuchner at csgis.de<mailto:toni.schoenbuchner at csgis.de>]
Gesendet: Montag, 9. September 2019 20:14
An: EFTAS Carsten Stemmler
Cc: geonode-devel-owner at lists.osgeo.org<mailto:geonode-devel-owner at lists.osgeo.org>
Betreff: Re: Programmatically create layers and maps from own Django App

Hi Carsten,

in case you have generated files on your disk maybe it could be enough to just use importlayers?
Have a look how it's done here: https://github.com/GeoNode/geonode/blob/master/pavement.py#L1002

For map creation I would go with something like:

$ python manage.py shell

from geonode.layers.models import Layer
from geonode.maps.models import Map
from geonode.people.models import Profile

user = Profile.objects.get(id=1000)
m = Map()
layer_name = Layer.objects.all().first().alternate
m.create_from_layer_list(user, [layer_name], "title", "abstract")


In this case 1000 is the ID of my admin user. You would pass your newly imported layers to
m.create_from_layer_list()

cheers,

Toni


Am 09.09.2019 um 12:13 schrieb geonode-devel-owner at lists.osgeo.org<mailto:geonode-devel-owner at lists.osgeo.org>:

As list administrator, your authorization is requested for the
following mailing list posting:

   List:    geonode-devel at lists.osgeo.org<mailto:geonode-devel at lists.osgeo.org>
   From:    carsten.stemmler at eftas.com<mailto:carsten.stemmler at eftas.com>
   Subject: Programmatically create layers and maps from own Django App
   Reason:  Post to moderated list

At your convenience, visit:

   https://lists.osgeo.org/mailman/admindb/geonode-devel

to approve or deny the request.

Von: EFTAS Carsten Stemmler <carsten.stemmler at eftas.com<mailto:carsten.stemmler at eftas.com>>
Betreff: Programmatically create layers and maps from own Django App
Datum: 9. September 2019 um 11:39:39 MESZ
An: "geonode-devel at lists.osgeo.org<mailto:geonode-devel at lists.osgeo.org>" <geonode-devel at lists.osgeo.org<mailto:geonode-devel at lists.osgeo.org>>


Dear all,

I created a new Django App by using geonode-project (Geonode version 2.10) to do some geospatial processing.
As a result of this process I want to create a new layer (and furthermore a map) within Geonode without user interaction.

I already had a look at the documentation, however I'm not sure about the right way to accomplish this task. Can I use internal functions e.g. from geonode.layers.models or is it necessary to use the Geoserver Rest API to import the data there directly (or another way I am not aware of at the moment)?

Any hints and also specific links to the documentation are appreciated.
Carsten

--
Carsten Stemmler
- Research & Development

E F T A S    Fernerkundung
Technologietransfer GmbH
Oststraße 2-18
48145 Münster
Fon: +49 251 13307-0      E-Mail: carsten.stemmler at eftas.com<mailto:carsten.stemmler at eftas.com>
Fax: +49 251 13307-33     Web:   http://www.eftas.com<http://www.eftas.com/>
Geschäftsführer:
Dipl.-Ing. Georg Altrogge

Sitz der Gesellschaft: Münster
Amtsgericht Münster, HRB 2999
USt.-IdNr. DE 126038986



Von: geonode-devel-request at lists.osgeo.org<mailto:geonode-devel-request at lists.osgeo.org>
Betreff: confirm 61cb4ec0107fc608b6f30c51a47cea3e31831aea
Datum: 9. September 2019 um 12:13:03 MESZ


If you reply to this message, keeping the Subject: header intact,
Mailman will discard the held message.  Do this if the message is
spam.  If you reply to this message and include an Approved: header
with the list password in it, the message will be approved for posting
to the list.  The Approved: header can also appear in the first line
of the body of the reply.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geonode-devel/attachments/20190925/4706dca3/attachment-0001.html>


More information about the geonode-devel mailing list