This is what I want: when I zoom out, cities of the country should appear as points and at a certain level when I zoom in, I want them to appear as polygons (showing the area of the city and boundaries). How can I do that? I am thinking of creating two tables "cities_points" and "cities_polygons" in my PostGIS database. Any idea? (actually not only the cities, but it's the same for other components of my map).
|
|
You can take advantage of layer groups in geoserver. Having in PostGIS the two geometries in separated tables, just create a layer group in geoserver with both layers and by means of SLD styling set the scale under which every layer should be rendered (use maxscaledenominator & minscaledenominator parameters). |
|||
|
|
Why not display the points/polygons as a wms-layer? Create a view as Scro suggested, create a layer for points and a layer for polygons in geoserver, set appropriate max- and minscalethresholds in sld-files, and combine them in a layer group. |
|||
|
|
One approach would be to create a view of the polygon centroids and manually add it to the geometry_columns table. The benifit of this method is that there is practically no maintenance of the points table as it will show any updates to the polygon table and make use of any of its indexes. The view creation would look something like this:
Then add it to the geometry_columns table, like so:
Hope that helps. |
|||||||
|
|
Which technology (apart from PostGIS, obviously) do you use? Is it a web application? If so, I'd recommend using Leaflet.js with a GeoJSON overlay from a server resource which returns either points or polygons depending on the zoom level you query the resource with. I can be more specific if i know the details. |
|||||||||||
|