From 2cd8bde8fcd0340305c6bab854a2e4004b59e1f2 Mon Sep 17 00:00:00 2001 From: jeremy Date: Tue, 12 Mar 2024 15:09:30 +0100 Subject: [PATCH 01/12] Reformat buildingParams.json to keep 'OSM building type as generic type' --- .../geoclimate/osm/buildingParams.json | 1381 ++++++++++++----- 1 file changed, 1010 insertions(+), 371 deletions(-) diff --git a/osm/src/main/resources/org/orbisgis/geoclimate/osm/buildingParams.json b/osm/src/main/resources/org/orbisgis/geoclimate/osm/buildingParams.json index d392a7af30..d36d7ee557 100644 --- a/osm/src/main/resources/org/orbisgis/geoclimate/osm/buildingParams.json +++ b/osm/src/main/resources/org/orbisgis/geoclimate/osm/buildingParams.json @@ -50,7 +50,7 @@ "historic": 0, "monument": 0, "ruins": 0, - "castle": 0, + "castle": 1, "agricultural": 0, "farm": 0, "farm_auxiliary": 0, @@ -67,6 +67,7 @@ "toll_booth": 0, "toll": 0, "terminal": 0, + "airport_terminal": 0, "healthcare": 1, "education": 1, "entertainment_arts_culture": 0, @@ -78,28 +79,131 @@ "government": 1, "townhall": 1, "office": 1, - "heavy_industry": 0, - "light_industry": 0, "emergency": 0, "hotel": 2, "hospital": 2, "parking": 1, "slight_construction": 0, - "water_tower" : 0 + "water_tower" : 0, + "fortress": 0, + "abbey": 0, + "cathedral": 0, + "mosque": 0, + "musalla": 0, + "temple": 0, + "synagogue": 0, + "shrine": 0, + "place_of_worship": 0, + "wayside_shrine": 0, + "swimming_pool" : 0, + "fitness_centre": 1, + "horse_riding": 0, + "ice_rink" : 0, + "pitch": 0, + "stadium": 0, + "track": 0, + "sports_hall": 0, + "ammunition": 0, + "bunker": 0, + "barracks": 1, + "casemate": 0, + "station": 0, + "government_office": 1, + "stable": 0, + "sty": 0, + "cowshed": 0, + "digester": 0, + "farmhouse": 0, + "bank": 1, + "bureau_de_change": 0, + "boat_rental": 0, + "car_rental" : 0, + "internet_cafe": 0, + "kiosk": 0, + "money_transfer": 0, + "market": 0, + "marketplace": 0, + "pharmacy" : 0, + "post_office" : 1, + "retail": 0, + "shop" : 0, + "store": 0, + "supermarket": 0, + "warehouse": 0, + "factory": 0, + "gas" : 0, + "heating_station": 0, + "oil_mill" : 0, + "oil": 0, + "wellsite": 0, + "well_cluster": 0, + "grain_silo": 0, + "villa": 1, + "dormitory": 1, + "condominium": 1, + "sheltered_housing": 0, + "workers_dormitory" :0, + "terrace": 1, + "transportation": 0, + "hangar": 0, + "tower": 1, + "control_tower": 0, + "aeroway": 1, + "roundhouse": 0, + "social_facility": 1, + "college": 1, + "kindergarten": 0, + "school": 0, + "university": 1, + "cinema": 1, + "arts_centre": 0, + "brothel": 1, + "casino": 0, + "community_centre": 0, + "conference_centre": 1, + "events_venue": 1, + "exhibition_centre": 0, + "gambling": 0, + "music_venue": 0, + "nightclub": 0, + "planetarium": 0, + "social_centre": 0, + "studio": 0, + "theatre": 0, + "library": 1, + "museum": 0, + "aquarium": 0, + "gallery": 0, + "information": 0, + "restaurant": 0, + "bar": 0, + "cafe": 0, + "fast_food": 0, + "ice_cream": 0, + "pub": 0, + "attraction": 0 }, "type": { "terminal:transport": { "aeroway": [ - "terminal", - "airport_terminal" + "terminal" + ], + "amenity": [ + "terminal" + ], + "building": [ + "terminal" + ] + }, + "airport_terminal:transport": { + "aeroway": [ + "terminal" ], "amenity": [ - "terminal", - "airport_terminal" + "terminal" ], "building": [ - "terminal", - "airport_terminal" + "terminal" ] }, "parking:transport": { @@ -107,6 +211,84 @@ "parking" ] }, + "train_station:transport": { + "building": [ + "train_station" + ], + "railway": [ + "train_station" + ], + "public_transport": [ + "train_station" + ], + "amenity": [ + "train_station" + ] + }, + "station:transport": { + "railway": [ + "station" + ] + }, + "toll:transport": { + "barrier": [ + "toll_booth" + ], + "building": [ + "toll_booth" + ] + }, + "shelter:transport": { + "shelter_type": [ + "public_transport" + ] + }, + "transportation:transport": { + "building": [ + "transportation" + ] + }, + "station:transport": { + "building": [ + "station" + ], + "railway": [ + "station" + ], + "public_transport": [ + "station" + ] + }, + "hangar:transport": { + "aeroway": [ + "hangar" + ] + }, + "tower:transport": { + "aeroway": [ + "tower" + ] + }, + "bunker:transport": { + "aeroway": [ + "bunker" + ] + }, + "control_tower:transport": { + "aeroway": [ + "control_tower" + ] + }, + "aeroway:transport": { + "aeroway": [ + "building" + ] + }, + "roundhouse:transport": { + "railway": [ + "roundhouse" + ] + }, "monument": { "building": [ "monument" @@ -145,519 +327,976 @@ }, "castle:heritage": { "building": [ - "castle", + "castle" + ] + }, + "fortress:heritage": { + "building": [ "fortress" ] }, - "religious": { + "religious:religious": { "building": [ - "religious", - "abbey", - "cathedral", - "mosque", - "musalla", - "temple", - "synagogue", - "shrine", - "place_of_worship", - "wayside_shrine" + "religious" ], "amenity": [ - "religious", - "abbey", - "cathedral", - "chapel", - "church", - "mosque", - "musalla", - "temple", - "synagogue", - "shrine", - "place_of_worship", - "wayside_shrine" - ], - "place_of_worship": [ - "! no", - "! chapel", - "! church" + "religious" ] }, - "sport:sport": { + "abbey:religious": { "building": [ - "swimming_pool", - "fitness_centre", - "horse_riding", - "ice_rink", - "pitch", - "stadium", - "track" - ], - "leisure": [ - "swimming_pool", - "fitness_centre", - "horse_riding", - "ice_rink", - "pitch", - "stadium", - "track" + "abbey" ], "amenity": [ - "swimming_pool", - "fitness_centre", - "horse_riding", - "ice_rink", - "pitch", - "stadium", - "track" + "abbey" ] }, - "sports_centre:sport": { + "cathedral:religious": { "building": [ - "sports_centre", - "sports_hall" - ], - "leisure": [ - "sports_centre", - "sports_hall" + "cathedral" ], "amenity": [ - "sports_centre", - "sports_hall" + "cathedral" ] }, - "military": { - "military": [ - "ammunition", - "bunker", - "barracks", - "casemate", - "office", - "shelter" - ], + "mosque:religious": { "building": [ - "ammunition", - "bunker", - "barracks", - "casemate", - "military", - "shelter" + "mosque" ], - "office": [ - "military" + "amenity": [ + "mosque" ] }, - "train_station:transport": { + "musalla:religious": { "building": [ - "train_station" - ], - "railway": [ - "station", - "train_station" - ], - "public_transport": [ - "train_station" + "musalla" ], "amenity": [ - "train_station" + "musalla" ] }, - "townhall:government": { - "amenity": [ - "townhall" - ], + "temple:religious": { "building": [ - "townhall" - ] - }, - "toll:transport": { - "barrier": [ - "toll_booth" + "temple" ], - "building": [ - "toll_booth" + "amenity": [ + "temple" ] }, - "government": { + "synagogue:religious": { "building": [ - "government", - "government_office" - ], - "government": [ - "! no" + "synagogue" ], - "office": [ - "government" + "amenity": [ + "synagogue" ] }, - "historic": { + "shrine:religious": { "building": [ - "historic" + "shrine" ], - "historic": [ - ], - "historic_building": [ - "! no" + "amenity": [ + "shrine" ] }, - "grandstand:entertainment_arts_culture": { + "place_of_worship:religious": { "building": [ - "grandstand" - ], - "leisure": [ - "grandstand" + "place_of_worship" ], "amenity": [ - "grandstand" - ], - "grandstand": [ - "yes" + "place_of_worship" ] }, - "detached:residential": { + "wayside_shrine:religious": { "building": [ - "detached" + "wayside_shrine" ], - "house": [ - "detached" + "amenity": [ + "wayside_shrine" ] }, - "farm_auxiliary:agricultural": { + "swimming_pool:sport": { "building": [ - "farm_auxiliary", - "barn", - "stable", - "sty", - "cowshed", - "digester", - "greenhouse" - ] - }, - "commercial": { - "building": [ - "bank", - "bureau_de_change", - "boat_rental", - "car_rental", - "commercial", - "internet_cafe", - "kiosk", - "money_transfer", - "market", - "marketplace", - "pharmacy", - "post_office", - "retail", - "shop", - "store", - "supermarket", - "warehouse" + "swimming_pool" ], - "amenity": [ - "bank", - "bureau_de_change", - "boat_rental", - "car_rental", - "commercial", - "internet_cafe", - "kiosk", - "money_transfer", - "market", - "market_place", - "pharmacy", - "post_office", - "retail", - "shop", - "store", - "supermarket", - "warehouse" + "leisure": [ + "swimming_pool" ], - "shop": [ - "!= no" + "amenity": [ + "swimming_pool" ] }, - "light_industry:industrial": { + "fitness_centre:sport": { "building": [ - "industrial", - "factory", - "warehouse" + "fitness_centre" ], - "industrial": [ - "factory" + "leisure": [ + "fitness_centre" ], "amenity": [ - "factory" + "fitness_centre" ] }, - "heavy_industry:industrial": { + "horse_riding:sport": { "building": [ - "digester" + "horse_riding" ], - "industrial": [ - "gas", - "heating_station", - "oil_mill", - "oil", - "wellsite", - "well_cluster" + "leisure": [ + "horse_riding" + ], + "amenity": [ + "horse_riding" ] }, - "greenhouse:agricultural": { + "ice_rink:sport": { "building": [ - "greenhouse" + "ice_rink" ], - "amenity": [ - "greenhouse" + "leisure": [ + "ice_rink" ], - "industrial": [ - "greenhouse" + "amenity": [ + "ice_rink" ] }, - "silo:agricultural": { + "pitch:sport": { "building": [ - "silo", - "grain_silo" + "pitch" ], - "man_made": [ - "silo", - "grain_silo" + "leisure": [ + "pitch" + ], + "amenity": [ + "pitch" ] }, - "house:residential": { + "stadium:sport": { "building": [ - "house" + "stadium" ], - "house": [ - "! no", - "! detached", - "! residential", - "! villa", - "residential" + "leisure": [ + "stadium" ], "amenity": [ - "house" + "stadium" ] }, - "apartments:residential": { + "track:sport": { "building": [ - "apartments" + "track" ], - "residential": [ - "apartments" + "leisure": [ + "track" ], "amenity": [ - "apartments" - ], - "apartments": [ - "yes" + "track" ] }, - "bungalow:residential": { + "sports_centre:sport": { "building": [ - "bungalow" + "sports_centre" ], - "house": [ - "bungalow" + "leisure": [ + "sports_centre" ], "amenity": [ - "bungalow" + "sports_centre" ] }, - "residential": { + "sports_hall:sport": { "building": [ - "residential", - "villa", - "dormitory", - "condominium", - "sheltered_housing", - "workers_dormitory", - "terrace" - ], - "residential": [ - "university", - "detached", - "dormitory", - "condominium", - "sheltered_housing", - "workers_dormitory", - "building" + "sports_hall" ], - "house": [ - "residential" + "leisure": [ + "sports_hall" ], "amenity": [ - "residential" + "sports_hall" ] }, - "ruins:heritage": { - "building": [ - "ruins" + "ammunition:military": { + "military": [ + "ammunition" ], - "ruins": [ - "ruins" + "building": [ + "ammunition" ] }, - "agricultural": { - "building": [ - "agricultural" + "bunker:military": { + "military": [ + "bunker" ], - "agricultural": [ - "building" + "building": [ + "bunker" ] }, - "farm:agricultural": { + "barracks:military": { + "military": [ + "barracks" + ], "building": [ - "farm", - "farmhouse" + "barracks" ] }, - "barn:agricultural": { - "building": [ - "barn" + "casemate:military": { + "military": [ + "casemate" ], - "barn": [ - "! no" + "building": [ + "casemate" ] }, - "shelter": { - "amenity": [ + "casemate:military": { + "military": [ + "office" + ] + }, + "shelter:military": { + "military": [ "shelter" ] }, - "shelter:transport": { - "shelter_type": [ - "public_transport" + "office:military": { + "military": [ + "office" + ] + }, + "office:military": { + "military": [ + "office" + ], + "office": [ + "military" + ] + }, + "military:military": { + "building": [ + "military" + ] + }, + "townhall:government": { + "amenity": [ + "townhall" + ], + "building": [ + "townhall" + ] + }, + "government:government": { + "building": [ + "government" + ] + }, + "government_office:government": { + "building": [ + "government_office" + ], + "office": [ + "government" + ] + }, + "government:government": { + "building": [ + "public" + ] + }, + "historic": { + "building": [ + "historic" + ], + "historic": [ + ], + "historic_building": [ + "! no" + ] + }, + "grandstand:entertainment_arts_culture": { + "building": [ + "grandstand" + ], + "leisure": [ + "grandstand" + ], + "amenity": [ + "grandstand" + ], + "grandstand": [ + "yes" + ] + }, + "farm_auxiliary:agricultural": { + "building": [ + "farm_auxiliary" + ] + }, + "barn:agricultural": { + "building": [ + "barn" + ] + }, + "stable:agricultural": { + "building": [ + "stable" + ] + }, + "sty:agricultural": { + "building": [ + "sty" + ] + }, + "cowshed:agricultural": { + "building": [ + "cowshed" + ] + }, + "greenhouse:agricultural": { + "building": [ + "greenhouse" + ], + "amenity": [ + "greenhouse" + ], + "industrial": [ + "greenhouse" + ] + }, + "agricultural:agricultural": { + "building": [ + "agricultural" + ], + "agricultural": [ + "building" + ] + }, + "farm:agricultural": { + "building": [ + "farm" + ] + }, + "farmhouse:agricultural": { + "building": [ + "farmhouse" + ] + }, + "grain_silo:agricultural": { + "building": [ + "grain_silo" + ], + "man_made": [ + "grain_silo" + ] + }, + "silo:agricultural": { + "building": [ + "silo" + ], + "man_made": [ + "silo" + ] + }, + "bank:commercial": { + "building": [ + "bank" + ], + "amenity": [ + "bank" + ] + }, + "bureau_de_change:commercial": { + "building": [ + "bureau_de_change" + ], + "amenity": [ + "bureau_de_change" + ] + }, + "boat_rental:commercial": { + "building": [ + "boat_rental" + ], + "amenity": [ + "boat_rental" + ] + }, + "car_rental:commercial": { + "building": [ + "car_rental" + ], + "amenity": [ + "car_rental" + ] + }, + "commercial:commercial": { + "building": [ + "commercial" + ], + "amenity": [ + "commercial" + ] + }, + "internet_cafe:commercial": { + "building": [ + "internet_cafe" + ], + "amenity": [ + "internet_cafe" + ] + }, + "kiosk:commercial": { + "building": [ + "kiosk" + ], + "amenity": [ + "kiosk" + ] + }, + "money_transfer:commercial": { + "building": [ + "money_transfer" + ], + "amenity": [ + "money_transfer" + ] + }, + "market:commercial": { + "building": [ + "market" + ], + "amenity": [ + "market" + ] + }, + "marketplace:commercial": { + "building": [ + "marketplace" + ], + "amenity": [ + "marketplace" + ] + }, + "pharmacy:commercial": { + "building": [ + "pharmacy" + ], + "amenity": [ + "pharmacy" + ] + }, + "post_office:commercial": { + "building": [ + "post_office" + ], + "amenity": [ + "post_office" + ] + }, + "retail:commercial": { + "building": [ + "retail" + ], + "amenity": [ + "retail" + ] + }, + "shop:commercial": { + "building": [ + "shop" + ], + "amenity": [ + "shop" + ] + }, + "store:commercial": { + "building": [ + "store" + ], + "amenity": [ + "store" + ] + }, + "supermarket:commercial": { + "building": [ + "supermarket" + ], + "amenity": [ + "supermarket" + ] + }, + "warehouse:commercial": { + "building": [ + "warehouse" + ], + "amenity": [ + "warehouse" + ] + }, + "restaurant:commercial": { + "amenity": [ + "restaurant" + ], + "building": [ + "restaurant" + ], + "shop": [ + "restaurant" + ] + }, + "bar:commercial": { + "amenity": [ + "bar" + ], + "building": [ + "bar" + ], + "shop": [ + "bar" + ] + }, + "cafe:commercial": { + "amenity": [ + "cafe" + ], + "building": [ + "cafe" + ], + "shop": [ + "cafe" + ] + }, + "fast_food:commercial": { + "amenity": [ + "fast_food" + ], + "building": [ + "fast_food" + ], + "shop": [ + "fast_food" + ] + }, + "ice_cream:commercial": { + "amenity": [ + "ice_cream" + ], + "building": [ + "ice_cream" + ], + "shop": [ + "ice_cream" + ] + }, + "pub:commercial": { + "amenity": [ + "pub" + ], + "building": [ + "pub" + ], + "shop": [ + "pub" + ] + }, + "industrial:industrial": { + "building": [ + "industrial" + ] + }, + "factory:industrial": { + "building": [ + "factory" + ], + "industrial": [ + "factory" + ], + "amenity": [ + "factory" + ] + }, + "warehouse:industrial": { + "industrial": [ + "warehouse" + ] + }, + "digester:industrial": { + "building": [ + "digester" + ] + }, + "gas:industrial": { + "industrial": [ + "gas" + ] + }, + "heating_station:industrial": { + "industrial": [ + "heating_station" + ] + }, + "oil_mill:industrial": { + "industrial": [ + "oil_mill" + ] + }, + "oil:industrial": { + "industrial": [ + "oil" + ] + }, + "wellsite:industrial": { + "industrial": [ + "wellsite" + ] + }, + "well_cluster:industrial": { + "industrial": [ + "well_cluster" ] }, - "transport": { + "house:residential": { "building": [ - "train_station", - "transportation", - "station" + "house" ], - "aeroway": [ - "hangar", - "tower", - "bunker", - "control_tower", + "house": [ + "residential" + ], + "amenity": [ + "house" + ] + }, + "detached:residential": { + "building": [ + "detached" + ], + "house": [ + "detached" + ] + }, + "apartments:residential": { + "building": [ + "apartments" + ], + "residential": [ + "apartments" + ], + "amenity": [ + "apartments" + ], + "apartments": [ + "yes" + ] + }, + "bungalow:residential": { + "building": [ + "bungalow" + ], + "house": [ + "bungalow" + ], + "amenity": [ + "bungalow" + ] + }, + "residential:residential": { + "building": [ + "residential" + ], + "residential": [ "building" ], - "railway": [ - "station", - "train_station", - "roundhouse" - + "amenity": [ + "residential" + ] + }, + "villa:residential": { + "building": [ + "villa" + ] + }, + "dormitory:residential": { + "building": [ + "dormitory" ], - "public_transport": [ - "train_station", - "station" + "residential": [ + "dormitory" + ] + }, + "condominium:residential": { + "building": [ + "condominium" + ], + "residential": [ + "condominium" + ] + }, + "sheltered_housing:residential": { + "building": [ + "sheltered_housing" + ], + "residential": [ + "sheltered_housing" + ] + }, + "workers_dormitory:residential": { + "building": [ + "workers_dormitory" + ], + "residential": [ + "workers_dormitory" + ] + }, + "terrace:residential": { + "building": [ + "terrace" + ], + "residential": [ + "terrace" + ] + }, + "ruins:heritage": { + "building": [ + "ruins" ], + "ruins": [ + "ruins" + ] + }, + "shelter:shelter": { "amenity": [ - "train_station", - "terminal" + "shelter" ] }, - "healthcare": { + "healthcare:healthcare": { "amenity": [ - "healthcare", - "social_facility" + "healthcare" ], "building": [ - "healthcare", + "healthcare" + ] + }, + "social_facility:healthcare": { + "amenity": [ + "social_facility" + ] + }, + "hospital:healthcare": { + "building": [ "hospital" + ] + }, + "education:education": { + "amenity": [ + "education" ], - "healthcare": [ - "! no" + "building": [ + "education" ] }, - "education": { + "college:education": { "amenity": [ - "education", - "college", - "kindergarten", - "school", - "university", - "research_institute" + "college" + ], + "building": [ + "college" + ], + "education": [ + "college" + ] + }, + "kindergarten:education": { + "amenity": [ + "kindergarten" + ], + "building": [ + "kindergarten" + ], + "education": [ + "kindergarten" + ] + }, + "school:education": { + "amenity": [ + "school" + ], + "building": [ + "school" + ], + "education": [ + "school" + ] + }, + "university:education": { + "amenity": [ + "university" ], "building": [ - "education", - "college", - "kindergarten", - "school", "university" ], "education": [ - "college", - "kindergarten", - "school", "university" ] }, - "entertainment_arts_culture": { - "leisure": [ - "! no" - ], "amenity": [ - "cinema","arts_centre", "brothel", "casino", - "community_centre", "conference_centre", - "events_venue", "exhibition_centre", "gambling", - "music_venue", "nightclub", "planetarium", - "social_centre","studio", "theatre", "library" - ], - "building": [ - "cinema","arts_centre", "brothel", "casino", - "community_centre", "conference_centre", - "events_venue", "exhibition_centre", "gambling", - "music_venue", "nightclub", "planetarium", - "social_centre","studio", "theatre" - ], "tourism": [ - "museum", "aquarium", "gallery", "information" - ] - }, - "sustenance:commercial": { - "amenity": [ - "restaurant", - "bar", - "cafe", - "fast_food", - "ice_cream", - "pub" + "research_institute:education": { + "amenity": [ + "research_institute" ], "building": [ - "restaurant", - "bar", - "cafe", - "fast_food", - "ice_cream", - "pub" + "research_institute" + ] + }, + "cinema:entertainment_arts_culture": { + "amenity": [ + "cinema" ], - "restaurant": [ - "! no" + "building": [ + "cinema" + ] + }, + "arts_centre:entertainment_arts_culture": { + "amenity": [ + "arts_centre" ], - "shop": [ - "restaurant", - "bar", - "cafe", - "fast_food", - "ice_cream", - "pub" + "building": [ + "arts_centre" + ] + }, + "brothel:entertainment_arts_culture": { + "amenity": [ + "brothel" ], - "sustenance": [ - "! no" + "building": [ + "brothel" ] }, - "office": { + "casino:entertainment_arts_culture": { + "amenity": [ + "casino" + ], "building": [ - "office" + "casino" + ] + }, + "community_centre:entertainment_arts_culture": { + "amenity": [ + "community_centre" ], + "building": [ + "community_centre" + ] + }, + "conference_centre:entertainment_arts_culture": { "amenity": [ - "office" + "conference_centre" ], - "office": [ - "! no" + "building": [ + "conference_centre" ] }, - "government:public": { + "events_venue:entertainment_arts_culture": { + "amenity": [ + "events_venue" + ], "building": [ - "public" + "events_venue" + ] + }, + "exhibition_centre:entertainment_arts_culture": { + "amenity": [ + "exhibition_centre" + ], + "building": [ + "exhibition_centre" + ] + }, + "gambling:entertainment_arts_culture": { + "amenity": [ + "gambling" + ], + "building": [ + "gambling" + ] + }, + "music_venue:entertainment_arts_culture": { + "amenity": [ + "music_venue" + ], + "building": [ + "music_venue" + ] + }, + "nightclub:entertainment_arts_culture": { + "amenity": [ + "nightclub" + ], + "building": [ + "nightclub" + ] + }, + "planetarium:entertainment_arts_culture": { + "amenity": [ + "planetarium" + ], + "building": [ + "planetarium" + ] + }, + "social_centre:entertainment_arts_culture": { + "amenity": [ + "social_centre" + ], + "building": [ + "social_centre" + ] + }, + "studio:entertainment_arts_culture": { + "amenity": [ + "studio" + ], + "building": [ + "studio" + ] + }, + "theatre:entertainment_arts_culture": { + "amenity": [ + "theatre" + ], + "building": [ + "theatre" + ] + }, + "library:entertainment_arts_culture": { + "amenity": [ + "library" + ], + "building": [ + "library" + ] + }, + "museum:entertainment_arts_culture": { + "tourism": [ + "museum" + ] + }, + "aquarium:entertainment_arts_culture": { + "tourism": [ + "aquarium" + ] + }, + "gallery:entertainment_arts_culture": { + "tourism": [ + "gallery" + ] + }, + "information:entertainment_arts_culture": { + "tourism": [ + "information" + ] + }, + "office": { + "building": [ + "office" + ], + "amenity": [ + "office" ] }, "emergency": { From 608dbfbb01384354dacfae9876a108f0e81309c3 Mon Sep 17 00:00:00 2001 From: jeremy Date: Tue, 12 Mar 2024 15:45:15 +0100 Subject: [PATCH 02/12] Update BDTopo with new OSM types (Note that heavy industry is lost...) --- .../bdtopo/InputDataFormatting.groovy | 190 ++++++++++++++---- .../geoclimate/osm/buildingParams.json | 8 +- 2 files changed, 154 insertions(+), 44 deletions(-) diff --git a/bdtopo/src/main/groovy/org/orbisgis/geoclimate/bdtopo/InputDataFormatting.groovy b/bdtopo/src/main/groovy/org/orbisgis/geoclimate/bdtopo/InputDataFormatting.groovy index bf72aa9065..9c784676de 100644 --- a/bdtopo/src/main/groovy/org/orbisgis/geoclimate/bdtopo/InputDataFormatting.groovy +++ b/bdtopo/src/main/groovy/org/orbisgis/geoclimate/bdtopo/InputDataFormatting.groovy @@ -66,14 +66,14 @@ String formatBuildingLayer(JdbcDataSource datasource, String building, String zo def types_uses_dictionnary = ["Bâtiment agricole" : ["farm_auxiliary": "agricultural"], "Bâtiment commercial" : ["commercial": "commercial"], - "Bâtiment industriel" : ["light_industry": "industrial"], + "Bâtiment industriel" : ["industrial": "industrial"], "Serre" : ["greenhouse": "agricultural"], "Silo" : ["silo": "agricultural"], - "Aérogare" : ["terminal": "transport"], + "Aérogare" : ["aeroway": "transport"], "Arc de triomphe" : ["monument": "heritage"], "Arène ou théâtre antique" : ["monument": "monument"], "Bâtiment religieux divers" : ["religious": "religious"], - "Bâtiment sportif" : ["sports_centre": "entertainment_arts_culture"], + "Bâtiment sportif" : ["sports_centre": "sport"], "Chapelle" : ["chapel": "religious"], "Château" : ["castle": "heritage"], "Eglise" : ["church": "religious"], @@ -97,48 +97,152 @@ String formatBuildingLayer(JdbcDataSource datasource, String building, String zo "Annexe" : ["annex": "building"], "Industriel, agricole ou commercial": ["commercial": "commercial"], "Bâtiment" : ["building": "building"], - "Industrie lourde" : ["heavy_industry": "industrial"] + "Industrie lourde" : ["industrial": "industrial"] ] - def building_type_level = ["building" : 1, - "annex" : 0, - "house" : 1, - "detached" : 1, - "residential" : 1, - "apartments" : 1, - "bungalow" : 0, - "historic" : 0, - "monument" : 0, - "ruins" : 0, - "castle" : 0, - "agricultural" : 0, - "farm" : 0, - "farm_auxiliary" : 0, - "barn" : 0, - "greenhouse" : 0, - "silo" : 0, - "commercial" : 2, - "industrial" : 0, - "sport" : 0, - "sports_centre" : 0, - "grandstand" : 0, - "transport" : 0, - "train_station" : 0, - "toll_booth" : 0, - "terminal" : 0, - "healthcare" : 1, - "education" : 1, - "entertainment_arts_culture": 0, - "sustenance" : 1, - "military" : 0, - "religious" : 0, - "chapel" : 0, - "church" : 0, - "government" : 1, - "townhall" : 1, - "office" : 1, - "heavy_industry" : 0, - "light_industry" : 0] + def building_type_level = [ + "building": 1, + "house": 1, + "detached": 1, + "residential": 1, + "apartments": 1, + "bungalow": 0, + "historic": 0, + "monument": 0, + "ruins": 0, + "castle": 1, + "agricultural": 0, + "farm": 0, + "farm_auxiliary": 0, + "barn": 0, + "greenhouse": 0, + "silo": 0, + "commercial": 2, + "industrial": 0, + "sport": 0, + "sports_centre": 0, + "grandstand": 0, + "transport": 0, + "train_station": 0, + "toll_booth": 0, + "toll": 0, + "terminal": 0, + "airport_terminal": 0, + "healthcare": 1, + "education": 1, + "entertainment_arts_culture": 0, + "sustenance": 1, + "military": 0, + "religious": 0, + "chapel": 0, + "church": 0, + "government": 1, + "townhall": 1, + "office": 1, + "emergency": 0, + "hotel": 2, + "hospital": 2, + "parking": 1, + "slight_construction": 0, + "water_tower" : 0, + "fortress": 0, + "abbey": 0, + "cathedral": 0, + "mosque": 0, + "musalla": 0, + "temple": 0, + "synagogue": 0, + "shrine": 0, + "place_of_worship": 0, + "wayside_shrine": 0, + "swimming_pool" : 0, + "fitness_centre": 1, + "horse_riding": 0, + "ice_rink" : 0, + "pitch": 0, + "stadium": 0, + "track": 0, + "sports_hall": 0, + "ammunition": 0, + "bunker": 0, + "barracks": 1, + "casemate": 0, + "station": 0, + "government_office": 1, + "stable": 0, + "sty": 0, + "cowshed": 0, + "digester": 0, + "farmhouse": 0, + "bank": 1, + "bureau_de_change": 0, + "boat_rental": 0, + "car_rental" : 0, + "internet_cafe": 0, + "kiosk": 0, + "money_transfer": 0, + "market": 0, + "marketplace": 0, + "pharmacy" : 0, + "post_office" : 1, + "retail": 0, + "shop" : 0, + "store": 0, + "supermarket": 0, + "warehouse": 0, + "factory": 0, + "gas" : 0, + "heating_station": 0, + "oil_mill" : 0, + "oil": 0, + "wellsite": 0, + "well_cluster": 0, + "grain_silo": 0, + "villa": 1, + "dormitory": 1, + "condominium": 1, + "sheltered_housing": 0, + "workers_dormitory" :0, + "terrace": 1, + "transportation": 0, + "hangar": 0, + "tower": 1, + "control_tower": 0, + "aeroway": 1, + "roundhouse": 0, + "social_facility": 1, + "college": 1, + "kindergarten": 0, + "school": 0, + "university": 1, + "cinema": 1, + "arts_centre": 0, + "brothel": 1, + "casino": 0, + "community_centre": 0, + "conference_centre": 1, + "events_venue": 1, + "exhibition_centre": 0, + "gambling": 0, + "music_venue": 0, + "nightclub": 0, + "planetarium": 0, + "social_centre": 0, + "studio": 0, + "theatre": 0, + "library": 1, + "museum": 0, + "aquarium": 0, + "gallery": 0, + "information": 0, + "restaurant": 0, + "bar": 0, + "cafe": 0, + "fast_food": 0, + "ice_cream": 0, + "pub": 0, + "attraction": 0 + ] //Formating building table diff --git a/osm/src/main/resources/org/orbisgis/geoclimate/osm/buildingParams.json b/osm/src/main/resources/org/orbisgis/geoclimate/osm/buildingParams.json index d36d7ee557..e01bcb995a 100644 --- a/osm/src/main/resources/org/orbisgis/geoclimate/osm/buildingParams.json +++ b/osm/src/main/resources/org/orbisgis/geoclimate/osm/buildingParams.json @@ -181,7 +181,8 @@ "fast_food": 0, "ice_cream": 0, "pub": 0, - "attraction": 0 + "attraction": 0, + "refinery": 0 }, "type": { "terminal:transport": { @@ -952,6 +953,11 @@ "well_cluster" ] }, + "refinery:industrial": { + "industrial": [ + "refinery" + ] + }, "house:residential": { "building": [ "house" From a68864fcb0ee09c831d7ba5c04ff3059dedfb396 Mon Sep 17 00:00:00 2001 From: jeremy Date: Tue, 12 Mar 2024 15:56:34 +0100 Subject: [PATCH 03/12] Update urbanAreasParams.json with new OSM types --- .../geoclimate/osm/urbanAreasParams.json | 50 +++++++++++++------ 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/osm/src/main/resources/org/orbisgis/geoclimate/osm/urbanAreasParams.json b/osm/src/main/resources/org/orbisgis/geoclimate/osm/urbanAreasParams.json index bb1fae88a6..c00fd0cde0 100644 --- a/osm/src/main/resources/org/orbisgis/geoclimate/osm/urbanAreasParams.json +++ b/osm/src/main/resources/org/orbisgis/geoclimate/osm/urbanAreasParams.json @@ -22,13 +22,23 @@ "education": { "landuse": [ "education" - ], + ] + }, + "university": { + "amenity": [ + "university" + ] + }, + "research_institute": { "amenity": [ - "school", - "university", "research_institute" ] }, + "school": { + "amenity": [ + "school" + ] + }, "construction": { "landuse": [ "construction" @@ -36,7 +46,11 @@ }, "commercial": { "landuse": [ - "commercial", + "commercial" + ] + }, + "retail": { + "landuse": [ "retail" ] }, @@ -45,14 +59,19 @@ "residential" ] }, - "heavy_industry": { - "industrial": [ - "refinery" + "industrial": { + "landuse": [ + "industrial" ] }, - "light_industry": { + "port": { "landuse": [ - "industrial", "port" + "port" + ] + }, + "industrial": { + "industrial": [ + "refinery" ] }, "government": { @@ -60,21 +79,22 @@ "institutional" ] }, - "social_building": { - "amenity": [ - "community_centre" - ]}, + "community_centre": { + "amenity": [ + "community_centre" + ] + }, "military": { "landuse": [ "military" ] }, - "transport": { + "railway": { "landuse": [ "railway" ] }, - "agricultural": { + "farmyard": { "landuse": [ "farmyard" ] From db8c351fcc8c7d88321be3a770e873e789ee646f Mon Sep 17 00:00:00 2001 From: jeremy Date: Thu, 14 Mar 2024 17:46:24 +0100 Subject: [PATCH 04/12] Add indicators to the tests --- .../TypologyClassification.groovy | 10 +- .../WorkflowGeoIndicators.groovy | 271 +++++++++++++----- .../WorkflowGeoIndicatorsTest.groovy | 22 +- .../geoindicators/data_for_tests.sql | 6 +- 4 files changed, 227 insertions(+), 82 deletions(-) diff --git a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/TypologyClassification.groovy b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/TypologyClassification.groovy index 2bee5f8257..eb4715e4dc 100644 --- a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/TypologyClassification.groovy +++ b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/TypologyClassification.groovy @@ -234,7 +234,7 @@ String identifyLczType(JdbcDataSource datasource, String rsuLczIndicators, Strin datasource """DROP TABLE IF EXISTS $urbanLCZ; CREATE TABLE $urbanLCZ AS SELECT a.*, - a.AREA_FRACTION_COMMERCIAL + a.AREA_FRACTION_LIGHT_INDUSTRY AS AREA_FRACTION_LOWRISE_TYPO + a.AREA_FRACTION_COMMERCIAL_LCZ + a.AREA_FRACTION_LIGHT_INDUSTRY_LCZ AS AREA_FRACTION_LOWRISE_TYPO FROM $rsuAllIndicators a LEFT JOIN $ruralLCZ b ON a.$ID_FIELD_RSU = b.$ID_FIELD_RSU @@ -242,11 +242,11 @@ String identifyLczType(JdbcDataSource datasource, String rsuLczIndicators, Strin // 0. Set as industrial areas or large low-rise (commercial) having more of industrial or commercial than residential // and at least 1/3 of fraction - if (datasource.getColumnNames(urbanLCZ).contains("AREA_FRACTION_HEAVY_INDUSTRY")) { + if (datasource.getColumnNames(urbanLCZ).contains("AREA_FRACTION_HEAVY_INDUSTRY_LCZ")) { datasource """DROP TABLE IF EXISTS $classifiedIndustrialCommercialLcz; CREATE TABLE $classifiedIndustrialCommercialLcz AS SELECT $ID_FIELD_RSU, - CASE WHEN AREA_FRACTION_HEAVY_INDUSTRY > AREA_FRACTION_LOWRISE_TYPO + CASE WHEN AREA_FRACTION_HEAVY_INDUSTRY_LCZ > AREA_FRACTION_LOWRISE_TYPO THEN 10 ELSE 8 END AS LCZ1, null AS LCZ2, @@ -254,8 +254,8 @@ String identifyLczType(JdbcDataSource datasource, String rsuLczIndicators, Strin null AS LCZ_UNIQUENESS_VALUE, null AS LCZ_EQUALITY_VALUE FROM $urbanLCZ - WHERE AREA_FRACTION_HEAVY_INDUSTRY > AREA_FRACTION_LOWRISE_TYPO AND AREA_FRACTION_HEAVY_INDUSTRY>0.33 - OR AREA_FRACTION_LOWRISE_TYPO > AREA_FRACTION_RESIDENTIAL AND AREA_FRACTION_LOWRISE_TYPO>0.33 + WHERE AREA_FRACTION_HEAVY_INDUSTRY_LCZ > AREA_FRACTION_LOWRISE_TYPO AND AREA_FRACTION_HEAVY_INDUSTRY_LCZ>0.33 + OR AREA_FRACTION_LOWRISE_TYPO > AREA_FRACTION_RESIDENTIAL_LCZ AND AREA_FRACTION_LOWRISE_TYPO>0.33 AND AVG_NB_LEV_AREA_WEIGHTED < 3 AND LOW_VEGETATION_FRACTION_LCZ+HIGH_VEGETATION_FRACTION_LCZ<0.2 AND GROUND_SKY_VIEW_FACTOR > 0.7; diff --git a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicators.groovy b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicators.groovy index de05a252fc..4f159f9dfa 100644 --- a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicators.groovy +++ b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicators.groovy @@ -338,11 +338,14 @@ String computeBlockIndicators(JdbcDataSource datasource, String inputBuildingTab * of overlapped layers (for example a geometry containing water and low_vegetation must be either water * or either low_vegetation, not both (default ["water", "building", "high_vegetation", "low_vegetation", * "road", "impervious"] - * @param buildingAreaTypeAndComposition Building type proportion that should be calculated (default: ["light_industry": ["light_industry"], - * "heavy_industry": ["heavy_industry"], - * "commercial":["commercial"], - * "residential": ["residential"]]) - * @param floorAreaTypeAndComposition Building floor area type proportion that should be calculated (default: ["residential": ["residential"]]) + * @param buildingAreaTypeAndCompositionLcz Building type proportion that should be calculated for LCZ classification + * (see default value in the function signature) + * @param floorAreaTypeAndCompositionLcz Building floor area type proportion that should be calculated for LCZ classification + * (see default value in the function signature) + * @param buildingAreaTypeAndCompositionTeb Building type proportion that should be calculated for the TEB model + * (see default value in the function signature) + * @param floorAreaTypeAndCompositionTeb Building floor area type proportion that should be calculated for the TEB model + * (see default value in the function signature) * @param utrfSurfFraction Map containing as key the name of the fraction indicators useful for the urban typology classification * and as value a list of the fractions that have to be summed up to calculate the indicator. No need to modify * these values if not interested by the urban typology @@ -356,66 +359,125 @@ String computeBlockIndicators(JdbcDataSource datasource, String inputBuildingTab */ String computeRSUIndicators(JdbcDataSource datasource, String buildingTable, String rsu, String vegetation, String road, String water, String impervious, String rail, Map parameters = - [facadeDensListLayersBottom : [0, 10, 20, 30, 40, 50], - facadeDensNumberOfDirection : 12, - svfPointDensity : 0.008, - svfRayLength : 100, - svfNumberOfDirection : 60, - heightColumnName : "height_roof", - inputFields : ["id_build", "the_geom"], - levelForRoads : [0], - angleRangeSizeBuDirection : 30, - svfSimplified : true, - indicatorUse : ["LCZ", "UTRF", "TEB"], - surfSuperpositions : ["high_vegetation": ["water", "building", "low_vegetation", "rail", "road", "impervious"]], - surfPriorities : ["water", "building", "high_vegetation", "low_vegetation", "rail", "road", "impervious"], - buildingAreaTypeAndComposition: ["light_industry": ["light_industry"], - "heavy_industry": ["heavy_industry"], - "commercial" : ["commercial"], - "residential" : ["residential"]], - floorAreaTypeAndComposition : ["residential": ["residential"]], - utrfSurfFraction : ["vegetation_fraction_utrf" : ["high_vegetation_fraction", + [facadeDensListLayersBottom : [0, 10, 20, 30, 40, 50], + facadeDensNumberOfDirection : 12, + svfPointDensity : 0.008, + svfRayLength : 100, + svfNumberOfDirection : 60, + heightColumnName : "height_roof", + inputFields : ["id_build", "the_geom"], + levelForRoads : [0], + angleRangeSizeBuDirection : 30, + svfSimplified : true, + indicatorUse : ["LCZ", "UTRF", "TEB"], + surfSuperpositions : ["high_vegetation": ["water", "building", "low_vegetation", "rail", "road", "impervious"]], + surfPriorities : ["water", "building", "high_vegetation", "low_vegetation", "rail", "road", "impervious"], + buildingAreaTypeAndCompositionLcz : ["light_industry_lcz": ["industrial", "factory", "warehouse", "port"], + "commercial_lcz": ["commercial", "shop", "retail", "port", + "exhibition_centre", "cinema"], + "heavy_industry_lcz": ["refinery"], + "residential_lcz" : ["house", "detached", "bungalow", "farm", "apartments", "barracks", + "abbey", "condominium", "villa", "dormitory", "sheltered_housing", + "workers_dormitory", "terrace", "residential"]], + floorAreaTypeAndCompositionLcz : [:], + buildingAreaTypeAndCompositionTeb : ["individual_housing": ["house", "detached", "bungalow", "farm", "villa", "terrace"], + "collective_housing": [ "apartments","barracks","abbey", "dormitory", + "sheltered_housing", "workers_dormitory", + "condominium"], + "other_residential": ["residential"], + "commercial" : ["commercial","internet_cafe","money_transfer","pharmacy", + "post_office","cinema","arts_centre", "brothel", "casino", + "sustenance","hotel","restaurant","bar","cafe","fast_food", + "ice_cream","pub","aquarium"], + "tertiary" : [ "government", "townhall", "retail","gambling","music_venue", "nightclub", + "shop","store","supermarket","office","terminal","airport_terminal","bank", + "bureau_de_change","boat_rental","car_rental","research_institute", + "community_centre", "conference_centre","events_venue", + "exhibition_centre","social_centre","studio","theatre", + "library","healthcare","entertainment_arts_culture", + "hospital", "information"], + "education" : [ "education","swimming-pool", "fitness_centre","sports_centre", + "college","kindergarten","school","university","museum","gallery"], + "light_industrial" : ["industrial", "factory", "warehouse", "port"], + "heavy_industrial" : ["refinery"], + "non_heated" : [ "silo", "barn", "cowshed","ruins","church","chapel","military", + "castle","monument","fortress","synagogue","mosquee","musalla", + "shrine","cathedral", "agricultural", "farm_auxiliary","digester", + "horse_riding","stadium","track","pitch", "ice_rink","sports_hall", + "ammunition","bunker","casemate","shelter","religious","place_of_worship", + "wayside_shrine","station","stable","sty","greenhouse","kiosk","marketplace", + "marker","warehouse","planetarium","fire_station","water_tower","grandstand", + "transportation","toll_booth"]], + floorAreaTypeAndCompositionTeb : ["individual_housing": ["house", "detached", "bungalow", "farm", "villa", "terrace"], + "collective_housing": [ "apartments","barracks","abbey", "dormitory", + "sheltered_housing", "workers_dormitory", + "condominium", "residential"], + "other_residential": ["residential"], + "commercial" : ["commercial","internet_cafe","money_transfer","pharmacy", + "post_office","cinema","arts_centre", "brothel", "casino", + "sustenance","hotel","restaurant","bar","cafe","fast_food", + "ice_cream","pub","aquarium"], + "tertiary" : [ "government", "townhall", "retail","gambling","music_venue", "nightclub", + "shop","store","supermarket","office","terminal","airport_terminal","bank", + "bureau_de_change","boat_rental","car_rental","research_institute", + "community_centre", "conference_centre","events_venue", + "exhibition_centre","social_centre","studio","theatre", + "library","healthcare","entertainment_arts_culture", + "hospital", "information"], + "education" : [ "education","swimming-pool", "fitness_centre","sports_centre", + "college","kindergarten","school","university","museum","gallery"], + "light_industrial" : ["industrial", "factory", "warehouse", "port"], + "heavy_industrial" : ["refinery"], + "non_heated" : [ "silo", "barn", "cowshed","ruins","church","chapel","military", + "castle","monument","fortress","synagogue","mosquee","musalla", + "shrine","cathedral", "agricultural", "farm_auxiliary","digester", + "horse_riding","stadium","track","pitch", "ice_rink","sports_hall", + "ammunition","bunker","casemate","shelter","religious","place_of_worship", + "wayside_shrine","station","stable","sty","greenhouse","kiosk","marketplace", + "marker","warehouse","planetarium","fire_station","water_tower","grandstand", + "transportation","toll_booth"]], + utrfSurfFraction : ["vegetation_fraction_utrf" : ["high_vegetation_fraction", "low_vegetation_fraction", "high_vegetation_low_vegetation_fraction", "high_vegetation_road_fraction", "high_vegetation_impervious_fraction", "high_vegetation_water_fraction", "high_vegetation_building_fraction"], - "low_vegetation_fraction_utrf" : ["low_vegetation_fraction"], - "high_vegetation_impervious_fraction_utrf": ["high_vegetation_road_fraction", - "high_vegetation_impervious_fraction"], - "high_vegetation_pervious_fraction_utrf" : ["high_vegetation_fraction", - "high_vegetation_low_vegetation_fraction", - "high_vegetation_water_fraction"], - "road_fraction_utrf" : ["road_fraction", - "high_vegetation_road_fraction"], - "impervious_fraction_utrf" : ["road_fraction", - "high_vegetation_road_fraction", - "impervious_fraction", - "high_vegetation_impervious_fraction"]], - lczSurfFraction : ["building_fraction_lcz" : ["building_fraction", - "high_vegetation_building_fraction"], - "pervious_fraction_lcz" : ["high_vegetation_fraction", - "low_vegetation_fraction", - "water_fraction", - "high_vegetation_low_vegetation_fraction", - "high_vegetation_water_fraction"], - "high_vegetation_fraction_lcz": ["high_vegetation_fraction", - "high_vegetation_low_vegetation_fraction", - "high_vegetation_road_fraction", - "high_vegetation_impervious_fraction", - "high_vegetation_water_fraction", - "high_vegetation_building_fraction"], - "low_vegetation_fraction_lcz" : ["low_vegetation_fraction"], - "impervious_fraction_lcz" : ["impervious_fraction", - "road_fraction", - "rail_fraction", - "high_vegetation_impervious_fraction", - "high_vegetation_road_fraction", - "high_vegetation_rail_fraction"], - "water_fraction_lcz" : ["water_fraction", + "low_vegetation_fraction_utrf" : ["low_vegetation_fraction"], + "high_vegetation_impervious_fraction_utrf": ["high_vegetation_road_fraction", + "high_vegetation_impervious_fraction"], + "high_vegetation_pervious_fraction_utrf" : ["high_vegetation_fraction", + "high_vegetation_low_vegetation_fraction", + "high_vegetation_water_fraction"], + "road_fraction_utrf" : ["road_fraction", + "high_vegetation_road_fraction"], + "impervious_fraction_utrf" : ["road_fraction", + "high_vegetation_road_fraction", + "impervious_fraction", + "high_vegetation_impervious_fraction"]], + lczSurfFraction : ["building_fraction_lcz" : ["building_fraction", + "high_vegetation_building_fraction"], + "pervious_fraction_lcz" : ["high_vegetation_fraction", + "low_vegetation_fraction", + "water_fraction", + "high_vegetation_low_vegetation_fraction", + "high_vegetation_water_fraction"], + "high_vegetation_fraction_lcz": ["high_vegetation_fraction", + "high_vegetation_low_vegetation_fraction", + "high_vegetation_road_fraction", + "high_vegetation_impervious_fraction", + "high_vegetation_water_fraction", + "high_vegetation_building_fraction"], + "low_vegetation_fraction_lcz" : ["low_vegetation_fraction"], + "impervious_fraction_lcz" : ["impervious_fraction", + "road_fraction", + "rail_fraction", + "high_vegetation_impervious_fraction", + "high_vegetation_road_fraction", + "high_vegetation_rail_fraction"], + "water_fraction_lcz" : ["water_fraction", "high_vegetation_water_fraction"]], - buildingFractions : ["high_vegetation_building_fraction", "building_fraction"]], String prefixName = "") { + buildingFractions : ["high_vegetation_building_fraction", "building_fraction"]], String prefixName = "") { info "Start computing RSU indicators..." def to_start = System.currentTimeMillis() @@ -523,15 +585,25 @@ String computeRSUIndicators(JdbcDataSource datasource, String buildingTable, } // building type fractions - if (indicatorUse*.toUpperCase().contains("UTRF") || indicatorUse*.toUpperCase().contains("LCZ")) { - def rsuTableTypeProportion = Geoindicators.GenericIndicators.typeProportion(datasource, buildingTable, - columnIdRsu, "type", rsu, parameters.buildingAreaTypeAndComposition, - parameters.floorAreaTypeAndComposition, temporaryPrefName) - if (!rsuTableTypeProportion) { - info "Cannot compute the building type proportion of the RSU" + if (indicatorUse*.toUpperCase().contains("LCZ")) { + def rsuTableTypeProportionLcz = Geoindicators.GenericIndicators.typeProportion(datasource, buildingTable, + columnIdRsu, "type", rsu, parameters.buildingAreaTypeAndCompositionLcz, + parameters.floorAreaTypeAndCompositionLcz, temporaryPrefName + "_LCZ") + if (!rsuTableTypeProportionLcz) { + info "Cannot compute the building type proportion for the LCZ at the RSU scale" + return + } + finalTablesToJoin.put(rsuTableTypeProportionLcz, columnIdRsu) + } + if (indicatorUse*.toUpperCase().contains("UTRF") || indicatorUse*.toUpperCase().contains("TEB")) { + def rsuTableTypeProportionTeb = Geoindicators.GenericIndicators.typeProportion(datasource, buildingTable, + columnIdRsu, "type", rsu, parameters.buildingAreaTypeAndCompositionTeb, + parameters.floorAreaTypeAndCompositionTeb, temporaryPrefName + "_TEB") + if (!rsuTableTypeProportionTeb) { + info "Cannot compute the building type proportion for TEB at the RSU scale" return } - finalTablesToJoin.put(rsuTableTypeProportion, columnIdRsu) + finalTablesToJoin.put(rsuTableTypeProportionTeb, columnIdRsu) } // rsu_area (note that the uuid is used as prefix for intermediate tables - indicator alone in a table) @@ -1132,11 +1204,70 @@ Map getParameters() { "angleRangeSizeBuDirection" : 30, "surfSuperpositions" : ["high_vegetation": ["water", "building", "low_vegetation", "rail", "road", "impervious"]], "surfPriorities" : ["water", "building", "high_vegetation", "low_vegetation", "rail", "road", "impervious"], - "buildingAreaTypeAndComposition": ["light_industry": ["light_industry"], - "heavy_industry": ["heavy_industry"], - "commercial" : ["commercial"], - "residential" : ["residential"]], - "floorAreaTypeAndComposition" : ["residential": ["residential"]], + "buildingAreaTypeAndCompositionLcz" : ["light_industry_lcz": ["industrial", "factory", "warehouse", "port"], + "commercial_lcz": ["commercial", "shop", "retail", "port", + "exhibition_centre", "cinema"], + "heavy_industry_lcz": ["refinery"], + "residential_lcz" : ["house", "detached", "bungalow", "farm", "apartments", "barracks", + "abbey", "condominium", "villa", "dormitory", "sheltered_housing", + "workers_dormitory", "terrace", "residential"]], + "floorAreaTypeAndCompositionLcz" : [:], + "buildingAreaTypeAndCompositionTeb" : ["individual_housing": ["house", "detached", "bungalow", "farm", "villa", "terrace"], + "collective_housing": [ "apartments","barracks","abbey", "dormitory", + "sheltered_housing", "workers_dormitory", + "condominium", "residential"], + "other_residential": ["residential"], + "commercial" : ["commercial","internet_cafe","money_transfer","pharmacy", + "post_office","cinema","arts_centre", "brothel", "casino", + "sustenance","hotel","restaurant","bar","cafe","fast_food", + "ice_cream","pub","aquarium"], + "tertiary" : [ "government", "townhall", "retail","gambling","music_venue", "nightclub", + "shop","store","supermarket","office","terminal","airport_terminal","bank", + "bureau_de_change","boat_rental","car_rental","research_institute", + "community_centre", "conference_centre","events_venue", + "exhibition_centre","social_centre","studio","theatre", + "library","healthcare","entertainment_arts_culture", + "hospital", "information"], + "education" : [ "education","swimming-pool", "fitness_centre","sports_centre", + "college","kindergarten","school","university","museum","gallery"], + "light_industrial" : ["industrial", "factory", "warehouse", "port"], + "heavy_industrial" : ["refinery"], + "non_heated" : [ "silo", "barn", "cowshed","ruins","church","chapel","military", + "castle","monument","fortress","synagogue","mosquee","musalla", + "shrine","cathedral", "agricultural", "farm_auxiliary","digester", + "horse_riding","stadium","track","pitch", "ice_rink","sports_hall", + "ammunition","bunker","casemate","shelter","religious","place_of_worship", + "wayside_shrine","station","stable","sty","greenhouse","kiosk","marketplace", + "marker","warehouse","planetarium","fire_station","water_tower","grandstand", + "transportation","toll_booth"]], + "floorAreaTypeAndCompositionTeb" : ["individual_housing": ["house", "detached", "bungalow", "farm", "villa", "terrace"], + "collective_housing": [ "apartments","barracks","abbey", "dormitory", + "sheltered_housing", "workers_dormitory", + "condominium", "residential"], + "other_residential": ["residential"], + "commercial" : ["commercial","internet_cafe","money_transfer","pharmacy", + "post_office","cinema","arts_centre", "brothel", "casino", + "sustenance","hotel","restaurant","bar","cafe","fast_food", + "ice_cream","pub","aquarium"], + "tertiary" : [ "government", "townhall", "retail","gambling","music_venue", "nightclub", + "shop","store","supermarket","office","terminal","airport_terminal","bank", + "bureau_de_change","boat_rental","car_rental","research_institute", + "community_centre", "conference_centre","events_venue", + "exhibition_centre","social_centre","studio","theatre", + "library","healthcare","entertainment_arts_culture", + "hospital", "information"], + "education" : [ "education","swimming-pool", "fitness_centre","sports_centre", + "college","kindergarten","school","university","museum","gallery"], + "light_industrial" : ["industrial", "factory", "warehouse", "port"], + "heavy_industrial" : ["refinery"], + "non_heated" : [ "silo", "barn", "cowshed","ruins","church","chapel","military", + "castle","monument","fortress","synagogue","mosquee","musalla", + "shrine","cathedral", "agricultural", "farm_auxiliary","digester", + "horse_riding","stadium","track","pitch", "ice_rink","sports_hall", + "ammunition","bunker","casemate","shelter","religious","place_of_worship", + "wayside_shrine","station","stable","sty","greenhouse","kiosk","marketplace", + "marker","warehouse","planetarium","fire_station","water_tower","grandstand", + "transportation","toll_booth"]], "utrfSurfFraction" : ["vegetation_fraction_utrf" : ["high_vegetation_fraction", "low_vegetation_fraction", "high_vegetation_low_vegetation_fraction", diff --git a/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy b/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy index b3b1749238..2440e031e6 100644 --- a/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy +++ b/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy @@ -66,7 +66,14 @@ class WorkflowGeoIndicatorsTest { "NON_VERT_ROOF_AREA_H0_10", "NON_VERT_ROOF_AREA_H10_20", "NON_VERT_ROOF_AREA_H20_30", "NON_VERT_ROOF_AREA_H30_40", "NON_VERT_ROOF_AREA_H40_50", "NON_VERT_ROOF_AREA_H50", "VERT_ROOF_AREA_H0_10", "VERT_ROOF_AREA_H10_20", "VERT_ROOF_AREA_H20_30", "VERT_ROOF_AREA_H30_40", - "VERT_ROOF_AREA_H40_50", "VERT_ROOF_AREA_H50", "EFFECTIVE_TERRAIN_ROUGHNESS_LENGTH"], + "VERT_ROOF_AREA_H40_50", "VERT_ROOF_AREA_H50", "EFFECTIVE_TERRAIN_ROUGHNESS_LENGTH", + "AREA_FRACTION_INDIVIDUAL_HOUSING", "AREA_FRACTION_COLLECTIVE_HOUSING", + "AREA_FRACTION_OTHER_RESIDENTIAL", "AREA_FRACTION_COMMERCIAL", "AREA_FRACTION_TERTIARY", "AREA_FRACTION_EDUCATION", + "AREA_FRACTION_LIGHT_INDUSTRIAL", "AREA_FRACTION_HEAVY_INDUSTRIAL", "AREA_FRACTION_NON_HEATED", + "FLOOR_AREA_FRACTION_INDIVIDUAL_HOUSING", "FLOOR_AREA_FRACTION_COLLECTIVE_HOUSING", + "FLOOR_AREA_FRACTION_OTHER_RESIDENTIAL", "FLOOR_AREA_FRACTION_COMMERCIAL", "FLOOR_AREA_FRACTION_TERTIARY", + "FLOOR_AREA_FRACTION_EDUCATION", "FLOOR_AREA_FRACTION_LIGHT_INDUSTRIAL", "FLOOR_AREA_FRACTION_HEAVY_INDUSTRIAL", + "FLOOR_AREA_FRACTION_NON_HEATED"], "UTRF": ["AREA", "ASPECT_RATIO", "BUILDING_TOTAL_FRACTION", "FREE_EXTERNAL_FACADE_DENSITY", "VEGETATION_FRACTION_UTRF", "LOW_VEGETATION_FRACTION_UTRF", "HIGH_VEGETATION_IMPERVIOUS_FRACTION_UTRF", "HIGH_VEGETATION_PERVIOUS_FRACTION_UTRF", "ROAD_FRACTION_UTRF", "IMPERVIOUS_FRACTION_UTRF", @@ -75,11 +82,17 @@ class WorkflowGeoIndicatorsTest { "BUILDING_VOLUME_DENSITY", "AVG_VOLUME", "GROUND_LINEAR_ROAD_DENSITY", "GEOM_AVG_HEIGHT_ROOF", "BUILDING_FLOOR_AREA_DENSITY", "AVG_MINIMUM_BUILDING_SPACING", "MAIN_BUILDING_DIRECTION", "BUILDING_DIRECTION_UNIQUENESS", - "BUILDING_DIRECTION_EQUALITY", "AREA_FRACTION_LIGHT_INDUSTRY", "FLOOR_AREA_FRACTION_RESIDENTIAL"], + "BUILDING_DIRECTION_EQUALITY", "AREA_FRACTION_INDIVIDUAL_HOUSING", "AREA_FRACTION_COLLECTIVE_HOUSING", + "AREA_FRACTION_OTHER_RESIDENTIAL", "AREA_FRACTION_COMMERCIAL", "AREA_FRACTION_TERTIARY", "AREA_FRACTION_EDUCATION", + "AREA_FRACTION_LIGHT_INDUSTRIAL", "AREA_FRACTION_HEAVY_INDUSTRIAL", "AREA_FRACTION_NON_HEATED", + "FLOOR_AREA_FRACTION_INDIVIDUAL_HOUSING", "FLOOR_AREA_FRACTION_COLLECTIVE_HOUSING", + "FLOOR_AREA_FRACTION_OTHER_RESIDENTIAL", "FLOOR_AREA_FRACTION_COMMERCIAL", "FLOOR_AREA_FRACTION_TERTIARY", + "FLOOR_AREA_FRACTION_EDUCATION", "FLOOR_AREA_FRACTION_LIGHT_INDUSTRIAL", "FLOOR_AREA_FRACTION_HEAVY_INDUSTRIAL", + "FLOOR_AREA_FRACTION_NON_HEATED"], "LCZ" : ["BUILDING_FRACTION_LCZ", "ASPECT_RATIO", "GROUND_SKY_VIEW_FACTOR", "PERVIOUS_FRACTION_LCZ", "IMPERVIOUS_FRACTION_LCZ", "GEOM_AVG_HEIGHT_ROOF", "EFFECTIVE_TERRAIN_ROUGHNESS_LENGTH", "EFFECTIVE_TERRAIN_ROUGHNESS_CLASS", - "HIGH_VEGETATION_FRACTION_LCZ", "LOW_VEGETATION_FRACTION_LCZ", "WATER_FRACTION_LCZ", "AREA_FRACTION_LIGHT_INDUSTRY", - "FLOOR_AREA_FRACTION_RESIDENTIAL"]] + "HIGH_VEGETATION_FRACTION_LCZ", "LOW_VEGETATION_FRACTION_LCZ", "WATER_FRACTION_LCZ", "AREA_FRACTION_LIGHT_INDUSTRY_LCZ", + "AREA_FRACTION_COMMERCIAL_LCZ", "AREA_FRACTION_HEAVY_INDUSTRY_LCZ", "AREA_FRACTION_RESIDENTIAL_LCZ"]] // Basic columns at RSU scale public static listColBasic = ["ID_RSU", "THE_GEOM"] @@ -109,6 +122,7 @@ class WorkflowGeoIndicatorsTest { @BeforeAll static void beforeAll() { + // folder = new File("/tmp") datasource = open(folder.getAbsolutePath() + File.separator + "workflowGeoIndicatorsTest;AUTO_SERVER=TRUE") assertNotNull(datasource) datasource.load(WorkflowGeoIndicatorsTest.getResource("BUILDING.geojson"), "BUILDING", true) diff --git a/geoindicators/src/test/resources/org/orbisgis/geoclimate/geoindicators/data_for_tests.sql b/geoindicators/src/test/resources/org/orbisgis/geoclimate/geoindicators/data_for_tests.sql index 75c48f0ed7..be8f261054 100644 --- a/geoindicators/src/test/resources/org/orbisgis/geoclimate/geoindicators/data_for_tests.sql +++ b/geoindicators/src/test/resources/org/orbisgis/geoclimate/geoindicators/data_for_tests.sql @@ -29,9 +29,9 @@ CREATE TABLE rsu_test_all_indics_for_lcz(id_rsu int, sky_view_factor float, aspe IMPERVIOUS_FRACTION_LCZ float, PERVIOUS_FRACTION_LCZ float, GEOM_AVG_HEIGHT_ROOF float, EFFECTIVE_TERRAIN_ROUGHNESS_LENGTH float, HIGH_VEGETATION_FRACTION_LCZ float, LOW_VEGETATION_FRACTION_LCZ float, WATER_FRACTION_LCZ float, IMPERVIOUS_FRACTION float, - AREA_FRACTION_HEAVY_INDUSTRY float, AREA_FRACTION_COMMERCIAL float, - AREA_FRACTION_RESIDENTIAL float, AVG_NB_LEV_AREA_WEIGHTED float, - GROUND_SKY_VIEW_FACTOR float, AREA_FRACTION_LIGHT_INDUSTRY float); + AREA_FRACTION_HEAVY_INDUSTRY_LCZ float, AREA_FRACTION_COMMERCIAL_LCZ float, + AREA_FRACTION_RESIDENTIAL_LCZ float, AVG_NB_LEV_AREA_WEIGHTED float, + GROUND_SKY_VIEW_FACTOR float, AREA_FRACTION_LIGHT_INDUSTRY_LCZ float); INSERT INTO building_test VALUES (1, 1, 1, 0, 'POLYGON((4 4, 10 4, 10 30, 4 30, 4 4))'::GEOMETRY, 8, 8, 156, 64, 2, 64, 0, 0, 'industrial'), (2, 2, 1, 0, 'POLYGON((12 4, 20 4, 20 9, 12 9, 12 4))'::GEOMETRY, 10, 13, 40, 26, 3, 26, 0, 0, 'detached'), From 8cc47fb7d6f78d52e35cb828004a79f236f14c35 Mon Sep 17 00:00:00 2001 From: BERNARD Jeremy Date: Mon, 18 Mar 2024 11:51:02 +0100 Subject: [PATCH 05/12] Start modifying the way indicators are created --- .../geoindicators/RsuIndicators.groovy | 18 +++++++++++++++--- .../geoindicators/WorkflowGeoIndicators.groovy | 4 +++- .../WorkflowGeoIndicatorsTest.groovy | 12 ++++++++++-- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicators.groovy b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicators.groovy index 92c1cc9c0f..0ee83ac9e1 100644 --- a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicators.groovy +++ b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicators.groovy @@ -994,7 +994,7 @@ String linearRoadOperations(JdbcDataSource datasource, String rsuTable, String r for (int d = angleRangeSize; d <= 180; d += angleRangeSize) { caseQueryDistrib += "SUM(CASEWHEN(azimuth>=${d - angleRangeSize} AND azimuth<$d, length, 0)) AS " + "road_direction_distribution_d${d - angleRangeSize}_$d," - nameDistrib.add("road_direction_distribution_d${d - angleRangeSize}_$d") + nameDistrib.add(getRoadDirIndic(d, angleRangeSize, null as Integer)) } } // If only certain levels are considered independently @@ -1009,8 +1009,7 @@ String linearRoadOperations(JdbcDataSource datasource, String rsuTable, String r "zindex = $lev, length, 0)) AS " + "road_direction_distribution_h${lev.toString().replaceAll("-", "minus")}" + "_d${d - angleRangeSize}_$d," - nameDistrib.add("road_direction_distribution_h${lev.toString().replaceAll("-", "minus")}" + - "_d${d - angleRangeSize}_$d") + nameDistrib.add(getRoadDirIndic(d, angleRangeSize, lev as Integer)) } } } @@ -1086,6 +1085,19 @@ String linearRoadOperations(JdbcDataSource datasource, String rsuTable, String r } } +String getRoadDirIndic(int d, int angleRangeSize, int lev){ + String name + if(!lev){ + name = "road_direction_distribution_d${d - angleRangeSize}_$d" + } + else{ + name = "road_direction_distribution_h${lev.toString().replaceAll("-", "minus")}" + + "_d${d - angleRangeSize}_$d" + } + + return name +} + /** * Script to compute the effective terrain class from the terrain roughness length (z0). * The classes are defined according to the Davenport lookup Table (cf Table 5 in Stewart and Oke, 2012) diff --git a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicators.groovy b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicators.groovy index 4f159f9dfa..5600e43d12 100644 --- a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicators.groovy +++ b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicators.groovy @@ -368,6 +368,7 @@ String computeRSUIndicators(JdbcDataSource datasource, String buildingTable, inputFields : ["id_build", "the_geom"], levelForRoads : [0], angleRangeSizeBuDirection : 30, + angleRangeSizeRoDirection : 30, svfSimplified : true, indicatorUse : ["LCZ", "UTRF", "TEB"], surfSuperpositions : ["high_vegetation": ["water", "building", "low_vegetation", "rail", "road", "impervious"]], @@ -681,7 +682,7 @@ String computeRSUIndicators(JdbcDataSource datasource, String buildingTable, roadOperations = ["road_direction_distribution", "linear_road_density"] } def linearRoadOperations = Geoindicators.RsuIndicators.linearRoadOperations(datasource, rsu, - road, roadOperations, 30, [0], temporaryPrefName) + road, roadOperations, parameters.angleRangeSizeRoDirection, [0], temporaryPrefName) if (!linearRoadOperations) { info "Cannot compute the linear road density and road direction distribution" return @@ -1202,6 +1203,7 @@ Map getParameters() { "inputFields" : ["id_build", "the_geom"], "levelForRoads" : [0], "angleRangeSizeBuDirection" : 30, + "angleRangeSizeRoDirection" : 30, "surfSuperpositions" : ["high_vegetation": ["water", "building", "low_vegetation", "rail", "road", "impervious"]], "surfPriorities" : ["water", "building", "high_vegetation", "low_vegetation", "rail", "road", "impervious"], "buildingAreaTypeAndCompositionLcz" : ["light_industry_lcz": ["industrial", "factory", "warehouse", "port"], diff --git a/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy b/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy index 2440e031e6..144f983c6c 100644 --- a/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy +++ b/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy @@ -39,10 +39,18 @@ class WorkflowGeoIndicatorsTest { public static Logger logger = LoggerFactory.getLogger(WorkflowGeoIndicatorsTest.class) + // Default geoindicator parameters + public static parameters = Geoindicators.WorkflowGeoIndicators.getParameters() + // Indicator list (at RSU scale) for each type of use + public static List listRoadDir = [] + for (int d = parameters.angleRangeSizeRoDirection; d <= 180; d += angleRangeSize) { + listRoadDir.add(Geoindicators.RsuIndicators.getRoadDirIndic(parameters.angleRangeSizeRoDirection, d, 0)) + } public static listNames = [ - "TEB" : ["VERT_ROOF_DENSITY", "NON_VERT_ROOF_DENSITY", - "ROAD_DIRECTION_DISTRIBUTION_H0_D0_30", "ROAD_DIRECTION_DISTRIBUTION_H0_D60_90", + "TEB" : ["VERT_ROOF_DENSITY", "NON_VERT_ROOF_DENSITY"] + + listRoadDir + + ["ROAD_DIRECTION_DISTRIBUTION_H0_D0_30", "ROAD_DIRECTION_DISTRIBUTION_H0_D60_90", "ROAD_DIRECTION_DISTRIBUTION_H0_D90_120", "ROAD_DIRECTION_DISTRIBUTION_H0_D120_150", "ROAD_DIRECTION_DISTRIBUTION_H0_D150_180", "ROAD_DIRECTION_DISTRIBUTION_H0_D30_60", "PROJECTED_FACADE_AREA_DISTRIBUTION_H0_10_D0_30", "PROJECTED_FACADE_AREA_DISTRIBUTION_H10_20_D0_30", From 9a1861bf5f757322c3397d6f6ac137bbbc1237dc Mon Sep 17 00:00:00 2001 From: jeremy Date: Mon, 18 Mar 2024 16:10:51 +0100 Subject: [PATCH 06/12] Add functions to create more generic names --- .../geoindicators/RsuIndicators.groovy | 52 +++++---- .../WorkflowGeoIndicators.groovy | 2 +- .../WorkflowGeoIndicatorsTest.groovy | 102 ++++++++++-------- 3 files changed, 89 insertions(+), 67 deletions(-) diff --git a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicators.groovy b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicators.groovy index 0ee83ac9e1..31314a32d4 100644 --- a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicators.groovy +++ b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicators.groovy @@ -482,8 +482,7 @@ String projectedFacadeAreaDistribution(JdbcDataSource datasource, String buildin def layerQuery = "DROP TABLE IF EXISTS $buildingLayer; " + "CREATE TABLE $buildingLayer AS SELECT the_geom, " for (i in 1..(listLayersBottom.size() - 1)) { - names[i - 1] = "${BASE_NAME}_H${listLayersBottom[i - 1]}" + - "_${listLayersBottom[i]}" + names.add(getDistribIndicName(BASE_NAME, 'H', listLayersBottom[i - 1], listLayersBottom[i])) layerQuery += "CASEWHEN(z_max <= ${listLayersBottom[i - 1]}, 0, " + "CASEWHEN(z_min >= ${listLayersBottom[i]}, " + "0, ${listLayersBottom[i] - listLayersBottom[i - 1]}-" + @@ -492,8 +491,7 @@ String projectedFacadeAreaDistribution(JdbcDataSource datasource, String buildin } // ...and for the final level - names[listLayersBottom.size() - 1] = "$BASE_NAME" + - "_H${listLayersBottom[listLayersBottom.size() - 1]}" + names.add(getDistribIndicName(BASE_NAME, 'H', listLayersBottom[listLayersBottom.size() - 1], null)) layerQuery += "CASEWHEN(z_max >= ${listLayersBottom[listLayersBottom.size() - 1]}, " + "z_max-GREATEST(z_min,${listLayersBottom[listLayersBottom.size() - 1]}), 0) " + "AS ${names[listLayersBottom.size() - 1]} FROM $buildingFree" @@ -532,24 +530,24 @@ String projectedFacadeAreaDistribution(JdbcDataSource datasource, String buildin def sumNamesDir = [] def queryColumns = [] for (int d = 0; d < numberOfDirection / 2; d++) { - def dirDeg = d * 360 / numberOfDirection + Integer dirDeg = d * 360 / numberOfDirection def dirRad = toRadians(dirDeg) - def rangeDeg = 360 / numberOfDirection + Integer rangeDeg = 360 / numberOfDirection def dirRadMid = dirRad + dirMedRad def dirDegMid = dirDeg + dirMedDeg // Define the field name for each of the directions and vertical layers names.each { - namesAndTypeDir += " " + it + "_D${dirDeg}_${dirDeg + rangeDeg} double" + namesAndTypeDir += " " + "${getDistribIndicName(it, 'D', dirDeg, dirDeg + rangeDeg)} double" queryColumns += """CASE WHEN a.azimuth-$dirRadMid>PI()/2 THEN a.$it*a.length*COS(a.azimuth-$dirRadMid-PI()/2)/2 WHEN a.azimuth-$dirRadMid<-PI()/2 THEN a.$it*a.length*COS(a.azimuth-$dirRadMid+PI()/2)/2 ELSE a.$it*a.length*ABS(SIN(a.azimuth-$dirRadMid))/2 - END AS ${it}_D${dirDeg}_${dirDeg + rangeDeg}""" + END AS ${getDistribIndicName(it, 'D', dirDeg, dirDeg + rangeDeg)}""" onlyNamesDir += "${it}_D${dirDeg}_${dirDeg + rangeDeg}" sumNamesDir += "COALESCE(SUM(b.${it}_D${dirDeg}_${dirDeg + rangeDeg}), 0) " + - "AS ${it}_D${dirDeg}_${dirDeg + rangeDeg} " + "AS ${getDistribIndicName(it, 'D', dirDeg, dirDeg + rangeDeg)}" } } namesAndTypeDir = namesAndTypeDir.join(",") @@ -584,6 +582,18 @@ String projectedFacadeAreaDistribution(JdbcDataSource datasource, String buildin return outputTableName } +String getDistribIndicName(String base_name, String var_type, Integer lev_bot, Integer lev_up){ + String name + if (lev_up == null){ + name = "${base_name}_${var_type}${lev_bot}" + } + else{ + name = "${base_name}_${var_type}${lev_bot}_${lev_up}" + } + + return name +} + /** * Script to compute both the roof (vertical, horizontal and tilted) * - area within each vertical layer of a RSU. @@ -755,8 +765,8 @@ String roofAreaDistribution(JdbcDataSource datasource, String rsu, String buildi "a.z_max <= ${listLayersBottom[i]}, CASEWHEN(a.delta_h=0, a.non_vertical_roof_area, " + "a.non_vertical_roof_area*(a.z_max-GREATEST(${listLayersBottom[i - 1]},a.z_min))/a.delta_h), " + "CASEWHEN(a.z_min < ${listLayersBottom[i]}, a.non_vertical_roof_area*(${listLayersBottom[i]}-" + - "GREATEST(${listLayersBottom[i - 1]},a.z_min))/a.delta_h, 0)))),0) AS non_vert_roof_area_H" + - "${listLayersBottom[i - 1]}_${listLayersBottom[i]}," + "GREATEST(${listLayersBottom[i - 1]},a.z_min))/a.delta_h, 0)))),0) AS " + + "${getDistribIndicName('non_vert_roof_area', 'H', listLayersBottom[i - 1], listLayersBottom[i])}," vertQuery += " COALESCE(SUM(CASEWHEN(a.z_max <= ${listLayersBottom[i - 1]}, 0, CASEWHEN(" + "a.z_max <= ${listLayersBottom[i]}, CASEWHEN(a.delta_h=0, 0, " + "a.vertical_roof_area*POWER((a.z_max-GREATEST(${listLayersBottom[i - 1]}," + @@ -764,16 +774,16 @@ String roofAreaDistribution(JdbcDataSource datasource, String rsu, String buildi "CASEWHEN(a.z_min>${listLayersBottom[i - 1]}, a.vertical_roof_area*(1-" + "POWER((a.z_max-${listLayersBottom[i]})/a.delta_h,2)),a.vertical_roof_area*(" + "POWER((a.z_max-${listLayersBottom[i - 1]})/a.delta_h,2)-POWER((a.z_max-${listLayersBottom[i]})/" + - "a.delta_h,2))), 0)))),0) AS vert_roof_area_H${listLayersBottom[i - 1]}_${listLayersBottom[i]}," + "a.delta_h,2))), 0)))),0) AS ${getDistribIndicName('vert_roof_area', 'H', listLayersBottom[i - 1], listLayersBottom[i])}," } // The roof area is calculated for the last level (> 50 m in the default case) def valueLastLevel = listLayersBottom[listLayersBottom.size() - 1] nonVertQuery += " COALESCE(SUM(CASEWHEN(a.z_max <= $valueLastLevel, 0, CASEWHEN(a.delta_h=0, a.non_vertical_roof_area, " + - "a.non_vertical_roof_area*(a.z_max-GREATEST($valueLastLevel,a.z_min))/a.delta_h))),0) AS non_vert_roof_area_H" + - "${valueLastLevel}," + "a.non_vertical_roof_area*(a.z_max-GREATEST($valueLastLevel,a.z_min))/a.delta_h))),0) AS " + + "${getDistribIndicName('non_vert_roof_area', 'H', valueLastLevel, null)}," vertQuery += " COALESCE(SUM(CASEWHEN(a.z_max <= $valueLastLevel, 0, CASEWHEN(a.delta_h=0, a.vertical_roof_area, " + - "a.vertical_roof_area*(a.z_max-GREATEST($valueLastLevel,a.z_min))/a.delta_h))),0) AS vert_roof_area_H" + - "${valueLastLevel}," + "a.vertical_roof_area*(a.z_max-GREATEST($valueLastLevel,a.z_min))/a.delta_h))),0) " + + "${getDistribIndicName('vert_roof_area', 'H', valueLastLevel, null)}," def endQuery = """ FROM $buildRoofSurfTot a RIGHT JOIN $rsu b ON a.id_rsu = b.id_rsu GROUP BY b.id_rsu;""" @@ -790,11 +800,11 @@ String roofAreaDistribution(JdbcDataSource datasource, String rsu, String buildi def optionalVert = "(" for (i in 1..(listLayersBottom.size() - 1)) { - optionalNonVert += " a.non_vert_roof_area_H${listLayersBottom[i - 1]}_${listLayersBottom[i]} + " - optionalVert += "a.vert_roof_area_H${listLayersBottom[i - 1]}_${listLayersBottom[i]} + " + optionalNonVert += " a.${getDistribIndicName('non_vert_roof_area', 'H', listLayersBottom[i - 1], listLayersBottom[i])} + " + optionalVert += "a.${getDistribIndicName('vert_roof_area', 'H', listLayersBottom[i - 1], listLayersBottom[i])} + " } - optionalNonVert += "a.non_vert_roof_area_H$valueLastLevel) / ST_AREA(b.$GEOMETRIC_COLUMN_RSU)" - optionalVert += "a.vert_roof_area_H${valueLastLevel}) / ST_AREA(b.$GEOMETRIC_COLUMN_RSU)" + optionalNonVert += "a.${getDistribIndicName('non_vert_roof_area', 'H', valueLastLevel, null)}) / ST_AREA(b.$GEOMETRIC_COLUMN_RSU)" + optionalVert += "a.${getDistribIndicName('vert_roof_area', 'H', valueLastLevel, null)}) / ST_AREA(b.$GEOMETRIC_COLUMN_RSU)" optionalQuery += "$optionalNonVert AS VERT_ROOF_DENSITY, $optionalVert AS NON_VERT_ROOF_DENSITY" + " FROM $optionalTempo a RIGHT JOIN $rsu b ON a.$ID_COLUMN_RSU = b.$ID_COLUMN_RSU;" @@ -1087,7 +1097,7 @@ String linearRoadOperations(JdbcDataSource datasource, String rsuTable, String r String getRoadDirIndic(int d, int angleRangeSize, int lev){ String name - if(!lev){ + if(lev == null){ name = "road_direction_distribution_d${d - angleRangeSize}_$d" } else{ diff --git a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicators.groovy b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicators.groovy index 5600e43d12..c31e4eb788 100644 --- a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicators.groovy +++ b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicators.groovy @@ -596,7 +596,7 @@ String computeRSUIndicators(JdbcDataSource datasource, String buildingTable, } finalTablesToJoin.put(rsuTableTypeProportionLcz, columnIdRsu) } - if (indicatorUse*.toUpperCase().contains("UTRF") || indicatorUse*.toUpperCase().contains("TEB")) { + if (indicatorUse*.toUpperCase().contains("TEB")) { def rsuTableTypeProportionTeb = Geoindicators.GenericIndicators.typeProportion(datasource, buildingTable, columnIdRsu, "type", rsu, parameters.buildingAreaTypeAndCompositionTeb, parameters.floorAreaTypeAndCompositionTeb, temporaryPrefName + "_TEB") diff --git a/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy b/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy index 144f983c6c..0206d79980 100644 --- a/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy +++ b/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy @@ -42,46 +42,65 @@ class WorkflowGeoIndicatorsTest { // Default geoindicator parameters public static parameters = Geoindicators.WorkflowGeoIndicators.getParameters() - // Indicator list (at RSU scale) for each type of use + // Indicator list (at RSU scale) for each road direction public static List listRoadDir = [] - for (int d = parameters.angleRangeSizeRoDirection; d <= 180; d += angleRangeSize) { - listRoadDir.add(Geoindicators.RsuIndicators.getRoadDirIndic(parameters.angleRangeSizeRoDirection, d, 0)) + static { + for (int d = parameters.angleRangeSizeRoDirection; d <= 180; d += parameters.angleRangeSizeRoDirection) { + listRoadDir.add(Geoindicators.RsuIndicators.getRoadDirIndic(parameters.angleRangeSizeRoDirection, d, 0)) + } + } + // Indicator list (at RSU scale) for each facade direction and height (projected facade distrib) + // and also for height only (vert and non vert roof density) + public static List listFacadeDistrib = [] + public static List listHeightDistrib = [] + + static { + int rangeDeg = 360 / parameters.angleRangeSizeRoDirection + for (i in 0..parameters.facadeDensListLayersBottom.size()) { + Integer h_bot = parameters.facadeDensListLayersBottom[i] + Integer h_up + if (h_bot == parameters.facadeDensListLayersBottom[-1]){ + h_up = null + } + else{ + h_up = parameters.facadeDensListLayersBottom[i+1] + } + // Create names for vert and non vert roof density + listHeightDistrib.add(Geoindicators.RsuIndicators.getDistribIndicName("vert_roof_area", 'h', h_bot, h_up)) + listHeightDistrib.add(Geoindicators.RsuIndicators.getDistribIndicName("non_vert_roof_area", 'h', h_bot, h_up)) + + // Create names for facade density + String name_h = Geoindicators.RsuIndicators.getDistribIndicName("projected_facade_area_distribution", 'h', h_bot, h_up) + for (Integer d = 0; d < parameters.facadeDensNumberOfDirection / 2; d++){ + Integer d_bot = d * 360 / parameters.facadeDensNumberOfDirection + Integer d_up = d_bot + rangeDeg + listFacadeDistrib.add(Geoindicators.RsuIndicators.getDistribIndicName(name_h, 'd', d_bot, d_up)) + } + } + } + + // Indicator list (at RSU scale) for each type of use + public static List listBuildTypTeb = [] + public static List listBuildTypLcz = [] + static { + for (type in parameters.buildingAreaTypeAndCompositionTeb.keySet()) { + listBuildTypTeb.add("AREA_FRACTION_${type}") + } + for (type in parameters.floorAreaTypeAndCompositionTeb.keySet()) { + listBuildTypTeb.add("FLOOR_AREA_FRACTION_${type}") + } + for (type in parameters.buildingAreaTypeAndCompositionLcz.keySet()) { + listBuildTypLcz.add("AREA_FRACTION_${type}") + } + for (type in parameters.floorAreaTypeAndCompositionLcz.keySet()) { + listBuildTypLcz.add("FLOOR_AREA_FRACTION_${type}") + } } + public static listNames = [ "TEB" : ["VERT_ROOF_DENSITY", "NON_VERT_ROOF_DENSITY"] + - listRoadDir + - ["ROAD_DIRECTION_DISTRIBUTION_H0_D0_30", "ROAD_DIRECTION_DISTRIBUTION_H0_D60_90", - "ROAD_DIRECTION_DISTRIBUTION_H0_D90_120", "ROAD_DIRECTION_DISTRIBUTION_H0_D120_150", - "ROAD_DIRECTION_DISTRIBUTION_H0_D150_180", "ROAD_DIRECTION_DISTRIBUTION_H0_D30_60", - "PROJECTED_FACADE_AREA_DISTRIBUTION_H0_10_D0_30", "PROJECTED_FACADE_AREA_DISTRIBUTION_H10_20_D0_30", - "PROJECTED_FACADE_AREA_DISTRIBUTION_H20_30_D0_30", "PROJECTED_FACADE_AREA_DISTRIBUTION_H30_40_D0_30", - "PROJECTED_FACADE_AREA_DISTRIBUTION_H40_50_D0_30", "PROJECTED_FACADE_AREA_DISTRIBUTION_H50_D0_30", - "PROJECTED_FACADE_AREA_DISTRIBUTION_H0_10_D30_60", "PROJECTED_FACADE_AREA_DISTRIBUTION_H10_20_D30_60", - "PROJECTED_FACADE_AREA_DISTRIBUTION_H20_30_D30_60", "PROJECTED_FACADE_AREA_DISTRIBUTION_H30_40_D30_60", - "PROJECTED_FACADE_AREA_DISTRIBUTION_H40_50_D30_60", "PROJECTED_FACADE_AREA_DISTRIBUTION_H50_D30_60", - "PROJECTED_FACADE_AREA_DISTRIBUTION_H0_10_D60_90", "PROJECTED_FACADE_AREA_DISTRIBUTION_H10_20_D60_90", - "PROJECTED_FACADE_AREA_DISTRIBUTION_H20_30_D60_90", "PROJECTED_FACADE_AREA_DISTRIBUTION_H30_40_D60_90", - "PROJECTED_FACADE_AREA_DISTRIBUTION_H40_50_D60_90", "PROJECTED_FACADE_AREA_DISTRIBUTION_H50_D60_90", - "PROJECTED_FACADE_AREA_DISTRIBUTION_H0_10_D90_120", "PROJECTED_FACADE_AREA_DISTRIBUTION_H10_20_D90_120", - "PROJECTED_FACADE_AREA_DISTRIBUTION_H20_30_D90_120", "PROJECTED_FACADE_AREA_DISTRIBUTION_H30_40_D90_120", - "PROJECTED_FACADE_AREA_DISTRIBUTION_H40_50_D90_120", "PROJECTED_FACADE_AREA_DISTRIBUTION_H50_D90_120", - "PROJECTED_FACADE_AREA_DISTRIBUTION_H0_10_D120_150", "PROJECTED_FACADE_AREA_DISTRIBUTION_H10_20_D120_150", - "PROJECTED_FACADE_AREA_DISTRIBUTION_H20_30_D120_150", "PROJECTED_FACADE_AREA_DISTRIBUTION_H30_40_D120_150", - "PROJECTED_FACADE_AREA_DISTRIBUTION_H40_50_D120_150", "PROJECTED_FACADE_AREA_DISTRIBUTION_H50_D120_150", - "PROJECTED_FACADE_AREA_DISTRIBUTION_H0_10_D150_180", "PROJECTED_FACADE_AREA_DISTRIBUTION_H10_20_D150_180", - "PROJECTED_FACADE_AREA_DISTRIBUTION_H20_30_D150_180", "PROJECTED_FACADE_AREA_DISTRIBUTION_H30_40_D150_180", - "PROJECTED_FACADE_AREA_DISTRIBUTION_H40_50_D150_180", "PROJECTED_FACADE_AREA_DISTRIBUTION_H50_D150_180", - "NON_VERT_ROOF_AREA_H0_10", "NON_VERT_ROOF_AREA_H10_20", "NON_VERT_ROOF_AREA_H20_30", - "NON_VERT_ROOF_AREA_H30_40", "NON_VERT_ROOF_AREA_H40_50", "NON_VERT_ROOF_AREA_H50", - "VERT_ROOF_AREA_H0_10", "VERT_ROOF_AREA_H10_20", "VERT_ROOF_AREA_H20_30", "VERT_ROOF_AREA_H30_40", - "VERT_ROOF_AREA_H40_50", "VERT_ROOF_AREA_H50", "EFFECTIVE_TERRAIN_ROUGHNESS_LENGTH", - "AREA_FRACTION_INDIVIDUAL_HOUSING", "AREA_FRACTION_COLLECTIVE_HOUSING", - "AREA_FRACTION_OTHER_RESIDENTIAL", "AREA_FRACTION_COMMERCIAL", "AREA_FRACTION_TERTIARY", "AREA_FRACTION_EDUCATION", - "AREA_FRACTION_LIGHT_INDUSTRIAL", "AREA_FRACTION_HEAVY_INDUSTRIAL", "AREA_FRACTION_NON_HEATED", - "FLOOR_AREA_FRACTION_INDIVIDUAL_HOUSING", "FLOOR_AREA_FRACTION_COLLECTIVE_HOUSING", - "FLOOR_AREA_FRACTION_OTHER_RESIDENTIAL", "FLOOR_AREA_FRACTION_COMMERCIAL", "FLOOR_AREA_FRACTION_TERTIARY", - "FLOOR_AREA_FRACTION_EDUCATION", "FLOOR_AREA_FRACTION_LIGHT_INDUSTRIAL", "FLOOR_AREA_FRACTION_HEAVY_INDUSTRIAL", - "FLOOR_AREA_FRACTION_NON_HEATED"], + listRoadDir + listFacadeDistrib + listHeightDistrib + listBuildTypTeb + + ["EFFECTIVE_TERRAIN_ROUGHNESS_LENGTH"], "UTRF": ["AREA", "ASPECT_RATIO", "BUILDING_TOTAL_FRACTION", "FREE_EXTERNAL_FACADE_DENSITY", "VEGETATION_FRACTION_UTRF", "LOW_VEGETATION_FRACTION_UTRF", "HIGH_VEGETATION_IMPERVIOUS_FRACTION_UTRF", "HIGH_VEGETATION_PERVIOUS_FRACTION_UTRF", "ROAD_FRACTION_UTRF", "IMPERVIOUS_FRACTION_UTRF", @@ -90,17 +109,10 @@ class WorkflowGeoIndicatorsTest { "BUILDING_VOLUME_DENSITY", "AVG_VOLUME", "GROUND_LINEAR_ROAD_DENSITY", "GEOM_AVG_HEIGHT_ROOF", "BUILDING_FLOOR_AREA_DENSITY", "AVG_MINIMUM_BUILDING_SPACING", "MAIN_BUILDING_DIRECTION", "BUILDING_DIRECTION_UNIQUENESS", - "BUILDING_DIRECTION_EQUALITY", "AREA_FRACTION_INDIVIDUAL_HOUSING", "AREA_FRACTION_COLLECTIVE_HOUSING", - "AREA_FRACTION_OTHER_RESIDENTIAL", "AREA_FRACTION_COMMERCIAL", "AREA_FRACTION_TERTIARY", "AREA_FRACTION_EDUCATION", - "AREA_FRACTION_LIGHT_INDUSTRIAL", "AREA_FRACTION_HEAVY_INDUSTRIAL", "AREA_FRACTION_NON_HEATED", - "FLOOR_AREA_FRACTION_INDIVIDUAL_HOUSING", "FLOOR_AREA_FRACTION_COLLECTIVE_HOUSING", - "FLOOR_AREA_FRACTION_OTHER_RESIDENTIAL", "FLOOR_AREA_FRACTION_COMMERCIAL", "FLOOR_AREA_FRACTION_TERTIARY", - "FLOOR_AREA_FRACTION_EDUCATION", "FLOOR_AREA_FRACTION_LIGHT_INDUSTRIAL", "FLOOR_AREA_FRACTION_HEAVY_INDUSTRIAL", - "FLOOR_AREA_FRACTION_NON_HEATED"], + "BUILDING_DIRECTION_EQUALITY"], "LCZ" : ["BUILDING_FRACTION_LCZ", "ASPECT_RATIO", "GROUND_SKY_VIEW_FACTOR", "PERVIOUS_FRACTION_LCZ", "IMPERVIOUS_FRACTION_LCZ", "GEOM_AVG_HEIGHT_ROOF", "EFFECTIVE_TERRAIN_ROUGHNESS_LENGTH", "EFFECTIVE_TERRAIN_ROUGHNESS_CLASS", - "HIGH_VEGETATION_FRACTION_LCZ", "LOW_VEGETATION_FRACTION_LCZ", "WATER_FRACTION_LCZ", "AREA_FRACTION_LIGHT_INDUSTRY_LCZ", - "AREA_FRACTION_COMMERCIAL_LCZ", "AREA_FRACTION_HEAVY_INDUSTRY_LCZ", "AREA_FRACTION_RESIDENTIAL_LCZ"]] + "HIGH_VEGETATION_FRACTION_LCZ", "LOW_VEGETATION_FRACTION_LCZ", "WATER_FRACTION_LCZ"] + listBuildTypLcz] // Basic columns at RSU scale public static listColBasic = ["ID_RSU", "THE_GEOM"] From e599e74a599db13babfa81a4038641244414408d Mon Sep 17 00:00:00 2001 From: jeremy Date: Mon, 18 Mar 2024 17:15:46 +0100 Subject: [PATCH 07/12] fix --- .../geoclimate/geoindicators/RsuIndicators.groovy | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicators.groovy b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicators.groovy index 31314a32d4..d703185187 100644 --- a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicators.groovy +++ b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicators.groovy @@ -1003,8 +1003,8 @@ String linearRoadOperations(JdbcDataSource datasource, String rsuTable, String r caseQueryDens = "SUM(ST_LENGTH(the_geom))/rsu_area AS linear_road_density " for (int d = angleRangeSize; d <= 180; d += angleRangeSize) { caseQueryDistrib += "SUM(CASEWHEN(azimuth>=${d - angleRangeSize} AND azimuth<$d, length, 0)) AS " + - "road_direction_distribution_d${d - angleRangeSize}_$d," - nameDistrib.add(getRoadDirIndic(d, angleRangeSize, null as Integer)) + "${getRoadDirIndic(d, angleRangeSize, null)}," + nameDistrib.add(getRoadDirIndic(d, angleRangeSize, null)) } } // If only certain levels are considered independently @@ -1017,9 +1017,8 @@ String linearRoadOperations(JdbcDataSource datasource, String rsuTable, String r for (int d = angleRangeSize; d <= 180; d += angleRangeSize) { caseQueryDistrib += "SUM(CASEWHEN(azimuth>=${d - angleRangeSize} AND azimuth<$d AND " + "zindex = $lev, length, 0)) AS " + - "road_direction_distribution_h${lev.toString().replaceAll("-", "minus")}" + - "_d${d - angleRangeSize}_$d," - nameDistrib.add(getRoadDirIndic(d, angleRangeSize, lev as Integer)) + "${getRoadDirIndic(d, angleRangeSize, lev)}," + nameDistrib.add(getRoadDirIndic(d, angleRangeSize, lev)) } } } @@ -1095,7 +1094,7 @@ String linearRoadOperations(JdbcDataSource datasource, String rsuTable, String r } } -String getRoadDirIndic(int d, int angleRangeSize, int lev){ +String getRoadDirIndic(int d, Integer angleRangeSize, Integer lev){ String name if(lev == null){ name = "road_direction_distribution_d${d - angleRangeSize}_$d" From 55b39fe059dfd774b789c9b9ce22bbd75baafb62 Mon Sep 17 00:00:00 2001 From: jeremy Date: Tue, 19 Mar 2024 10:49:25 +0100 Subject: [PATCH 08/12] Fix urban areas --- .../geoclimate/osm/InputDataFormatting.groovy | 17 +++++++++++------ .../geoclimate/osm/urbanAreasParams.json | 2 +- .../osm/InputDataFormattingTest.groovy | 3 ++- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/osm/src/main/groovy/org/orbisgis/geoclimate/osm/InputDataFormatting.groovy b/osm/src/main/groovy/org/orbisgis/geoclimate/osm/InputDataFormatting.groovy index e9e9c62708..a3a359db35 100644 --- a/osm/src/main/groovy/org/orbisgis/geoclimate/osm/InputDataFormatting.groovy +++ b/osm/src/main/groovy/org/orbisgis/geoclimate/osm/InputDataFormatting.groovy @@ -153,15 +153,20 @@ Map formatBuildingLayer(JdbcDataSource datasource, String building, String zone create table $buildinType as select MAX(part) FILTER (WHERE type = 'residential') as "residential", MAX(part) FILTER (WHERE type = 'education') as "education", + MAX(part) FILTER (WHERE type = 'school') as "school", + MAX(part) FILTER (WHERE type = 'university') as "university", + MAX(part) FILTER (WHERE type = 'research_institute') as "research_institute", + MAX(part) FILTER (WHERE type = 'construction') as "construction", MAX(part) FILTER (WHERE type = 'commercial') as "commercial", - MAX(part) FILTER (WHERE type = 'heavy_industry') as "heavy_industry", - MAX(part) FILTER (WHERE type = 'light_industry') as "light_industry", + MAX(part) FILTER (WHERE type = 'retail') as "retail", + MAX(part) FILTER (WHERE type = 'industrial') as "industrial", + MAX(part) FILTER (WHERE type = 'port') as "port", + MAX(part) FILTER (WHERE type = 'refinery') as "refinery", MAX(part) FILTER (WHERE type = 'government') as "government", + MAX(part) FILTER (WHERE type = 'community_centre') as "community_centre", MAX(part) FILTER (WHERE type = 'military') as "military", - MAX(part) FILTER (WHERE type = 'transport') as "transport", - MAX(part) FILTER (WHERE type = 'construction') as "construction", - MAX(part) FILTER (WHERE type = 'agricultural') as "agricultural", - MAX(part) FILTER (WHERE type = 'social_building') as "social_building", + MAX(part) FILTER (WHERE type = 'railway') as "railway", + MAX(part) FILTER (WHERE type = 'farmyard') as "farmyard", id_build FROM $urbanAreasPart where part > 0.9 group by id_build """.toString() datasource.withBatch(100) { stmt -> diff --git a/osm/src/main/resources/org/orbisgis/geoclimate/osm/urbanAreasParams.json b/osm/src/main/resources/org/orbisgis/geoclimate/osm/urbanAreasParams.json index c00fd0cde0..bbe53ac353 100644 --- a/osm/src/main/resources/org/orbisgis/geoclimate/osm/urbanAreasParams.json +++ b/osm/src/main/resources/org/orbisgis/geoclimate/osm/urbanAreasParams.json @@ -69,7 +69,7 @@ "port" ] }, - "industrial": { + "refinery": { "industrial": [ "refinery" ] diff --git a/osm/src/test/groovy/org/orbisgis/geoclimate/osm/InputDataFormattingTest.groovy b/osm/src/test/groovy/org/orbisgis/geoclimate/osm/InputDataFormattingTest.groovy index 401dd1540d..4013b45a0e 100644 --- a/osm/src/test/groovy/org/orbisgis/geoclimate/osm/InputDataFormattingTest.groovy +++ b/osm/src/test/groovy/org/orbisgis/geoclimate/osm/InputDataFormattingTest.groovy @@ -95,8 +95,9 @@ class InputDataFormattingTest { assertTrue(rows.type == ['residential', 'residential']) rows = h2GIS.rows("select type from ${buiding_imp} where id_build=881 or id_build=484 or id_build=610".toString()) + assertEquals(3, rows.size()) - assertTrue(rows.type == ['light_industry', 'light_industry', 'light_industry']) + assertTrue(rows.type == ['industrial', 'industrial', 'industrial']) //Roads From a5850d678770ea8861161d24eda0e5894cbd963a Mon Sep 17 00:00:00 2001 From: jeremy Date: Tue, 19 Mar 2024 11:28:28 +0100 Subject: [PATCH 09/12] Add doc --- .../geoindicators/RsuIndicators.groovy | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicators.groovy b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicators.groovy index d703185187..f1a0688516 100644 --- a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicators.groovy +++ b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicators.groovy @@ -582,6 +582,18 @@ String projectedFacadeAreaDistribution(JdbcDataSource datasource, String buildin return outputTableName } +/** + * Create indicator names for building facade and building roof distribution indicators + * + * @param base_name The base name of the indicator + * @param var_type A prefix corresponding to the type of values to come after ("h" for height range and "d" for direction range) + * @param lev_bot The bottom limit of the level (for height range or direction range) + * @param lev_up The upper limit of the level (for height range or direction range) + * + * @return Column (indicator) name + * + * @author Jérémy Bernard + */ String getDistribIndicName(String base_name, String var_type, Integer lev_bot, Integer lev_up){ String name if (lev_up == null){ @@ -1094,6 +1106,17 @@ String linearRoadOperations(JdbcDataSource datasource, String rsuTable, String r } } +/** + * Create indicator names for road distribution indicators + * + * @param d The upper limit of the angle considered for road direction (°) + * @param angleRangeSize the angle range + * @param lev The level of the roads + * + * @return Column (indicator) name + * + * @author Jérémy Bernard + */ String getRoadDirIndic(int d, Integer angleRangeSize, Integer lev){ String name if(lev == null){ From 947682c648ced9d9ea582535f5d70873e7e9d41a Mon Sep 17 00:00:00 2001 From: ebocher Date: Wed, 20 Mar 2024 18:04:03 +0100 Subject: [PATCH 10/12] Fix test --- .../bdtopo/WorkflowDebugTest.groovy | 2 +- .../geoindicators/RsuIndicators.groovy | 6 +- .../WorkflowGeoIndicatorsTest.groovy | 214 +++++++++--------- 3 files changed, 115 insertions(+), 107 deletions(-) diff --git a/bdtopo/src/test/groovy/org/orbisgis/geoclimate/bdtopo/WorkflowDebugTest.groovy b/bdtopo/src/test/groovy/org/orbisgis/geoclimate/bdtopo/WorkflowDebugTest.groovy index 34ee81e685..b74c1d8a0c 100644 --- a/bdtopo/src/test/groovy/org/orbisgis/geoclimate/bdtopo/WorkflowDebugTest.groovy +++ b/bdtopo/src/test/groovy/org/orbisgis/geoclimate/bdtopo/WorkflowDebugTest.groovy @@ -158,7 +158,7 @@ class WorkflowDebugTest { "parameters" : ["distance" : 0, rsu_indicators : [ - "indicatorUse": ["LCZ", "UTRF", "URBAN_TYPOLOGY"] + "indicatorUse": ["LCZ", "UTRF"] ], "grid_indicators": [ "x_size" : 1000, diff --git a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicators.groovy b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicators.groovy index f1a0688516..86e24294ac 100644 --- a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicators.groovy +++ b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicators.groovy @@ -530,14 +530,14 @@ String projectedFacadeAreaDistribution(JdbcDataSource datasource, String buildin def sumNamesDir = [] def queryColumns = [] for (int d = 0; d < numberOfDirection / 2; d++) { - Integer dirDeg = d * 360 / numberOfDirection + int dirDeg = d * 360 / numberOfDirection def dirRad = toRadians(dirDeg) - Integer rangeDeg = 360 / numberOfDirection + int rangeDeg = 360 / numberOfDirection def dirRadMid = dirRad + dirMedRad def dirDegMid = dirDeg + dirMedDeg // Define the field name for each of the directions and vertical layers names.each { - namesAndTypeDir += " " + "${getDistribIndicName(it, 'D', dirDeg, dirDeg + rangeDeg)} double" + namesAndTypeDir += " " + "${getDistribIndicName(it, 'D', dirDeg, dirDeg + rangeDeg)} double precision" queryColumns += """CASE WHEN a.azimuth-$dirRadMid>PI()/2 THEN a.$it*a.length*COS(a.azimuth-$dirRadMid-PI()/2)/2 diff --git a/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy b/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy index 0206d79980..5422713c28 100644 --- a/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy +++ b/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy @@ -39,110 +39,24 @@ class WorkflowGeoIndicatorsTest { public static Logger logger = LoggerFactory.getLogger(WorkflowGeoIndicatorsTest.class) - // Default geoindicator parameters - public static parameters = Geoindicators.WorkflowGeoIndicators.getParameters() - - // Indicator list (at RSU scale) for each road direction - public static List listRoadDir = [] - static { - for (int d = parameters.angleRangeSizeRoDirection; d <= 180; d += parameters.angleRangeSizeRoDirection) { - listRoadDir.add(Geoindicators.RsuIndicators.getRoadDirIndic(parameters.angleRangeSizeRoDirection, d, 0)) - } - } - // Indicator list (at RSU scale) for each facade direction and height (projected facade distrib) - // and also for height only (vert and non vert roof density) - public static List listFacadeDistrib = [] - public static List listHeightDistrib = [] - - static { - int rangeDeg = 360 / parameters.angleRangeSizeRoDirection - for (i in 0..parameters.facadeDensListLayersBottom.size()) { - Integer h_bot = parameters.facadeDensListLayersBottom[i] - Integer h_up - if (h_bot == parameters.facadeDensListLayersBottom[-1]){ - h_up = null - } - else{ - h_up = parameters.facadeDensListLayersBottom[i+1] - } - // Create names for vert and non vert roof density - listHeightDistrib.add(Geoindicators.RsuIndicators.getDistribIndicName("vert_roof_area", 'h', h_bot, h_up)) - listHeightDistrib.add(Geoindicators.RsuIndicators.getDistribIndicName("non_vert_roof_area", 'h', h_bot, h_up)) - - // Create names for facade density - String name_h = Geoindicators.RsuIndicators.getDistribIndicName("projected_facade_area_distribution", 'h', h_bot, h_up) - for (Integer d = 0; d < parameters.facadeDensNumberOfDirection / 2; d++){ - Integer d_bot = d * 360 / parameters.facadeDensNumberOfDirection - Integer d_up = d_bot + rangeDeg - listFacadeDistrib.add(Geoindicators.RsuIndicators.getDistribIndicName(name_h, 'd', d_bot, d_up)) - } - } - } - - // Indicator list (at RSU scale) for each type of use - public static List listBuildTypTeb = [] - public static List listBuildTypLcz = [] - static { - for (type in parameters.buildingAreaTypeAndCompositionTeb.keySet()) { - listBuildTypTeb.add("AREA_FRACTION_${type}") - } - for (type in parameters.floorAreaTypeAndCompositionTeb.keySet()) { - listBuildTypTeb.add("FLOOR_AREA_FRACTION_${type}") - } - for (type in parameters.buildingAreaTypeAndCompositionLcz.keySet()) { - listBuildTypLcz.add("AREA_FRACTION_${type}") - } - for (type in parameters.floorAreaTypeAndCompositionLcz.keySet()) { - listBuildTypLcz.add("FLOOR_AREA_FRACTION_${type}") - } - } - - public static listNames = [ - "TEB" : ["VERT_ROOF_DENSITY", "NON_VERT_ROOF_DENSITY"] + - listRoadDir + listFacadeDistrib + listHeightDistrib + listBuildTypTeb + - ["EFFECTIVE_TERRAIN_ROUGHNESS_LENGTH"], - "UTRF": ["AREA", "ASPECT_RATIO", "BUILDING_TOTAL_FRACTION", "FREE_EXTERNAL_FACADE_DENSITY", - "VEGETATION_FRACTION_UTRF", "LOW_VEGETATION_FRACTION_UTRF", "HIGH_VEGETATION_IMPERVIOUS_FRACTION_UTRF", - "HIGH_VEGETATION_PERVIOUS_FRACTION_UTRF", "ROAD_FRACTION_UTRF", "IMPERVIOUS_FRACTION_UTRF", - "AVG_NUMBER_BUILDING_NEIGHBOR", "AVG_HEIGHT_ROOF_AREA_WEIGHTED", - "STD_HEIGHT_ROOF_AREA_WEIGHTED", "BUILDING_NUMBER_DENSITY", "BUILDING_VOLUME_DENSITY", - "BUILDING_VOLUME_DENSITY", "AVG_VOLUME", "GROUND_LINEAR_ROAD_DENSITY", - "GEOM_AVG_HEIGHT_ROOF", "BUILDING_FLOOR_AREA_DENSITY", - "AVG_MINIMUM_BUILDING_SPACING", "MAIN_BUILDING_DIRECTION", "BUILDING_DIRECTION_UNIQUENESS", - "BUILDING_DIRECTION_EQUALITY"], - "LCZ" : ["BUILDING_FRACTION_LCZ", "ASPECT_RATIO", "GROUND_SKY_VIEW_FACTOR", "PERVIOUS_FRACTION_LCZ", - "IMPERVIOUS_FRACTION_LCZ", "GEOM_AVG_HEIGHT_ROOF", "EFFECTIVE_TERRAIN_ROUGHNESS_LENGTH", "EFFECTIVE_TERRAIN_ROUGHNESS_CLASS", - "HIGH_VEGETATION_FRACTION_LCZ", "LOW_VEGETATION_FRACTION_LCZ", "WATER_FRACTION_LCZ"] + listBuildTypLcz] + public static listNames // Basic columns at RSU scale - public static listColBasic = ["ID_RSU", "THE_GEOM"] - + public static listColBasic // Indicators common to each indicator use - public static listColCommon = ["LOW_VEGETATION_FRACTION", "HIGH_VEGETATION_FRACTION", - "BUILDING_FRACTION", "WATER_FRACTION", "ROAD_FRACTION", "IMPERVIOUS_FRACTION", - "HIGH_VEGETATION_LOW_VEGETATION_FRACTION", "HIGH_VEGETATION_WATER_FRACTION", - "HIGH_VEGETATION_ROAD_FRACTION", "HIGH_VEGETATION_IMPERVIOUS_FRACTION", - "HIGH_VEGETATION_BUILDING_FRACTION", "UNDEFINED_FRACTION"] - + public static listColCommon // Column names in the LCZ Table - public static listColLcz = ["LCZ_PRIMARY", "LCZ_SECONDARY", "LCZ_EQUALITY_VALUE", "LCZ_UNIQUENESS_VALUE", "MIN_DISTANCE"] - + public static listColLcz // Indicator lists for urban typology use at building and block scales - public static listUrbTyp = - ["Bu": ["THE_GEOM", "ID_RSU", "ID_BUILD", "ID_BLOCK", "NB_LEV", "ZINDEX", "MAIN_USE", "TYPE", "ID_SOURCE", - "HEIGHT_ROOF", "HEIGHT_WALL", "PERIMETER", "AREA", "VOLUME", "FLOOR_AREA", "TOTAL_FACADE_LENGTH", "COMMON_WALL_FRACTION", - "CONTIGUITY", "AREA_CONCAVITY", "FORM_FACTOR", "RAW_COMPACTNESS", "PERIMETER_CONVEXITY", - "MINIMUM_BUILDING_SPACING", "NUMBER_BUILDING_NEIGHBOR", "ROAD_DISTANCE", "LIKELIHOOD_LARGE_BUILDING"], - "Bl": ["THE_GEOM", "ID_RSU", "ID_BLOCK", "AREA", "FLOOR_AREA", "VOLUME", "HOLE_AREA_DENSITY", "MAIN_BUILDING_DIRECTION", - "BUILDING_DIRECTION_UNIQUENESS", "BUILDING_DIRECTION_EQUALITY", "CLOSINGNESS", "NET_COMPACTNESS", - "AVG_HEIGHT_ROOF_AREA_WEIGHTED", "STD_HEIGHT_ROOF_AREA_WEIGHTED"]] + public static listUrbTyp public static H2GIS datasource public static def inputTableNames + public @BeforeAll static void beforeAll() { - // folder = new File("/tmp") + initParameters() datasource = open(folder.getAbsolutePath() + File.separator + "workflowGeoIndicatorsTest;AUTO_SERVER=TRUE") assertNotNull(datasource) datasource.load(WorkflowGeoIndicatorsTest.getResource("BUILDING.geojson"), "BUILDING", true) @@ -154,6 +68,100 @@ class WorkflowGeoIndicatorsTest { railTable: "RAIL", vegetationTable: "VEGET", hydrographicTable: "HYDRO"] } + /** + * Init some parameters to run the tests + */ + static void initParameters() { + Map parameters = Geoindicators.WorkflowGeoIndicators.getParameters() + // Indicator list (at RSU scale) for each type of use + List listBuildTypTeb = [] + List listBuildTypLcz = [] + for (type in parameters.buildingAreaTypeAndCompositionTeb.keySet()) { + listBuildTypTeb.add("AREA_FRACTION_${type}") + } + for (type in parameters.floorAreaTypeAndCompositionTeb.keySet()) { + listBuildTypTeb.add("FLOOR_AREA_FRACTION_${type}") + } + for (type in parameters.buildingAreaTypeAndCompositionLcz.keySet()) { + listBuildTypLcz.add("AREA_FRACTION_${type}") + } + for (type in parameters.floorAreaTypeAndCompositionLcz.keySet()) { + listBuildTypLcz.add("FLOOR_AREA_FRACTION_${type}") + } + + // Indicator list (at RSU scale) for each road direction + List listRoadDir = [] + for (int d = parameters.angleRangeSizeRoDirection; d <= 180; d += parameters.angleRangeSizeRoDirection) { + listRoadDir.add(Geoindicators.RsuIndicators.getRoadDirIndic(parameters.angleRangeSizeRoDirection, d, 0)) + } + + // Indicator list (at RSU scale) for each facade direction and height (projected facade distrib) + // and also for height only (vert and non vert roof density) + List listFacadeDistrib = [] + List listHeightDistrib = [] + int rangeDeg = 360 / parameters.angleRangeSizeRoDirection + for (int i in 0..parameters.facadeDensListLayersBottom.size()) { + Integer h_bot = parameters.facadeDensListLayersBottom[i] + Integer h_up + if (h_bot == parameters.facadeDensListLayersBottom[-1]) { + h_up = null + } else { + h_up = parameters.facadeDensListLayersBottom[i + 1] + } + // Create names for vert and non vert roof density + listHeightDistrib.add(Geoindicators.RsuIndicators.getDistribIndicName("vert_roof_area", 'h', h_bot, h_up)) + listHeightDistrib.add(Geoindicators.RsuIndicators.getDistribIndicName("non_vert_roof_area", 'h', h_bot, h_up)) + + // Create names for facade density + String name_h = Geoindicators.RsuIndicators.getDistribIndicName("projected_facade_area_distribution", 'h', h_bot, h_up) + for (int d = 0; d < parameters.facadeDensNumberOfDirection / 2; d++) { + int d_bot = d * 360 / parameters.facadeDensNumberOfDirection + int d_up = d_bot + rangeDeg + listFacadeDistrib.add(Geoindicators.RsuIndicators.getDistribIndicName(name_h, 'd', d_bot, d_up)) + } + } + listNames = [ + "TEB" : ["VERT_ROOF_DENSITY", "NON_VERT_ROOF_DENSITY"] + + listRoadDir + listFacadeDistrib + listHeightDistrib + listBuildTypTeb + + ["EFFECTIVE_TERRAIN_ROUGHNESS_LENGTH"], + "UTRF": ["AREA", "ASPECT_RATIO", "BUILDING_TOTAL_FRACTION", "FREE_EXTERNAL_FACADE_DENSITY", + "VEGETATION_FRACTION_UTRF", "LOW_VEGETATION_FRACTION_UTRF", "HIGH_VEGETATION_IMPERVIOUS_FRACTION_UTRF", + "HIGH_VEGETATION_PERVIOUS_FRACTION_UTRF", "ROAD_FRACTION_UTRF", "IMPERVIOUS_FRACTION_UTRF", + "AVG_NUMBER_BUILDING_NEIGHBOR", "AVG_HEIGHT_ROOF_AREA_WEIGHTED", + "STD_HEIGHT_ROOF_AREA_WEIGHTED", "BUILDING_NUMBER_DENSITY", "BUILDING_VOLUME_DENSITY", + "BUILDING_VOLUME_DENSITY", "AVG_VOLUME", "GROUND_LINEAR_ROAD_DENSITY", + "GEOM_AVG_HEIGHT_ROOF", "BUILDING_FLOOR_AREA_DENSITY", + "AVG_MINIMUM_BUILDING_SPACING", "MAIN_BUILDING_DIRECTION", "BUILDING_DIRECTION_UNIQUENESS", + "BUILDING_DIRECTION_EQUALITY"], + "LCZ" : ["BUILDING_FRACTION_LCZ", "ASPECT_RATIO", "GROUND_SKY_VIEW_FACTOR", "PERVIOUS_FRACTION_LCZ", + "IMPERVIOUS_FRACTION_LCZ", "GEOM_AVG_HEIGHT_ROOF", "EFFECTIVE_TERRAIN_ROUGHNESS_LENGTH", "EFFECTIVE_TERRAIN_ROUGHNESS_CLASS", + "HIGH_VEGETATION_FRACTION_LCZ", "LOW_VEGETATION_FRACTION_LCZ", "WATER_FRACTION_LCZ"] + listBuildTypLcz] + + + // Basic columns at RSU scale + listColBasic = ["ID_RSU", "THE_GEOM"] + + // Indicators common to each indicator use + listColCommon = ["LOW_VEGETATION_FRACTION", "HIGH_VEGETATION_FRACTION", + "BUILDING_FRACTION", "WATER_FRACTION", "ROAD_FRACTION", "IMPERVIOUS_FRACTION", + "HIGH_VEGETATION_LOW_VEGETATION_FRACTION", "HIGH_VEGETATION_WATER_FRACTION", + "HIGH_VEGETATION_ROAD_FRACTION", "HIGH_VEGETATION_IMPERVIOUS_FRACTION", + "HIGH_VEGETATION_BUILDING_FRACTION", "UNDEFINED_FRACTION"] + + // Column names in the LCZ Table + listColLcz = ["LCZ_PRIMARY", "LCZ_SECONDARY", "LCZ_EQUALITY_VALUE", "LCZ_UNIQUENESS_VALUE", "MIN_DISTANCE"] + + // Indicator lists for urban typology use at building and block scales + listUrbTyp = + ["Bu": ["THE_GEOM", "ID_RSU", "ID_BUILD", "ID_BLOCK", "NB_LEV", "ZINDEX", "MAIN_USE", "TYPE", "ID_SOURCE", + "HEIGHT_ROOF", "HEIGHT_WALL", "PERIMETER", "AREA", "VOLUME", "FLOOR_AREA", "TOTAL_FACADE_LENGTH", "COMMON_WALL_FRACTION", + "CONTIGUITY", "AREA_CONCAVITY", "FORM_FACTOR", "RAW_COMPACTNESS", "PERIMETER_CONVEXITY", + "MINIMUM_BUILDING_SPACING", "NUMBER_BUILDING_NEIGHBOR", "ROAD_DISTANCE", "LIKELIHOOD_LARGE_BUILDING"], + "Bl": ["THE_GEOM", "ID_RSU", "ID_BLOCK", "AREA", "FLOOR_AREA", "VOLUME", "HOLE_AREA_DENSITY", "MAIN_BUILDING_DIRECTION", + "BUILDING_DIRECTION_UNIQUENESS", "BUILDING_DIRECTION_EQUALITY", "CLOSINGNESS", "NET_COMPACTNESS", + "AVG_HEIGHT_ROOF_AREA_WEIGHTED", "STD_HEIGHT_ROOF_AREA_WEIGHTED"]] + + } @Test void GeoIndicatorsTest1() { @@ -165,7 +173,7 @@ class WorkflowGeoIndicatorsTest { Map geoIndicatorsCompute_i = Geoindicators.WorkflowGeoIndicators.computeAllGeoIndicators(datasource, inputTableNames.zoneTable, inputTableNames.buildingTable, inputTableNames.roadTable, inputTableNames.railTable, inputTableNames.vegetationTable, - inputTableNames.hydrographicTable, "", "", "", "","", + inputTableNames.hydrographicTable, "", "", "", "", "", ["indicatorUse": indicatorUse, svfSimplified: false], prefixName) assertNotNull(geoIndicatorsCompute_i) checkRSUIndicators(datasource, geoIndicatorsCompute_i.rsu_indicators) @@ -208,7 +216,7 @@ class WorkflowGeoIndicatorsTest { inputTableNames.buildingTable, inputTableNames.roadTable, inputTableNames.railTable, inputTableNames.vegetationTable, inputTableNames.hydrographicTable, "", - "", "", "","", + "", "", "", "", ["indicatorUse": indicatorUse, svfSimplified: false, "utrfModelName": "UTRF_BDTOPO_V2_RF_2_2.model"], prefixName) assertNotNull(geoIndicatorsCompute_i) @@ -284,7 +292,7 @@ class WorkflowGeoIndicatorsTest { Map geoIndicatorsCompute_i = Geoindicators.WorkflowGeoIndicators.computeAllGeoIndicators(datasource, inputTableNames.zoneTable, inputTableNames.buildingTable, inputTableNames.roadTable, inputTableNames.railTable, inputTableNames.vegetationTable, - inputTableNames.hydrographicTable, "","", + inputTableNames.hydrographicTable, "", "", "", "", "", ["indicatorUse": indicatorUse, svfSimplified: false], prefixName) assertNotNull(geoIndicatorsCompute_i) @@ -326,7 +334,7 @@ class WorkflowGeoIndicatorsTest { inputTableNames.buildingTable, inputTableNames.roadTable, inputTableNames.railTable, inputTableNames.vegetationTable, inputTableNames.hydrographicTable, "", - "", "", "","", ["indicatorUse": indicatorUse, svfSimplified: false], prefixName) + "", "", "", "", ["indicatorUse": indicatorUse, svfSimplified: false], prefixName) assertNotNull(geoIndicatorsCompute_i) checkRSUIndicators(datasource, geoIndicatorsCompute_i.rsu_indicators) @@ -366,7 +374,7 @@ class WorkflowGeoIndicatorsTest { inputTableNames.buildingTable, inputTableNames.roadTable, inputTableNames.railTable, inputTableNames.vegetationTable, inputTableNames.hydrographicTable, "", - "", "", "", "",["indicatorUse": indicatorUse, svfSimplified: false], prefixName) + "", "", "", "", ["indicatorUse": indicatorUse, svfSimplified: false], prefixName) assertNotNull(geoIndicatorsCompute_i) checkRSUIndicators(datasource, geoIndicatorsCompute_i.rsu_indicators) @@ -408,7 +416,7 @@ class WorkflowGeoIndicatorsTest { inputTableNames.buildingTable, inputTableNames.roadTable, inputTableNames.railTable, inputTableNames.vegetationTable, inputTableNames.hydrographicTable, "", "", "", - "","", + "", "", ["indicatorUse": indicatorUse, "svfSimplified": false], prefixName) assertNotNull(geoIndicatorsCompute_i) @@ -450,7 +458,7 @@ class WorkflowGeoIndicatorsTest { inputTableNames.buildingTable, inputTableNames.roadTable, inputTableNames.railTable, inputTableNames.vegetationTable, inputTableNames.hydrographicTable, "", - "", "", "", "",["indicatorUse": indicatorUse, svfSimplified: false], prefixName) + "", "", "", "", ["indicatorUse": indicatorUse, svfSimplified: false], prefixName) assertNotNull(geoIndicatorsCompute_i) def expectListRsuTempo = listColBasic + listColCommon @@ -503,15 +511,15 @@ class WorkflowGeoIndicatorsTest { assertEquals(100d, rows.SUM_POP) assertEquals(10d, rows.AVG_HEIGHT_ROOF) assertEquals(0d, rows.STD_HEIGHT_ROOF) - assertTrue(10d-rows.GEOM_AVG_HEIGHT_ROOF< 0.0001) + assertTrue(10d - rows.GEOM_AVG_HEIGHT_ROOF < 0.0001) assertEquals(10d, rows.AVG_HEIGHT_ROOF_AREA_WEIGHTED) assertEquals(0d, rows.STD_HEIGHT_ROOF_AREA_WEIGHTED) assertEquals(2d, rows.FREE_EXTERNAL_FACADE_DENSITY) assertEquals(3d, rows.BUILDING_SURFACE_DENSITY) - assertTrue(1.5 -rows.EFFECTIVE_TERRAIN_ROUGHNESS_LENGTH<0.001) + assertTrue(1.5 - rows.EFFECTIVE_TERRAIN_ROUGHNESS_LENGTH < 0.001) assertEquals(8, rows.EFFECTIVE_TERRAIN_ROUGHNESS_CLASS) assertNull(rows.ASPECT_RATIO) - assertTrue(0.5 -rows.SVF<0.1) + assertTrue(0.5 - rows.SVF < 0.1) assertEquals(1d, rows.TYPE_OFFICE) } From 83b22e4acfa061e2339062ce514cae9d79918dd4 Mon Sep 17 00:00:00 2001 From: jeremy Date: Tue, 26 Mar 2024 15:33:31 +0100 Subject: [PATCH 11/12] New test for sum of all building fraction implementeds --- .../geoindicators/WorkflowGeoIndicators.groovy | 9 ++++++--- .../WorkflowGeoIndicatorsTest.groovy | 17 +++++++++++++---- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicators.groovy b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicators.groovy index c31e4eb788..f269696e68 100644 --- a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicators.groovy +++ b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicators.groovy @@ -1206,7 +1206,8 @@ Map getParameters() { "angleRangeSizeRoDirection" : 30, "surfSuperpositions" : ["high_vegetation": ["water", "building", "low_vegetation", "rail", "road", "impervious"]], "surfPriorities" : ["water", "building", "high_vegetation", "low_vegetation", "rail", "road", "impervious"], - "buildingAreaTypeAndCompositionLcz" : ["light_industry_lcz": ["industrial", "factory", "warehouse", "port"], + "buildingAreaTypeAndCompositionLcz" : ["undefined_lcz": ["building"], + "light_industry_lcz": ["industrial", "factory", "warehouse", "port"], "commercial_lcz": ["commercial", "shop", "retail", "port", "exhibition_centre", "cinema"], "heavy_industry_lcz": ["refinery"], @@ -1214,7 +1215,8 @@ Map getParameters() { "abbey", "condominium", "villa", "dormitory", "sheltered_housing", "workers_dormitory", "terrace", "residential"]], "floorAreaTypeAndCompositionLcz" : [:], - "buildingAreaTypeAndCompositionTeb" : ["individual_housing": ["house", "detached", "bungalow", "farm", "villa", "terrace"], + "buildingAreaTypeAndCompositionTeb" : ["undefined": ["building"], + "individual_housing": ["house", "detached", "bungalow", "farm", "villa", "terrace"], "collective_housing": [ "apartments","barracks","abbey", "dormitory", "sheltered_housing", "workers_dormitory", "condominium", "residential"], @@ -1242,7 +1244,8 @@ Map getParameters() { "wayside_shrine","station","stable","sty","greenhouse","kiosk","marketplace", "marker","warehouse","planetarium","fire_station","water_tower","grandstand", "transportation","toll_booth"]], - "floorAreaTypeAndCompositionTeb" : ["individual_housing": ["house", "detached", "bungalow", "farm", "villa", "terrace"], + "floorAreaTypeAndCompositionTeb" : ["undefined": ["building"], + "individual_housing": ["house", "detached", "bungalow", "farm", "villa", "terrace"], "collective_housing": [ "apartments","barracks","abbey", "dormitory", "sheltered_housing", "workers_dormitory", "condominium", "residential"], diff --git a/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy b/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy index 0206d79980..8179db738e 100644 --- a/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy +++ b/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy @@ -81,26 +81,28 @@ class WorkflowGeoIndicatorsTest { // Indicator list (at RSU scale) for each type of use public static List listBuildTypTeb = [] + public static List listFloorBuildTypTeb = [] public static List listBuildTypLcz = [] + public static List listFloorBuildTypLcz = [] static { for (type in parameters.buildingAreaTypeAndCompositionTeb.keySet()) { listBuildTypTeb.add("AREA_FRACTION_${type}") } for (type in parameters.floorAreaTypeAndCompositionTeb.keySet()) { - listBuildTypTeb.add("FLOOR_AREA_FRACTION_${type}") + listFloorBuildTypTeb.add("FLOOR_AREA_FRACTION_${type}") } for (type in parameters.buildingAreaTypeAndCompositionLcz.keySet()) { listBuildTypLcz.add("AREA_FRACTION_${type}") } for (type in parameters.floorAreaTypeAndCompositionLcz.keySet()) { - listBuildTypLcz.add("FLOOR_AREA_FRACTION_${type}") + listFloorBuildTypLcz.add("FLOOR_AREA_FRACTION_${type}") } } public static listNames = [ "TEB" : ["VERT_ROOF_DENSITY", "NON_VERT_ROOF_DENSITY"] + - listRoadDir + listFacadeDistrib + listHeightDistrib + listBuildTypTeb + - ["EFFECTIVE_TERRAIN_ROUGHNESS_LENGTH"], + listRoadDir + listFacadeDistrib + listHeightDistrib + listBuildTypTeb + listFloorBuildTypTeb + + listFloorBuildTypLcz + ["EFFECTIVE_TERRAIN_ROUGHNESS_LENGTH"], "UTRF": ["AREA", "ASPECT_RATIO", "BUILDING_TOTAL_FRACTION", "FREE_EXTERNAL_FACADE_DENSITY", "VEGETATION_FRACTION_UTRF", "LOW_VEGETATION_FRACTION_UTRF", "HIGH_VEGETATION_IMPERVIOUS_FRACTION_UTRF", "HIGH_VEGETATION_PERVIOUS_FRACTION_UTRF", "ROAD_FRACTION_UTRF", "IMPERVIOUS_FRACTION_UTRF", @@ -195,6 +197,13 @@ class WorkflowGeoIndicatorsTest { dfBlock = dfBlock.drop("ID_RSU") assertEquals dfBlock.nrows(), dfBlock.omitNullRows().nrows() + // Test that the sum of all building fractions is 100% for both LCZ and TEB building types + datasource """DROP TABLE IF EXISTS TEST; CREATE TABLE TEST AS SELECT *, ${listBuildTypTeb.join("+")} AS SUM_FRAC FROM ${"$geoIndicatorsCompute_i.rsu_indicators"}""" + + datasource.save("TEST", "/tmp/test.geojson", true) + def sum_frac = datasource.firstRow("SELECT AVG(${listBuildTypTeb.join("+")}) AS SUM_FRAC FROM ${"$geoIndicatorsCompute_i.rsu_indicators"} WHERE BUILDING_DIRECTION_UNIQUENESS <> -1") + assertEquals sum_frac.SUM_FRAC, 1.0, 0.001 + } @Test From def26c66f71045a3ba8bdb9c259ea7e71aead0f6 Mon Sep 17 00:00:00 2001 From: jeremy Date: Wed, 27 Mar 2024 14:00:38 +0100 Subject: [PATCH 12/12] Put all distribution indicators to upper cases in the tests --- .../WorkflowGeoIndicatorsTest.groovy | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy b/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy index 42f65149a4..755e7b4819 100644 --- a/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy +++ b/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy @@ -85,22 +85,22 @@ class WorkflowGeoIndicatorsTest { listFloorBuildTypLcz = [] listFloorBuildTypTeb = [] for (type in parameters.buildingAreaTypeAndCompositionTeb.keySet()) { - listBuildTypTeb.add("AREA_FRACTION_${type}".toString()) + listBuildTypTeb.add("AREA_FRACTION_${type}".toString().toUpperCase()) } for (type in parameters.floorAreaTypeAndCompositionTeb.keySet()) { - listFloorBuildTypTeb.add("FLOOR_AREA_FRACTION_${type}".toString()) + listFloorBuildTypTeb.add("FLOOR_AREA_FRACTION_${type}".toString().toUpperCase()) } for (type in parameters.buildingAreaTypeAndCompositionLcz.keySet()) { - listBuildTypLcz.add("AREA_FRACTION_${type}".toString()) + listBuildTypLcz.add("AREA_FRACTION_${type}".toString().toUpperCase()) } for (type in parameters.floorAreaTypeAndCompositionLcz.keySet()) { - listFloorBuildTypLcz.add("FLOOR_AREA_FRACTION_${type}".toString()) + listFloorBuildTypLcz.add("FLOOR_AREA_FRACTION_${type}".toString().toUpperCase()) } // Indicator list (at RSU scale) for each road direction List listRoadDir = [] for (int d = parameters.angleRangeSizeRoDirection; d <= 180; d += parameters.angleRangeSizeRoDirection) { - listRoadDir.add(Geoindicators.RsuIndicators.getRoadDirIndic(d, parameters.angleRangeSizeRoDirection, 0)) + listRoadDir.add(Geoindicators.RsuIndicators.getRoadDirIndic(d, parameters.angleRangeSizeRoDirection, 0).toString().toUpperCase()) } // Indicator list (at RSU scale) for each facade direction and height (projected facade distrib) @@ -117,15 +117,15 @@ class WorkflowGeoIndicatorsTest { h_up = parameters.facadeDensListLayersBottom[i + 1] } // Create names for vert and non vert roof density - listHeightDistrib.add(Geoindicators.RsuIndicators.getDistribIndicName("vert_roof_area", 'h', h_bot, h_up)) - listHeightDistrib.add(Geoindicators.RsuIndicators.getDistribIndicName("non_vert_roof_area", 'h', h_bot, h_up)) + listHeightDistrib.add(Geoindicators.RsuIndicators.getDistribIndicName("vert_roof_area", 'h', h_bot, h_up).toString().toUpperCase()) + listHeightDistrib.add(Geoindicators.RsuIndicators.getDistribIndicName("non_vert_roof_area", 'h', h_bot, h_up).toString().toUpperCase()) // Create names for facade density - String name_h = Geoindicators.RsuIndicators.getDistribIndicName("projected_facade_area_distribution", 'h', h_bot, h_up) + String name_h = Geoindicators.RsuIndicators.getDistribIndicName("projected_facade_area_distribution", 'h', h_bot, h_up).toString().toUpperCase() for (int d = 0; d < parameters.facadeDensNumberOfDirection / 2; d++) { int d_bot = d * 360 / parameters.facadeDensNumberOfDirection int d_up = d_bot + rangeDeg - listFacadeDistrib.add(Geoindicators.RsuIndicators.getDistribIndicName(name_h, 'd', d_bot, d_up)) + listFacadeDistrib.add(Geoindicators.RsuIndicators.getDistribIndicName(name_h, 'd', d_bot, d_up).toString().toUpperCase()) } } listNames = [ @@ -195,7 +195,7 @@ class WorkflowGeoIndicatorsTest { List realListRsu = datasource.getTable(geoIndicatorsCompute_i.rsu_indicators).columns // We test that there is no missing indicators in the RSU table for (i in expectListRsu) { - assertTrue realListRsu.contains(i.toUpperCase()) + assertTrue realListRsu.contains(i) } def expectListLczTempo = listColLcz expectListLczTempo = expectListLczTempo + listColBasic @@ -334,6 +334,7 @@ class WorkflowGeoIndicatorsTest { def realListRsu = datasource.getTable(geoIndicatorsCompute_i.rsu_indicators).columns // We test that there is no missing indicators in the RSU table for (i in expectListRsu) { + println(i) assertTrue realListRsu.contains(i) } if (indicatorUse.contains("LCZ")) {