Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Using GeoServer, I need to provide a graphical representation of the distribution of some metrics on a geographical basis. The geographical regions will be coloured and labelled according to the value of that metric.

I would like to have a "world" layer (containing all the continents and only continents), a "Europe" layer (containing only countries from Europe) and a "France" layer (containing all the cities in France). So to speak, "a tree of layers containing the immediate children", given that these entities (continents/countries/cities) reside in three distinct tables with one-to-many relationships defined.

I haven't found any "filtering" option when defining a layer from a PostGIS store, so a "cities" layer can only be based on the whole cities table (not on the cities in country X). Is there something I missed ?

P.S. I would rather have distinct layers than having one big layer and filtering with every request, because I think the caching feature can only refer to layers. Is this assumption correct ?

share|improve this question
    
Let me try to rephrase... –  Costi Ciudatu Jan 11 '11 at 15:57
    
Hope the edit clarifies at least the "normalisation" thing... Basically, I'm looking for a way to define (for each country in the "countries" table) a layer containing all the cities in the "cities" table which belong to that country. –  Costi Ciudatu Jan 11 '11 at 16:09
    
I re-edited the question and I hope I phrased it right this time... and the title also... –  Costi Ciudatu Jan 11 '11 at 16:32

2 Answers 2

up vote 2 down vote accepted

I haven't found any "filtering" option when defining a layer from a PostGIS store, so a "cities" layer can only be based on the whole cities table (not on the cities in country X). Is there something I missed ?

There are basically two ways to filter data in Geoserver: CQL and OGC Filter encoding. Read more: http://docs.geoserver.org/2.0.x/en/user/filter/index.html

The new Geoserver beta additionally supports SQL views (http://gridlock.openplans.org/geoserver/trunk/doc/en/user/data/sqlview.html):

alt text

But in your case, I think it would make sense to just create a view containing only cities in France (if you want to avoid creating another table for that).

share|improve this answer
    
But these filtering solutions can only applied to the request. I would like the layer itself to only contain filtered data, so that I can request it with no filter and still get what I want (and benefit of caching). –  Costi Ciudatu Jan 12 '11 at 7:56
    
Have you even checked gridlock.openplans.org/geoserver/trunk/doc/en/user/data/…? You don't need to define views in database. You write an SQL statement in Geoserver. –  underdark Jan 12 '11 at 8:32
    
Actually, not until now (sorry !). I was pretty convinced this was only about using views that are already created (just like using tables). –  Costi Ciudatu Jan 12 '11 at 8:40

I don't really understand what you are trying to do but the new SQL views datastore in GeoServer 2.1beta may be what you are looking for. See http://gridlock.openplans.org/geoserver/trunk/doc/en/user/data/sqlview.html

share|improve this answer
    
Thanks. Having a view for each continent and each country defined in the DB is something I have considered, in case I won't find any better solution. –  Costi Ciudatu Jan 12 '11 at 7:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.