Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if the clipping for diff works #20

Closed
Gustry opened this issue Dec 17, 2015 · 5 comments
Closed

Check if the clipping for diff works #20

Gustry opened this issue Dec 17, 2015 · 5 comments
Labels

Comments

@Gustry
Copy link
Collaborator

Gustry commented Dec 17, 2015

OSM Update can't clip a diff file : http://wiki.openstreetmap.org/wiki/Osmconvert#Clipping_OSM_Change_Files.3F
So the poly file is useless ...

Like osmosis, we can run this kind of SQL script to delete everything outside a bbox or WKT :
http://wiki.openstreetmap.org/wiki/User:Stephankn/knowledgebase#Cleanup_of_ways_outside_the_bounding_box

@Gustry Gustry added the bug label Dec 17, 2015
@Gustry
Copy link
Collaborator Author

Gustry commented Dec 23, 2015

Work in progress :

CREATE OR REPLACE FUNCTION clean_tables() RETURNS void AS $$
DECLARE osm_tables CURSOR FOR 
    SELECT table_name
    FROM information_schema.tables
    WHERE table_schema='public'
    AND table_type='BASE TABLE'
    AND table_name LIKE 'osm_%';
BEGIN
    FOR osm_table IN osm_tables LOOP
        EXECUTE 'DELETE FROM ' || quote_ident(osm_table.table_name) || ' USING clip WHERE ST_Disjoint(geom,geometry);';
    END LOOP;
END;
$$ LANGUAGE plpgsql;

select clean_tables();

Or better with multi rows :

CREATE OR REPLACE FUNCTION clean_tables() RETURNS void AS
$BODY$
DECLARE osm_tables CURSOR FOR 
    SELECT table_name
    FROM information_schema.tables
    WHERE table_schema='public'
    AND table_type='BASE TABLE'
    AND table_name LIKE 'osm_%';
BEGIN
    FOR osm_table IN osm_tables LOOP
    EXECUTE 'DELETE FROM ' || quote_ident(osm_table.table_name) || ' WHERE osm_id IN (
            SELECT DISTINCT osm_id
            FROM ' || quote_ident(osm_table.table_name) || ' 
            LEFT JOIN clip ON ST_Intersects(geometry, geom)
            WHERE clip.id IS NULL)
        ;';
    END LOOP;
END;
$BODY$
LANGUAGE plpgsql;

select clean_tables();

@timlinux
Copy link
Contributor

Maybe its not necessary these days but it might be worth checking if vacuuming the db after doing bulk deletes is a good idea.

This was referenced Dec 29, 2015
@NyakudyaA
Copy link
Collaborator

Not useful now as imposm3 natively supports this. You can use a GeoJSON file to limit the geometries on import

@Gustry
Copy link
Collaborator Author

Gustry commented May 9, 2020

Do you mean you are going to make the clip shapefile deprecated and add the note about this new geojson file?

@NyakudyaA
Copy link
Collaborator

Hi @Gustry it is already deprecated and we have added it to the description

https://github.com/kartoza/docker-osm#clipping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants