-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata2db.sh
executable file
·102 lines (88 loc) · 3.09 KB
/
data2db.sh
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/sh
dbNames=( 'Northern_San_Andreas_Fault' );
Dirs=( 'NSAF' );
for ((j=0;j<"${#Dirs[*]}";j=j+1)); do
cd ${Dirs[$j]};
echo "in directory: "${Dirs[$j]};
EPSG=$(<EPSG.txt);
count=1;
for laz in `ls *.laz`; do
xmlfile=${laz%.laz}.xml;
touch ${xmlfile};
jsonfile=${laz%.laz}.json;
touch ${jsonfile};
txtfile=${laz%.laz}.txt;
if [ "$count" -eq 1 ]; then
echo '<?xml version="1.0" encoding="utf-8"?>
<Pipeline version="1.0">
<Writer type="writers.pgpointcloud">
<Option name="connection">host='"'"'localhost'"'"' dbname='"'${dbNames[$j]}'"' user='"'"'ericrussell'"'"'</Option>
<Option name="table">lidar</Option>
<Filter type="filters.chipper">
<Option name="capacity">400</Option>
<Reader type="readers.text">
<Option name="filename">'"${txtfile}"'</Option>
<Option name="spatialreference">EPSG:'"${EPSG}"'</Option>
</Reader>
</Filter>
</Writer>
</Pipeline>' > ${xmlfile};
else
echo '<?xml version="1.0" encoding="utf-8"?>
<Pipeline version="1.0">
<Writer type="writers.pgpointcloud">
<Option name="connection">host='"'"'localhost'"'"' dbname='"'${dbNames[$j]}'"' user='"'"'ericrussell'"'"'</Option>
<Option name="table">lidar</Option>
<Option name="overwrite">false</Option>
<Filter type="filters.chipper">
<Option name="capacity">400</Option>
<Reader type="readers.text">
<Option name="filename">'"${txtfile}"'</Option>
<Option name="spatialreference">EPSG:'"${EPSG}"'</Option>
</Reader>
</Filter>
</Writer>
</Pipeline>' > ${xmlfile};
fi
: <<'END'
echo '<?xml version="1.0" encoding="utf-8"?>
<Pipeline version="1.0">
<Writer type="writers.pgpointcloud">
<Option name="connection">host='"'"'localhost'"'"' dbname='"'${dbNames[$j]}'"' user='"'"'ericrussell'"'"'</Option>
<Option name="table">lidar</Option>
<Option name="overwrite">false</Option>
<Filter type="filters.chipper">
<Option name="capacity">400</Option>
<Reader type="readers.text">
<Option name="filename">'"${txtfile}"'</Option>
<Option name="spatialreference">EPSG:'"${EPSG}"'</Option>
</Reader>
</Filter>
</Writer>
</Pipeline>' > ${xmlfile};
END
echo '{
"pipeline":[
{
"type":"readers.las",
"filename":"'"${laz}"'"
},
{
"type":"writers.text",
"order":"X,Y,Z",
"keep_unspecified":"false",
"quote_header":"false",
"filename":"'"${txtfile}"'"
}
]
}' > ${jsonfile};
pdal pipeline ${jsonfile};
pdal pipeline --input ${xmlfile};
rm ${jsonfile};
rm ${xmlfile};
rm ${txtfile};
echo " finished: "${count}"/"`ls *.laz | wc -l`;
count=$((count+1));
done
cd ..;
done