1
# This program is free software; you can redistribute it and/or modify
2
# it under the terms of the GNU General Public License as published by
3
# the Free Software Foundation; version 2 of the License.
5
# This program is distributed in the hope that it will be useful, but
6
# WITHOUT ANY WARRANTY; without even the implied warranty of
7
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8
# General Public License for more details.
10
# You should have received a copy of the GNU General Public License
11
# along with this program; if not, write to the Free Software
12
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
15
# This script can be used to load the files from
16
# http://www.tm.kit.edu/~mayer/osm2wkt/
17
# into MySQL and PostGIS
25
author = {Christoph P. Mayer},
26
title = {osm2wkt - OpenStreetMap to WKT Conversion},
27
howpublished = {http://www.tm.kit.edu/~mayer/osm2wkt},
31
Map data (c) OpenStreetMap contributors, CC-BY-SA
35
print "DROP TABLE IF EXISTS linestring;\n";
37
if ($ARGV[0] eq 'MySQL') {
38
print "CREATE TABLE linestring (pk INTEGER NOT NULL PRIMARY KEY, linestring_key GEOMETRY NOT NULL, linestring_nokey GEOMETRY NOT NULL) ENGINE=Aria TRANSACTIONAL=0;\n";
39
} elsif ($ARGV[0] eq 'PostGIS') {
40
print "CREATE TABLE linestring (pk INTEGER NOT NULL PRIMARY KEY);\n";
41
print "SELECT AddGeometryColumn('linestring', 'linestring_key', -1, 'GEOMETRY', 2 );\n";
42
print "SELECT AddGeometryColumn('linestring', 'linestring_nokey', -1, 'GEOMETRY', 2 );\n";
48
print "INSERT INTO linestring (pk, linestring_key, linestring_nokey) VALUES ($counter, GeomFromText('$_'), GeomFromText('$_'));\n";
52
if ($ARGV[0] eq 'MySQL') {
53
print "ALTER TABLE linestring ADD SPATIAL KEY (linestring_key);\n";
54
} elsif ($ARGV[0] eq 'MySQL') {
55
print "CREATE INDEX linestring_index ON linestring USING GIST ( linestring_key );\n";