]>
pere.pagekite.me Git - homepage.git/blob - gis/openstreetmap/pcode-location-update
3 # Create postgis database from the postal code
5 # Author: Petter Reinholdtsen <pere@hungry.com>
7 # Lisence: GNU Public Lisence
9 my $dbtable = "postal_codes";
14 CREATE TABLE $dbtable (
15 postal_code text NOT NULL PRIMARY KEY,
18 SELECT AddGeometryColumn('','$dbtable','center_point', '-1','POINT', 2);
19 SELECT AddGeometryColumn('','$dbtable','area', '-1','POLYGON', 2);
25 my ($postal_code, $lat, $lon) = @_;
27 INSERT INTO $dbtable (postal_code, center_point)
28 VALUES ('$postal_code', GeometryFromText('POINT($lon $lat)', -1));
35 SELECT DropGeometryColumn('','$dbtable','center_point');
36 SELECT DropGeometryColumn('','$dbtable','area');
44 open(FILE
, "<pcode-location.txt") or
45 die "Unable to read pcode-location.txt";
50 my ($postal_code, $lat, $lon) = split;
51 print insert_location
($postal_code, $lat, $lon);
59 # Location of postal area codes in Norway. The values are aproximate.
61 # Author: Petter Reinholdsten <pere@hungry.com>
64 # Updates and corrections are most welcome. The accurasy is unknown,
65 # as the positions are based on a random set of addresses with the
68 # zip latitude longitude