[opengeodb] Alle Städte und/oder Landkreise in einem Bundesland?

Jan-Simon Winkelmann winkelmann at blue-metallic.de
Fre Mar 21 11:38:25 CET 2008


Robert Böck schrieb:
> Hallo Jan,
>
> Jan-Simon Winkelmann wrote:
>
>  
>> ich stehe (nach meinem inzwischen gelösten Kartenproblem) mal wieder 
>> vor einer Problematik. Diesmal mit der opengeodb selbst.
>> Und zwar möchte ich gerne (ohne die geoclassphp, sofern die das denn 
>> überhaupt kann) eine Liste von allen Städten in einem Bundesland oder 
>> allen Landkreisen in einem Bundesland haben. Geht das irgendwie oder 
>> fehlt da die Zuordnung?
>>     
>
> Ich habe mir vor einiger Zeit mal einige Abfragen in mühevoller
> Kleinarbeit zusammengebaut. Diese Abfragen beziehen sich auf Bayern,
> aber du kannst sie ja auf das jeweilige Bundesland anpassen. Beachte,
> dass diese Abfragen nur mit einer intakten geodb_hierarchies 
> funktionieren.
>
> ------------------------------------------------------------------------
> Regierungsbezirk:
>
> SELECT ort.loc_id as l_ort,
>        ort.text_val as t_ort
> FROM geodb_hierarchies hi,
>      geodb_textdata land,
>      geodb_textdata ort,
>      geodb_textdata bundesland
> WHERE hi.id_lvl2=land.loc_id AND
>       land.text_val='DE' AND
>       land.text_type=500100001 AND
>       hi.id_lvl3=bundesland.loc_id AND
>       bundesland.text_val='BY' AND
>       bundesland.text_type=500100001 AND
>       ort.loc_id = hi.loc_id AND
>       ort.text_type = 500100000 AND
>       hi.loc_id=hi.id_lvl4
> ORDER BY l_ort
> ------------------------------------------------------------------------
> Landkreis:
>
> SELECT ort.loc_id as l_ort,
>        ort.text_val as t_ort,
>        hi.id_lvl4 as rbez_id
> FROM geodb_hierarchies hi,
>      geodb_textdata land,
>      geodb_textdata ort,
>      geodb_textdata bundesland
> WHERE hi.id_lvl2=land.loc_id AND
>       land.text_val='DE' AND
>       land.text_type=500100001 AND
>       hi.id_lvl3=bundesland.loc_id AND
>       bundesland.text_val='BY' AND
>       bundesland.text_type=500100001 AND
>       ort.loc_id = hi.loc_id AND
>       ort.text_type = 500100000 AND
>       hi.loc_id=hi.id_lvl5
> ORDER BY l_ort
> ------------------------------------------------------------------------
> Ort:
>
> SELECT ort.loc_id as l_ort,
>        ort.text_val as t_ort,
>        coord.lon as lon,
>        coord.lat as lat,
>        kfz.text_val as t_kfz,
>        hi.id_lvl5 as lkr_id
> FROM geodb_hierarchies hi,
>      geodb_textdata land,
>      geodb_textdata ort,
>      geodb_textdata bundesland,
>      geodb_textdata kfz,
>      geodb_coordinates coord,
>      geodb_locations loc
> WHERE hi.id_lvl2=land.loc_id AND
>       land.text_val='DE' AND
>       land.text_type=500100001 AND
>       hi.id_lvl3=bundesland.loc_id AND
>       bundesland.text_val='BY' AND
>       bundesland.text_type=500100001 AND
>       ort.loc_id=hi.loc_id AND
>       ort.text_type=500100000 AND
>       hi.loc_id=hi.id_lvl6 AND
>       loc.loc_id=hi.loc_id AND
>       loc.loc_type=100700000 AND
>       coord.loc_id=hi.loc_id AND
>       kfz.loc_id=hi.loc_id AND
>       kfz.text_type=500500000
> ORDER BY l_ort
> ------------------------------------------------------------------------
> PLZ:
>
> SELECT plz.loc_id as l_plz,
>        plz.text_val as t_plz
> FROM geodb_hierarchies hi,
>      geodb_textdata land,
>      geodb_textdata bundesland,
>      geodb_textdata plz
> WHERE hi.id_lvl2=land.loc_id AND
>       land.text_val='DE' AND
>       land.text_type=500100001 AND
>       hi.id_lvl3=bundesland.loc_id AND
>       bundesland.text_val='BY' AND
>       bundesland.text_type=500100001 AND
>       hi.loc_id=hi.id_lvl6 AND
>       plz.loc_id=hi.loc_id AND
>       plz.text_type=500300000
> ORDER BY l_plz, t_plz
> ------------------------------------------------------------------------
>
> cu, Robo :)
>
>   
Hallo Robert,

leider ist bei mir die hierarchies-Tabelle leer ...

gruß
Jan