~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to tests/kewpie/randgen/conf/gis/wkt2sql.pl

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.1.6)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20120619104649-e2l0ggd4oz3um0f4
Tags: upstream-7.1.36-stable
ImportĀ upstreamĀ versionĀ 7.1.36-stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.
 
4
#
 
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.
 
9
#
 
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
 
13
# USA
 
14
 
 
15
# This script can be used to load the files from
 
16
# http://www.tm.kit.edu/~mayer/osm2wkt/ 
 
17
# into MySQL and PostGIS
 
18
 
 
19
use strict;
 
20
 
 
21
print '
 
22
/*
 
23
 
 
24
@MISC{mayer2010osm,
 
25
  author = {Christoph P. Mayer},
 
26
  title = {osm2wkt - OpenStreetMap to WKT Conversion},
 
27
  howpublished = {http://www.tm.kit.edu/~mayer/osm2wkt},
 
28
  year = {2010}
 
29
 
30
 
 
31
Map data (c) OpenStreetMap contributors, CC-BY-SA
 
32
 
 
33
*/'."\n";
 
34
 
 
35
print "DROP TABLE IF EXISTS linestring;\n";
 
36
 
 
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";
 
43
}
 
44
 
 
45
my $counter = 1;
 
46
while (<STDIN>) {
 
47
        chomp $_;
 
48
        print "INSERT INTO linestring (pk, linestring_key, linestring_nokey) VALUES ($counter, GeomFromText('$_'), GeomFromText('$_'));\n";
 
49
        $counter++;
 
50
}
 
51
 
 
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";
 
56
}