Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 0 additions & 49 deletions analysers/analyser_osmosis_relation_multipolygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,43 +161,6 @@
COUNT(*) > 1
"""

sql40 = """
SELECT
ways.id,
ST_AsText(way_locate(ways.linestring)),
ways.tags->'area',
ways.tags->'landuse',
ways.tags->'natural',
ways.tags->'waterway',
ways.tags->'leisure',
ways.tags->'amenity',
ways.tags->'building',
COALESCE(ways.tags->'area', ways.tags->'landuse', ways.tags->'natural', ways.tags->'waterway', ways.tags->'leisure', ways.tags->'amenity', ways.tags->'building')
FROM
{0}ways AS ways
LEFT JOIN relation_members ON
relation_members.member_id = ways.id AND
relation_members.member_type = 'W'
WHERE
ways.tags != ''::hstore AND
(
(ways.tags?'area' AND ways.tags->'area' in ('yes', 'true')) OR
ways.tags?'landuse' OR
(ways.tags?'natural' AND ways.tags->'natural' in ('bare_rock', 'bay', 'beach', 'fell', 'glacier', 'grassland', 'heath', 'hot_spring', 'moor', 'mud', 'rock', 'sand', 'scree', 'scrub', 'shingle', 'sinkhole', 'stone', 'water', 'wetland', 'wood') AND (NOT ways.tags?'bay' OR ways.tags->'bay' != 'fjord')) OR
(ways.tags?'waterway' AND ways.tags->'waterway' in ('boatyard', 'dock', 'fuel', 'riverbank')) OR
(ways.tags?'leisure' AND ways.tags->'leisure' in ('adult_gaming_centre', 'amusement_arcade', 'bandstand', 'beach_resort', 'bird_hide', 'common', 'dance', 'dog_park', 'firepit', 'fishing', 'fitness_centre', 'garden', 'golf_course', 'hackerspace', 'horse_riding', 'ice_rink', 'marina', 'miniature_golf', 'nature_reserve', 'park', 'picnic_table', 'pitch', 'playground', 'sports_centre', 'stadium', 'summer_camp', 'swimming_area', 'swimming_pool', 'water_park', 'wildlife_hide')) OR
(ways.tags?'amenity' AND ways.tags->'amenity' in ('animal_boarding', 'animal_shelter', 'arts_centre', 'baby_hatch', 'bank', 'bar', 'bicycle_rental', 'bicycle_repair_station', 'biergarten', 'blood_donation', 'boat_sharing', 'brothel', 'bus_station', 'cafe', 'car_rental', 'car_sharing', 'car_wash', 'casino', 'cinema', 'clinic', 'college', 'community_centre', 'courthouse', 'coworking_space', 'crematorium', 'crypt', 'dentist', 'dive_centre', 'doctors', 'dojo', 'driving_school', 'embassy', 'fast_food', 'ferry_terminal', 'fire_station', 'firepit', 'food_court', 'fountain', 'fuel', 'gambling', 'game_feeding', 'grave_yard', 'gym', 'hospital', 'hunting_stand', 'ice_cream', 'internet_cafe', 'kindergarten', 'kneipp_water_cure', 'language_school', 'library', 'marketplace', 'motorcycle_parking', 'music_school', 'nightclub', 'nursing_home', 'parking', 'parking_space', 'pharmacy', 'place_of_worship', 'planetarium', 'police', 'post_office', 'prison', 'pub', 'public_bookcase', 'public_building', 'ranger_station', 'recycling', 'rescue_station', 'restaurant', 'sauna', 'school', 'shelter', 'shower', 'social_centre', 'social_facility', 'studio', 'swingerclub', 'taxi', 'theatre', 'toilets', 'townhall', 'university', 'veterinary', 'waste_transfer_station')) OR
ways.tags?'building'
) AND
ways.linestring IS NOT NULL AND
NOT ways.is_polygon AND
relation_members.member_id IS NULL AND
-- Avoid confusing warnings for invalid polygons. Any closed way with >3 nodes that doesn't match
-- is_polygon (with any of the tags above) must be an invalid polygon (which is checked elsewhere)
-- Note: use array_length instead of ST_NPoints as the former includes nodes outside of the extract
(NOT ST_IsClosed(ways.linestring) OR array_length(ways.nodes,1) = 3)
"""

class Analyser_Osmosis_Relation_Multipolygon(Analyser_Osmosis):

def __init__(self, config, logger = None):
Expand All @@ -220,13 +183,6 @@ def __init__(self, config, logger = None):
detail = T_(
'''Multipolygon does not define nature, several found on the outer role
members.'''))
self.classs_change[4] = self.def_class(item = 1170, level = 1, tags = ['relation', 'fix:chair', 'geom'],
title = T_('Should be polygon, part of multipolygon or not having area tag'),
detail = T_(
'''The nature of the way indicates that it is a surface, the way would be
a polygon or a part of a multipolygon as outer role.'''),
fix = T_(
'''Close the way to make a polygon or add to a multipolygon.'''))

self.callback10 = lambda res: {"class":1, "data":[self.relation_full, self.way_full, self.way_full, self.positionAsText]}
self.callback20 = lambda res: {"class":2, "subclass":stablehash64(res[11]), "data":[self.relation_full, self.way_full, self.positionAsText],
Expand All @@ -235,9 +191,6 @@ def __init__(self, config, logger = None):
self.callback30 = lambda res: {"class":3, "subclass":1, "data":[self.relation_full, self.positionAsText],
"text": {"en": u", ".join(map(lambda k: "{0}=({1})".format(*k), filter(lambda k: k[1], (("landuse",res[2]), ("natural",res[3]), ("waterway",res[4]), ("building",res[5])))))}
}
self.callback40 = lambda res: {"class":4, "subclass":stablehash64(res[9]), "data":[self.way_full, self.positionAsText],
"text": {"en": u", ".join(map(lambda k: "{0}={1}".format(*k), filter(lambda k: k[1], (("area",res[2]), ("landuse",res[3]), ("natural",res[4]), ("waterway",res[5]), ("leisure",res[6]), ("amenity",res[7]), ("building",res[8])))))}
}

def analyser_osmosis_common(self):
self.run(sql30, self.callback30)
Expand All @@ -247,7 +200,6 @@ def analyser_osmosis_full(self):
self.run(sql11)
self.run(sql12.format("", "", ""), self.callback10)
self.run(sql20.format("", ""), self.callback20)
self.run(sql40.format(""), self.callback40)

def analyser_osmosis_diff(self):
self.run(sql10)
Expand All @@ -258,4 +210,3 @@ def analyser_osmosis_diff(self):
self.run(sql12.format("not_touched_", "not_touched_", "touched_"), self.callback10)
self.run(sql20.format("touched_", ""), self.callback20)
self.run(sql20.format("not_touched_", "touched_"), self.callback20)
self.run(sql40.format("touched_"), self.callback40)
4 changes: 2 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11
FROM python:3.13

RUN apt-get update && \
apt-get -y dist-upgrade && \
Expand All @@ -18,7 +18,7 @@ RUN apt-get update && \
libprotobuf-dev \
locales \
make \
openjdk-17-jre-headless \
openjdk-21-jre-headless \
pkg-config \
postgis \
postgresql-client \
Expand Down
34 changes: 17 additions & 17 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ osmose-backend can be run in a Docker container. This avoids setting
up and configuring Python, Java and PostgreSQL on your system.

Note : A PostgreSQL docker is automatically installed and run by
docker-compose and doesn't need be installed manually.
docker compose and doesn't need be installed manually.
The osmose-frontend docker may also be run but is not mandatory.


Expand All @@ -14,7 +14,7 @@ Setup

To build the docker image run this command from the docker folder:
```
docker-compose build
docker compose build
```

For production setup, you may fill the `SENTRY_DSN` field in
Expand All @@ -32,8 +32,8 @@ chmod a+w ./work
Taking Monaco (a quick and small one) as an example, once the docker
image is built, you can run Osmose analyzers using:
```
docker-compose --project-name monaco run --rm backend ./osmose_run.py --country=monaco
docker-compose --project-name monaco down # Destroy the loaded data base
docker compose --project-name monaco run --rm backend ./osmose_run.py --country=monaco
docker compose --project-name monaco down # Destroy the loaded data base
```

This will run interactively and you will see the output scrolling on your
Expand Down Expand Up @@ -67,7 +67,7 @@ requiring extra configuration or upload password.

Build the docker image with develop tools included:
```
docker-compose -f docker-compose.yml -f docker-compose-dev.yml build
docker compose -f docker-compose.yml -f docker-compose-dev.yml build
```


Expand All @@ -80,7 +80,7 @@ chmod a+w ../modules/osm_pbf_parser/

Enter the container with:
```
docker-compose -f docker-compose.yml -f docker-compose-dev.yml run --rm backend
docker compose -f docker-compose.yml -f docker-compose-dev.yml run --rm backend
```

On the first execution only, compile the OSM PBF parser:
Expand All @@ -89,7 +89,7 @@ cd modules/osm_pbf_parser/ && make && cd -
```

Note: when exiting the backend, the dependency Database container will still be
running. You can stop it with `docker-compose stop`.
running. You can stop it with `docker compose stop`.


## Access to the Database
Expand All @@ -109,7 +109,7 @@ osmose=> set search_path to monaco,public;

You can Reset the Database and the docker containers with:
```
docker-compose down -v
docker compose down -v
```


Expand All @@ -130,14 +130,14 @@ pytest plugins/TagFix_Housenumber.py

Download and load a country into the Database:
```
docker-compose -f docker-compose.yml -f docker-compose-dev.yml run -p 8888:8888 --rm backend ./osmose_run.py --no-clean --country=monaco --skip-analyser --skip-upload
docker compose -f docker-compose.yml -f docker-compose-dev.yml run -p 8888:8888 --rm backend ./osmose_run.py --no-clean --country=monaco --skip-analyser --skip-upload
```
You do not need to load the country each time. It remains in the Database.


Then run the jupyter-notebook web server:
```
docker-compose -f docker-compose.yml -f docker-compose-dev.yml run -p 8888:8888 --rm backend jupyter-notebook
docker compose -f docker-compose.yml -f docker-compose-dev.yml run -p 8888:8888 --rm backend jupyter-notebook
```
Note the `8888:8888`, which exposes port `8888` to localhost.

Expand All @@ -152,7 +152,7 @@ own analyzer code.

From docker container you can test all the analyzers using:
```
docker-compose -f docker-compose.yml -f docker-compose-dev.yml run --rm backend
docker compose -f docker-compose.yml -f docker-compose-dev.yml run --rm backend
```

To test a specific analyzer:
Expand Down Expand Up @@ -187,16 +187,16 @@ First time build
git clone https://github.com/osmose-qa/osmose-frontend.git
cd osmose-frontend/docker
curl https://osmose.openstreetmap.fr/export/osmose-menu.sql.bz2 | bzcat > osmose-menu.sql
docker-compose build
docker-compose -f docker-compose.yml -f docker-compose-test.yml up -d postgres
docker compose build
docker compose -f docker-compose.yml -f docker-compose-test.yml up -d postgres
# Wait fwe seconds for postgres ready
docker-compose -f docker-compose.yml -f docker-compose-test.yml run --rm api bash -c "cd web_api/static && npm run build"
docker-compose -f docker-compose.yml -f docker-compose-test.yml stop postgres
docker compose -f docker-compose.yml -f docker-compose-test.yml run --rm api bash -c "cd web_api/static && npm run build"
docker compose -f docker-compose.yml -f docker-compose-test.yml stop postgres
```

Run the frontend
```
docker-compose -f docker-compose.yml -f docker-compose-test.yml up
docker compose -f docker-compose.yml -f docker-compose-test.yml up
```

For a detailed description of the procedure see
Expand All @@ -205,7 +205,7 @@ https://github.com/osmose-qa/osmose-frontend/tree/master/docker

To upload the results of the analysis to the frontend, use:
```
docker-compose -f docker-compose.yml -f docker-compose-dev.yml -f docker-compose-frontend.yml run --rm backend bash
docker compose -f docker-compose.yml -f docker-compose-dev.yml -f docker-compose-frontend.yml run --rm backend bash
```

The result will be available at: http://127.0.0.1:8080/en/issues/open?item=xxxx&useDevItem=all
2 changes: 0 additions & 2 deletions docker/docker-compose-dev.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.3'

services:
backend:
build:
Expand Down
2 changes: 0 additions & 2 deletions docker/docker-compose-frontend.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.3'

services:
backend:
volumes:
Expand Down
2 changes: 0 additions & 2 deletions docker/docker-compose-readonly.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.3'

services:
postgis:
volumes:
Expand Down
4 changes: 1 addition & 3 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
version: '3.3'

volumes:
pgdata:

services:
postgis:
shm_size: 1g
image: postgis/postgis:16-3.5-alpine
image: postgis/postgis:17-3.5-alpine
volumes:
- type: bind
source: ./postgis-init.sh
Expand Down
14 changes: 7 additions & 7 deletions docker/public-jupyter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ export COMPOSE_HTTP_TIMEOUT=300
mkdir local && chmod a+w local

# Just build with docker-compose-dev.yml, not for run
docker-compose -f docker-compose.yml -f docker-compose-dev.yml build
docker compose -f docker-compose.yml -f docker-compose-dev.yml build

docker-compose down -v
docker-compose -f docker-compose.yml run -p 8888:8888 --rm backend ./osmose_run.py --no-clean --country=monaco --skip-analyser --skip-upload
docker compose down -v
docker compose -f docker-compose.yml run -p 8888:8888 --rm backend ./osmose_run.py --no-clean --country=monaco --skip-analyser --skip-upload

docker-compose down
docker-compose -f docker-compose.yml -f docker-compose-readonly.yml up -d
docker-compose -f docker-compose.yml -f docker-compose-readonly.yml exec postgis bash /postgres-readonly.sh
# docker-compose -f docker-compose.yml -f docker-compose-readonly.yml run -p 8888:8888 --rm backend jupyter-notebook
docker compose down
docker compose -f docker-compose.yml -f docker-compose-readonly.yml up -d
docker compose -f docker-compose.yml -f docker-compose-readonly.yml exec postgis bash /postgres-readonly.sh
# docker compose -f docker-compose.yml -f docker-compose-readonly.yml run -p 8888:8888 --rm backend jupyter-notebook
Loading
Loading