jablonka.czprosek.czf

czfgmap

Subversion Repositories:
[/] [tools/] [gendb] - Blame information for rev 10

 

Line No. Rev Author Line
17simandl#!/bin/bash
2#<!-- Copyright (C) 2008 Petr Simandl www.simandl.cz -->
3#<!-- This file is part of CZFGmap. -->
4#<!-- -->
5#<!-- CZFGmap is free software: you can redistribute it and/or modify -->
6#<!-- it under the terms of the GNU General Public License as published by -->
7#<!-- the Free Software Foundation, either version 3 of the License, or -->
8#<!-- (at your option) any later version. -->
9#<!-- -->
10#<!-- CZFGmap is distributed in the hope that it will be useful, -->
11#<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of -->
12#<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -->
13#<!-- GNU General Public License for more details. -->
14#<!-- -->
15#<!-- You should have received a copy of the GNU General Public License -->
16#<!-- along with CZFGmap. If not, see <http://www.gnu.org/licenses/>. -->
17 
18datum=`date '+%Y%m%d%H%M%S'`
19 
20outputfilen="out_node.sql"
21outputfilel="out_line.sql"
22 
23#stahnem nody a linky
24if [ ! -e listnodes_${datum}.txt ]
25then
26# echo "neni tu ";
27 wget http://mapa.czfree.net/listnodes.php -O listnodes_${datum}.txt
28fi
29 
30if [ ! -e listlines_${datum}.txt ]
31then
32# echo "neni tu ";
33 wget http://mapa.czfree.net/listlines.php -O listlines_${datum}.txt
34fi
35 
36if [ -e listnodes_${datum}.txt ]
37then
38# echo "nodes do utf";
39 iconv -f windows-1250 -t utf8 listnodes_${datum}.txt --output listnodesutf.txt
40fi
41 
42if [ -e listnodesutf.txt ]
43then
44# echo "delam tabulku node";
45cat > $outputfilen <<EOF
46DROP TABLE node;
47CREATE TABLE node (
48 id int(10) unsigned NOT NULL auto_increment,
49 lat double NOT NULL default '0',
50 lon double NOT NULL default '0',
51 ownerid int(10) unsigned NOT NULL default '0',
52 networkid int(11) NOT NULL default '0',
53 type mediumint(8) unsigned NOT NULL default '0',
54 status tinyint(3) unsigned NOT NULL default '0',
55 admingroup int(11) default NULL,
56 ostype int(11) default NULL,
57 osversion int(11) default NULL,
58 name varchar(100) default NULL,
59 address varchar(120) default NULL,
60 urlphotos varchar(90) default NULL,
61 urlhomepage varchar(60) default NULL,
62 urlthread varchar(60) default NULL,
63 visibilitydesc blob,
64 changed_by int(10) unsigned default NULL,
65 changed_on datetime default NULL,
66 align int(11) default '0',
67 peoplecount smallint(5) unsigned default NULL,
68 machinecount smallint(5) unsigned default NULL,
69 peoplehide enum('0','1') NOT NULL default '0',
70 machinehide enum('0','1') NOT NULL default '0',
71 ownername varchar(100) default NULL,
72 PRIMARY KEY (id),
73 UNIQUE KEY name (name),
74 KEY lat_2 (lat),
75 KEY lat_3 (lat),
76 KEY id (id),
77 KEY lat (lat),
78 KEY lon (lon),
79 KEY ownerid (ownerid),
80 KEY Type (type)
81) TYPE=MyISAM PACK_KEYS=0;
82EOF
83 
84cat listnodesutf.txt | \
85sed 's/^\[//' | \
86sed 's/^\([0-9]*\)\]/\1/' | \
87sed 's/\\/\\\\/' | \
88sed 's/'\''/\\'\''/' | \
89awk -F "\t" '{print "INSERT INTO node VALUES ("$1","$2","$3",0,1,1,"$4",1,1,1,'\''"$6"'\'','\'\'','\'\'','\'\'','\'\'','\'\'',440,'\''2008-01-01 01:01:01'\'',0,NULL,NULL,'\'\'','\'\'','\''"$5"'\'');"}' | \
90uniq >> $outputfilen
91 
92fi
93 
94if [ -e listlines_${datum}.txt ]
95then
96# echo "delam tabulku line";
97cat > $outputfilel <<EOF
98DROP TABLE line;
99CREATE TABLE line (
100 id1 int(10) unsigned NOT NULL default '0',
101 id2 int(10) unsigned NOT NULL default '0',
102 type mediumint(8) unsigned zerofill NOT NULL default '00000000',
103 status tinyint(1) unsigned NOT NULL default '0',
104 perm1 tinyint(1) unsigned NOT NULL default '0',
105 perm2 tinyint(1) unsigned NOT NULL default '0',
106 changed_by int(10) unsigned default NULL,
107 changed_on datetime default NULL,
108 backbone tinyint(1) unsigned NOT NULL default '0',
109 inplanning tinyint(1) unsigned NOT NULL default '0',
110 comment varchar(128) NOT NULL default '',
111 PRIMARY KEY (id1,id2),
112 KEY id1 (id1),
113 KEY id2 (id2),
114 KEY last (changed_on),
115 KEY backbone (backbone),
116 KEY inplanning (inplanning)
117) TYPE=MyISAM;
118EOF
119 
120cat listlines_${datum}.txt | \
121sed 's/\[\([0-9]*\)\]/\1/g' | \
122awk -F "\t" '{print "INSERT INTO line VALUES ("$1","$2","$3",0,40,40,88,'\''2008-01-01 01:01:01'\'',0"$4",0,'\'\'');"}' | \
123uniq >> $outputfilel
124 
125fi
126 
127 
128 
129 

Powered by WebSVN 2.2.1