- Get link
- X
- Other Apps
🔧 Your Use Case
You are building a multi-organization geospatial API. Each organization has:
-
Its own PostgreSQL/PostGIS database
-
A REST API to manage login and serve GeoJSON
-
Now you want to introduce GeoServer to serve the data via WFS/WMS
-
You want to store, serve, and view layer metadata properly, possibly in JSON
✅ API Flow (Existing)
You described your API structure like this:
API Endpoints:
-
POST /login
→ Takes{ user, pw }→ returns Bearer token -
GET /
→ Lists organization names (databases) -
GET /:orgName
→ Lists all layers for that organization -
GET /:orgName/:layerName
→ Returns raw GeoJSON for that layer
You now want to connect this structure to GeoServer and serve layers as WFS with rich metadata.
⚙️ Integrating with GeoServer
1. Connect your PostgreSQL databases to GeoServer
-
Use the GeoServer UI or REST API to create datastores for each organization's database
-
Each layer (table/view) is a FeatureType
-
Organize layers into Workspaces (e.g.,
org1_ws,org2_ws)
2. Expose Layers via WFS
Example WFS URL:
bashhttp://localhost:8080/geoserver/ows?service=WFS&version=1.1.0&request=GetFeature&typeName=org1_ws:buildings&outputFormat=application/json
Use this in your frontend or serve via your API as a proxy if needed.
📝 Adding Metadata to GeoServer Layers
You wanted to add rich metadata inside GeoServer, not in the request URLs.
✅ Manual Method (GeoServer UI):
Go to:
Layers → [Layer Name] → Data tab / Publishing tab
Fill in:
-
Title – Human-readable name
-
Abstract – Short description
-
Keywords – Tags for search
-
Metadata Links – Optional (link to JSON/XML metadata file)
-
Attribution – Author, source, license
✅ REST API Method:
httpPUT http://localhost:8080/geoserver/rest/workspaces/org1_ws/datastores/org1_store/featuretypes/buildings Content-Type: application/json Authorization: Basic (admin:geoserver) { "featureType": { "title": "City Buildings", "abstract": "Detailed building polygons with attributes...", "keywords": { "string": ["buildings", "city", "org1"] }, "metadataLinks": { "metadataLink": [{ "type": "ISO19115:2003", "metadataType": "text/html", "content": "https://example.com/metadata/buildings.html" }] } } }
❓ Your Metadata Formatting Issue
You tried putting rich metadata in abstract like this:
json"abstract": "File Name: land_use_zones.shp\r\nFile Type: ESRI Shapefile\r\nGeometry Type: Polygon..."
But it looked messy because:
-
GeoServer stores
abstractas plain text -
No support for
\n,\r\n, or markdown/HTML
✅ Solutions to Display Metadata Better (Without External Links)
✔️ 1. Clean Plain-Text Formatting (Recommended)
Use bullet-style formatting:
plaintextLand Use Zones: - File: land_use_zones.shp - Type: ESRI Shapefile - Geometry: Polygon - CRS: EPSG:4326 Attributes: * ZONE_ID: Integer * ZONE_TYPE: String ...
This appears clearly in GeoServer UI and GetCapabilities.
✔️ 2. Keep abstract short + use metadataLinks for full details
json"abstract": "Zoning layer. See full metadata linked below.",
"metadataLinks": [{
"type": "application/json",
"metadataType": "application/json",
"content": "https://yourdomain.com/metadata/zoning_layer.json"
}]
✔️ 3. If You Control the Client
-
Fetch metadata from your DB or JSON files
-
Display it in a nicely formatted UI panel
-
Combine GeoServer WFS data + your metadata API
❌ Limitations: Why You Can't Use JSON in abstract
| Option | Supports JSON? | Looks Good? | Use Case |
|---|---|---|---|
abstract | ✅ (as plain string) | ❌ (ugly formatting) | Avoid |
metadataLinks | ✅ (link to JSON) | ✅ (if client parses it) | ✔ Recommended |
| External App | ✅ | ✅ | ✔ Best for full control |
✅ Ways to Get Metadata from GeoServer
| Method | URL Example | Includes | Requires Admin |
|---|---|---|---|
GetCapabilities (WFS/WMS) | /geoserver/ows?... | Public metadata | ❌ |
| REST API | /geoserver/rest/workspaces/ws/datastores/store/featuretypes/layer.json | Full config | ✅ |
DescribeFeatureType | /geoserver/wfs?request=DescribeFeatureType... | Schema only | ❌ |
✅ Final Tips
-
Use
abstractfor a short, readable summary -
Use
metadataLinksfor full metadata (JSON/XML/HTML) -
Consider building your own metadata microservice or DB if you need more control
Would you like me to:
-
Generate a clean
abstractexample for a specific layer? -
Help create a JSON metadata structure you can serve?
-
Help you script REST updates to GeoServer for all your orgs?
Let me know!
You said:
ChatGPT said:
Excellent question — and an important architectural decision.
Short answer:
⚠️ No, you probably should not create 50 separate databases unless there's a very strong reason (like legal data separation or multi-tenant isolation requirements).
✅ Recommended: Use 1 database with multi-organization schema
Instead of creating 50 separate PostgreSQL/PostGIS databases, use:
🔸 One database, and either:
✅ Option A: One schema per organization
bashpostgresql://host/dbname Schemas: - org1_schema - org2_schema - org3_schema ...
Each schema contains its own tables/layers. For example:
org1_schema.schools org1_schema.roads org2_schema.schools org2_schema.roads
GeoServer can easily connect to specific schemas, and you can create 50 datastores (or one dynamic datastore if you're using REST automation).
This balances isolation and manageability.
✅ Option B: One schema, use a org_id column in each table
You keep all data in shared tables, and filter it using an organization_id:
sqlTable: public.schools
Columns: id, name, geom, org_id
This is easier to query and manage at scale, but gives less isolation.
Use GeoServer SQL views to filter per org:
sqlSELECT * FROM public.schools WHERE org_id = 'org1'
You can expose these filtered views as separate GeoServer layers.
🛑 When to Use 50 Separate Databases?
Only if you truly need physical isolation, such as:
-
Each org runs its own GeoServer instance
-
You’re hosting for clients who require full data isolation
-
Legal/compliance policies demand strict separation
-
Different DB versions/extensions per org
Downside:
-
High operational overhead
-
Hard to scale
-
Complex GeoServer datastore management
📊 Comparison
| Design | Pros | Cons | Good For |
|---|---|---|---|
| 1 DB, 1 schema per org | Isolated, manageable | 50 schemas, but still easy | Multi-tenant apps |
| 1 DB, org_id filter | Easiest to scale | Least isolation | Centralized access, APIs |
| 50 DBs | Total isolation | Very hard to manage | Strict compliance hosting |
🔁 GeoServer Integration Tips
-
You can dynamically register datastores via REST API
-
Use workspace + datastore naming like:
workspace: org1_ws,datastore: org1_store -
Use SQL views or filtered layers to serve per-org data cleanly
✅ Recommendation
Use a single PostGIS DB with either multiple schemas (Option A) or shared tables with org_id filters (Option B). This keeps things scalable, fast, and easier to integrate with GeoServer and your API layer.
Comments
Post a Comment