GeoNode / geonode

GeoNode is an open source platform that facilitates the creation, sharing, and collaborative use of geospatial data.
https://geonode.org/
Other
1.42k stars 1.11k forks source link

Custom React Frontend + geonode API #11919

Open flieks opened 5 months ago

flieks commented 5 months ago

I know there is the mapstore example project to use mapstore frontend https://github.com/GeoNode/geonode-mapstore-client

but it is using there own plugin architecture with old react 16 and redux so it is not what we want.

I would want to develop our own frontend and connect to geonode api but i can not find in the docs how to only run the backend API. We also want to connect our own azure SSO AD.

if i run geonode from the devcontainer all 8 docker containers startup but the django4geonode fails because it cant connect to the postgres db: connection to server at "db" (172.22.0.6), port 5432 failed: FATAL: password authentication failed for user "geonode_data"

db4geonode ran fine, only has this in the end PostgreSQL Database directory appears to contain a database; Skipping initialization

i cannot access postgress from pgadmin app or browser (localhost:5432). According to .devcontainer/.env vars: DATABASE_HOST=db DATABASE_PORT=5432 DATABASE_URL=postgis://geonode:geonode@db:5432/geonode

Greetings

flieks commented 5 months ago

I can run the project now and view it in browser localhost. Just not yet connect in pgadmin. i puted host db, the creds from the root env file

POSTGRES_USER=postgres
POSTGRES_PASSWORD=xxxxxxx

DATABASE_HOST=db
DATABASE_PORT=5432

But i get connection is bad: No such host is known.

mattiagiupponi commented 5 months ago
db4geonode ran fine, only has this in the end
PostgreSQL Database directory appears to contain a database; Skipping initialization

This (usually) means that the docker db volumes where already there. If you can, i would suggest u to delete the volumes and re-run the docker container.

db is the service name we use in the docker. I guess if you want to see it from pg-admin u should expose the port in the docker-file and then use localhost to connect pgadmin to the db

flieks commented 5 months ago

@mattiagiupponi

Thanks, i changed dockerFile to this EXPOSE 8000 5432

and used localhost as host and from .env

POSTGRES_USER=postgres
POSTGRES_PASSWORD=xxxxxxx

But still i get the error in pgadmin connection failed: :1), port 5432 failed: FATAL: password authentication failed for user "postgres"

flieks commented 5 months ago

i also uncommented

ports:
     - "5432:5432"

in docker-compose.yml and docker-compose-dev.yml but did not help

ridoo commented 5 months ago

I would want to develop our own frontend and connect to geonode api but i can not find in the docs how to only run the backend API. We also want to connect our own azure SSO AD.

Do you have specific requirements your web client shall be able to serve. The one you already mention is Azure SSO which could be already possible. Not sure if you already had a look here:

However, I am more interested in how far you plan to get when implementing a custom solution based on the GeoNode API. I am asking because from different kinds of project contexts we often have (naturally) different kinds of requirements, but mostly the need for light-weighted clients.

However, running a completely headless GeoNode would be as simple as removing the GeoNode-mapstore-client from INSTALLED_APPS, I guess. But I am sure, that you will run into some limitations regarding API (at least when using the current version). See

What is your approach and will it be OpenSource?

flieks commented 5 months ago

@ridoo that is interesting. Thanks for the links.

Indeed i didnt develop yet in mapstore/geonode but checked a bit both codebases. And mapstore is heavy java with react and geonode is all django so also backend and frontend mixed. I see the django and api are in same container so the API isnt really seperated yet.

We are still investigating all options how we want to build it. It is for private company so will not be open source.

I also tested the map search on the right in geonode after i added 2 datasets to the map. I clicked on something in a layer to see its metadata on the right which was some description. I then searched for 1 word that is in the description but it could not find it. It only showed addresses that had that keyword. A major functionality that we need it cross-layer and cross-attribute search. Is that possible with geonode ?

Thanks

ridoo commented 5 months ago

I see the django and api are in same container so the API isnt really seperated yet.

GeoSolutions is going away from using Django templates and using react client (MapStore2) and REST API instead. In fact, this was a huge step in v4 (but I am unsure if v4 is feature par with v3 again), but there are some legacy parts still using templates, and the metadata editor is one (the last?). However, migrating the editor is not straight forward and we evaluating some conceptual ideas here (using OpenAPI description vs. geonode-mapstore-client API).

A major functionality that we need it cross-layer and cross-attribute search. Is that possible with geonode ?

What do you mean by that? If you want to search in GeoNode by content this is not possible, as it serves metadata about geo data. However, we at 52n are about to evaluate ways to make possible cross data search in research data infrastructures without adding a bottleneck into the whole system. However, we are in the starting phase here, so if you are interested you may want to share your thoughts and requirements.

flieks commented 5 months ago

The problem is mapstore has its own complex plugin architecture and layers build on (old) redux and on an old version of react with webpack. All that stuff dictates then the entire frontend setup. We would prefer using react 18, atom based state, apollo, VITE build system and more simplified folder structure because it wont use redux where these actions/components/containers are in different locations. We want to go much further then standard mapstore functionality and not all are map related features.

Does this mean geonode could be discontinued if they move more and more to mapstore ? Or maybe python API from geonode will still survive nstead of the JAVA one from mapstore.

About cross-layer, i mean search in all metadata of all shapefiles (attributes) wherever they are located (all layers or dataset in db). Possibly importing and indexing this in elasticsearch is the way to go here.

flieks commented 5 months ago

I am also wondering if geonode will fetch changes that were added to WMS layers after this WMS was added to geonode and its resources were imported via the harvester into postgis. And how does it get these changes/additions ?

giohappy commented 5 months ago

Does this mean geonode could be discontinued if they move more and more to mapstore ? Or maybe python API from geonode will still survive instead of the JAVA one from mapstore.

@flieks I know MapStore can be a bit confusing (for historical reasons). Let me clarify some points:

At the moment the GeoNode API covers everything that can be done from its frontends (MapStore + legacy templates). It's not as clean and auto-documented as everybody wishes, but I would say that with some effort you can drive GeoNode completely with a custom frontend app. @ridoo what do you think we miss here?

flieks commented 5 months ago

@giohappy thanks for the clarification.

This the latest geonode API? geonode swagger v2 because @ridoo was talking about v4. He probably meant the mapstore client v4 is feature par with latest mapstore2.

Is there a github repo or folder where only the api is inside or it could be as easy of removing the geonode django code and folders from this repo main branch ?

About mapstore client, you mean this repo here ? mapstore client There are files in geonode_mapstore_client/client/ with the react code. And lots of django template files in geonode_mapstore_client/templates/geonode-mapstore-client. We will need this django templates ?

Does the current geonode api allow searching in multiple layers and multiple feature metadata attribute fields at once ? I think some kind of indexing like with elasticsearch would be needed for that..

dgquail commented 2 months ago

Hello everyone. I have been reading this interesting thread and had some queries regarding mapstore client (mapstore2) and geonode. Looking a little at the geonode repository, we have noticed that, for example in version 4.2.0 of geonode, it has as in requirements.txt: django-geonode-mapstore-client==4.2.0.

Now looking at the code in the geonode-mapstore-client repository in the file geonode_mapstore_client/client/package.json it has Mapstore2 as a dependency on the following line: "mapstore": "file:MapStore2", which is a specific commit of the Mapstore2 project (https://github.com/geosolutions-it/MapStore2/commit/ce0069d3da0ee25b84c620deae060f03462bd892).

The question is: Could this dependency on mapstore-client be changed and go to the latest version of Mapstore2? Could a React upgrade be done both in mapstore-client and in Mapstore2? What could happen to geonde?

What we are looking for is to have a geonode with the latest versions of React and Mapstore2, or the most recent. I appreciate in advance if you can give me your observations or suggestions.

Thanks!

ridoo commented 2 months ago

Hey @dgquail, GeoSolutions is currently working on updating geonode-mapstore-client to use latest MapStore2. The dependency is declared as Git submodule. However, that MapStore2 version is using react version 16 .. not sure when they will upgrade to v18, though.

giohappy commented 2 months ago

I confirm what @ridoo said. GeoNode 4.3.0, which should be released in a few days, will be aligned with MapStore 2024.01.00, which has been released a few days ago.

The React version adopted by the client depends on the version in MapStore. I'm not aware of any plan for its upgrade, for the moment, although the team is certainly willing to do it sooner than later.