Advertisement
cd62131

Parce JSP and Split each town

Nov 30th, 2013
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.25 KB | None | 0 0
  1. #!/bin/bash -ef
  2. typeset -g PREFIX=''
  3. if [[ $# != 2 ]]
  4. then
  5.   cat <<USAGE
  6. usage: $0 zip_dir dest_dir
  7. USAGE
  8.   exit 1
  9. fi
  10. mkdir -p $2
  11. find $1 -name 'N*.zip' -exec unzip -u '{}' -d $2 ';'
  12. cd $2
  13. find . -name 'N*.xml' -exec cat '{}' '+' | xml2 | \
  14. awk -F= \
  15.   -v OFS='=' \
  16.   "\$1 ~ /GM_Point\/@id/{ \
  17.     f = \$2; \
  18.     print \"/ksj:GI/dataset/ksj:object/ksj:AA01/ksj:OBJ/jps:GM_Point/\" > f } \
  19.   /GM_Point\/@id/,/dimension/{ print > f } \
  20.   \$1 ~ /GM_Curve\/@id/{ \
  21.     f = \$2; \
  22.     print \"/ksj:GI/dataset/ksj:object/ksj:AA01/ksj:OBJ/jps:GM_Curve/\" > f } \
  23.   /GM_Curve\/@id/, \
  24.   /GM_OrientableCurve\/jps:GM_OrientablePrimitive\.primitive\/@idref/{ \
  25.    print > f } \
  26.   \$1 ~ /GM_Surface\/@id/{ \
  27.     f = \$2; \
  28.     print \"/ksj:GI/dataset/ksj:object/ksj:AA01/ksj:OBJ/jps:GM_Surface/\" > f } \
  29.   /GM_Surface\/@id/,/GM_CompositeCurve\.generator\/@idref/{ print > f } \
  30.   \$1 ~ /EC01\/@id/{ \
  31.     f = \$2; \
  32.     print \"/ksj:GI/dataset/ksj:object/ksj:AA01/ksj:OBJ/ksj:EC01/\" > f } \
  33.   /EC01\/@id/,/EC01\/ksj:AAC=/{ print > f } \
  34.   { i++; if (i % 100000 == 0) { printf \".\" } } \
  35.   "
  36. find . -name 'ar*' -delete
  37. find . -name 'aac*' -delete
  38. typeset -i i
  39. (( i = 1 ))
  40. for ec in $(find . -name 'EC*')
  41. do
  42.   (( i++ ))
  43.   if [[ $(( i >> 32 > 0 )) ]]; then echo -n '.'; (( i = 1 )); fi
  44.   area=$(grep -Po '(?<=idref=)a\d+' ${ec})
  45.   echo ${area} >> ar${area#a}
  46.   aac=$(grep -Po '(?<=AAC=)\d+' ${ec})
  47.   echo ${area} >> aac${aac}
  48.   echo ${ec#./} >> aac${aac}
  49.   curve=$(grep -Po '(?<=idref=_)c\d+' ${area})
  50.   echo ${curve} >> ar${area#a}
  51.   typeset -a point=($(grep -Po '(?<=idref=)n\d+' ${curve}))
  52.   for p in ${point[@]}
  53.   do
  54.     echo ${p} >> ar${area#a}
  55.   done
  56. done
  57. (( i = 1 ))
  58. for aac in $(find . -name 'aac*')
  59. do
  60.   (( i++ ))
  61.   if [[ $(( i % 1000000 == 0 )) ]]; then echo -n '.'; fi
  62.   rm -f temp1 temp2
  63.   for area in $(cat ${aac} | grep -v '^EC' | sort -u)
  64.   do
  65.     cat ar${area#a}
  66.   done | \
  67.   sed 's/^\([a-z]\)/\1 /' | \
  68.   sort -k1.1r -k2.1n -u | \
  69.   tr -d ' ' | \
  70.   while read dat
  71.   do
  72.     cat ${dat} >> temp1
  73.   done
  74.   for area in $(cat ${aac} | grep '^EC' | sort -u)
  75.   do
  76.     cat ${area} >> temp2
  77.   done
  78.   cat temp1 temp2 | 2xml | tidy -xml -utf8 > "${PREFIX}${aac#./aac}.xml" 2>/dev/null
  79.   rm -f temp1 temp2
  80. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement