1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
#!/usr/bin/env perl
#
# PostGIS - Spatial Types for PostgreSQL
# http://postgis.net
#
# Copyright (C) 2016 Sandro Santilli <strk@kbt.io>
#
# This is free software; you can redistribute and/or modify it under
# the terms of the GNU General Public Licence. See the COPYING file.
#
use warnings;
use strict;
(@ARGV) ||
die "Usage: perl $0 <spatial_ref_sys>\n" .
"Creates an SQL script to mark system records of spatial_ref_sys.\n";
my $SRSFILE=$ARGV[0];
open SRSFILE, "<$SRSFILE" || die "Can't open $SRSFILE for reading\n";
my @SRIDS = ();
while (<SRSFILE>) {
/^\(([0-9]+),/ || next;
push @SRIDS, $1;
}
@SRIDS = sort {$b <=> $a} @SRIDS;
print "SELECT pg_catalog.pg_extension_config_dump('spatial_ref_sys',";
print " 'WHERE NOT (\n";
my $OR="";
while (@SRIDS)
{
my $min = pop @SRIDS;
#print "min:$min\n";
# Find upper bound
my $max = $min;
while (@SRIDS)
{
#print "next:$SRIDS[@SRIDS-1]\n";
last if ( $SRIDS[@SRIDS-1] != $max+1 );
$max = pop @SRIDS
};
if ( $min != $max ) {
print $OR . "srid BETWEEN $min AND $max\n";
} else {
print $OR . "srid = $min\n";
}
$OR = "OR ";
}
print join ",\n", @SRIDS;
print ")');"
#mark_editable_objects.sql.in
|