Giter Site home page Giter Site logo

Comments (5)

Gustry avatar Gustry commented on June 30, 2024

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();

from docker-osm.

timlinux avatar timlinux commented on June 30, 2024

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

from docker-osm.

NyakudyaA avatar NyakudyaA commented on June 30, 2024

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

from docker-osm.

Gustry avatar Gustry commented on June 30, 2024

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

from docker-osm.

NyakudyaA avatar NyakudyaA commented on June 30, 2024

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

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

from docker-osm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.