https://github.com/springmeyer/render-collections
sample style and notes around rendering geometry collections from postgis
https://github.com/springmeyer/render-collections
Last synced: 5 months ago
JSON representation
sample style and notes around rendering geometry collections from postgis
- Host: GitHub
- URL: https://github.com/springmeyer/render-collections
- Owner: springmeyer
- Created: 2011-11-01T16:32:15.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2011-12-22T22:30:41.000Z (over 14 years ago)
- Last Synced: 2025-05-20T04:35:04.856Z (about 1 year ago)
- Homepage:
- Size: 93.8 KB
- Stars: 3
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Rendering arbitrary geometry collections from postgis
## Overview
Mapnik uses flexible data structures for storing features
and their geometries. It also supports rendering rules
to allow multiple styles be applied to a given layer.
If you have a postgis table with a single geometry column
but many different kinds of geometry types, it is easy to
render directly from this column. You just need to apply
the desired styling logic and rules to display your data in
reasonable ways.
This repo includes a test XML and sample data to experiment
with this flexibility and brainstorm ways to make it better.
## Setup
createdb -T template_postgis geometries
psql geometries -f load_geoms.sql
## Testing renders
Edit the 'postgis.xml' adding or removing styles you wish to view rendered.
Then render the map out:
nik2img.py postgis.xml image.png
## Details of data structures
* Mapnik feature objects can store one or many geometries, each of arbitrary type.
* Mapnik geometry objects can store single or multipart points, lines, or polygons
* Some Mapnik datasources can enhance this flexibility by parsing OGC multigeometries
into a sequence of single geometries on a features: basically flattening OGC multigeometries
into a list of single geometries.
* Mapnik symbolizers can be applied to features with arbitrary types of geometries
* Mapnik renderers (agg, grid and cairo) are responsible for handling the drawing of
a given feature with applied symbolizer. Different rendering behaviors are triggered for certain
symbolizers at the rendering level depending on the `placement` type and/or the geometry type.
For example, common uses where this flexibility makes life simple:
- LineSymbolizer:
applied to a linestring geometry it strokes lines
applied to a polygon geometry it strokes the perimeter (outline)
- PolygonSymbolizer:
applied to a polygon geometry it fills the polygon(s)
But be aware this flexibility also creates some ambiguity or does nothing in some cases:
- PolygonSymbolizer:
lines - draws unfilled polygons and looks pretty odd
point - does nothing
- LineSymbolizer:
point - does nothing
And depending on `placement` type (and the types default, which can depend on geometry type)
you can see some complex behaviors:
- MarkersSymbolizer:
polygon geometry - draws point at centroid of each polygon (placement=point)
polygon geometry - draws point along the outline of each polygon (placement=line)
point geometry - draws point no matter the value of placement
## Caveats
* TextSymbolizer - only the first placeable label for a geometry part will currently show up (https://github.com/mapnik/mapnik/issues/162)
Bugs around multigeometry support are tracked via:
https://github.com/mapnik/mapnik/issues?sort=created&labels=multigeom+robustness&direction=desc&state=open