Files
qt5-legatus-legacy/specs/external/qatar_buildings/postProcessingExcon/postProcessingExconQatar.sh
T
2026-08-13 18:33:10 +02:00

374 lines
12 KiB
Bash
Executable File

#!/bin/sh
#
# @RDE_HEADER@
# $Id$
# $HeadURL$
# $Author$
#
env
file_location=`pwd`
echo "Comment: current wd is: " `pwd`
###
### Presets
###
PROJECT="QATAR"
xlsxfile=AHTC_Transformationspunkte_190114_UTM_fuer_FME
SPD_BLDGS=../QatarBuildings/buildings
LOCATIONS_LIST="qatar"
loc="qatar"
echo "Comment: remove some temporary files... revert some other..."
rm -v block*.csv
rm -v ./import_qatar.csv
rm -v ./${xlsxfile}*
rm -v vwm_adjustment*.log
rm -v checkProtective*.log
rm -v checkDuplicateNames*.log
###
### revert *.spec
###
svn revert *.spec
###
### check-out / revert bldgs
###
echo "Comment: revert bldgs: $SPD_BLDGS ..."
## rm -rfv $SPD_BLDGS/bldg_3145_47
svn revert -R $SPD_BLDGS
###
# remove uneeded: bldg_hierarchie.flt, directory bldg_EGCU_test
###
rm -v $SPD_BLDGS/bldg_hierarchie.flt
rm -rfv $SPD_BLDGS/bldg_EGCU_test
mv -v $SPD_BLDGS/bldg_3145-47 $SPD_BLDGS/bldg_3145_47
find $SPD_BLDGS -iname "*egcu2room*" -delete
find $SPD_BLDGS -iname "*.wrl" -delete
find $SPD_BLDGS -iname "*.patch" -delete
###
# fix syntax: bldg_3141_26.flt.VWM_Building.xml
###
BEFORE="<ExclusionZoneProtectiveFactor>20<\/OuterWallProtectiveFactor>"
AFTER="<OuterWallProtectiveFactor>20<\/OuterWallProtectiveFactor>"
#sed -i "s/${BEFORE}/${AFTER}/g" $SPD_BLDGS/bldg_3141_26/bldg_3141_26.flt.VWM_Building.xml
# if [ $? -ne 0 ]; then echo "sed command failed" ; fi
# Fix bldg_3101 (16.787/16.786 ; remove linear dependencies (GUEZE-605, GUEZE-717 ; CheckAwesOnBldg_3101_verteilt.sh)
#sed -i 's/16.787/16.786/g' $SPD_BLDGS/bldg_3101/bldg_3101.flt.xml
#sed -i 's/16.787/16.786/g' $SPD_BLDGS/bldg_3101/bldg_3101.flt.VWM_Building.xml
###
### Apply some patches: early to be idenpendent from modifications by replace_transistion_factors etc.
###
# Do it here, because the final xml structure is avaible now (node.js converts to json and back to xml....)
#
# fix Bbox / placement of 4 roomnames at 3101: 102, 108, 109, 112
#
# diff -Naur ./bldg_3100/bldg_3100.flt.VWM_Building.xml ./bldg_3100/bldg_3100.flt.VWM_Building.xmlOKAY
#
#cp -v ./patches/* $SPD_BLDGS
# if [ $? -ne 0 ]; then echo "copy command (patches) failed" ; fi
#pushd $SPD_BLDGS
# if [ $? -ne 0 ]; then echo "cd command failed" ; fi
#echo "Comment: cd building ; patching.."
#echo "Comment: current wd is: " `pwd`
#dos2unix ./bldg_3101/bldg_3101.flt.xml
#cp ./bldg_3101/bldg_3101.flt.xml ./bldg_3101/bldg_3101.flt.xml_bak
#patch -p1 < patch_bldg_3101.flt.xml.patch
# if [ $? -ne 0 ]; then echo "patch (patch_bldg_3101.flt.xml.patch) failed" ; exit ; fi
# popd
###
### update ProtectiveFactor, see https://devhub.defence-elec.de/jira/browse/MNQ-481
### (introduced in 2024 for qatar/qatar-mout)
###
echo "Comment: updateProtectiveFactor ..."
echo "Comment: current wd is: " `pwd`
./updateProtective.sh > updateProtectiveQatar.log
updateProtectiveErrorCnt=`cat updateProtectiveQatar.log | grep "failure" | wc -l`
echo -e "Comment: Problems regarding updating protectiveFactors at some files: cnt: $updateProtectiveErrorCnt"
###
### check ProtectiveFactor according VEMAG
###
# Wall -> 150
# Ceiling -> 150
# ExclusiveDoor -> 20
# ExclusiveWindow -> 0
#
echo "Comment: checkProtectiveFactors ..."
echo "Comment: current wd is: " `pwd`
./checkProtective.sh > checkProtectiveQatar.log
protectiveErrorCnt=`cat checkProtectiveQatar.log | grep "failure" | wc -l`
echo -e "Comment: Problems regarding wrong protectiveFactors at some files: cnt: $protectiveErrorCnt"
###
### xmllint
###
echo "Comment: verify xml using xmllint on $SPD_BLDGS ..."
rm /tmp/xmllintDummyout.xml
find $SPD_BLDGS -iname "*.xml" | xargs xmllint > /tmp/xmllintDummyout.xml
if [ $? -ne 0 ]; then
echo "xmllint failed" ; exit
else
echo "xmllint successfull"
fi
###
### check duplicate names
###
echo "Comment: check duplicate names on $SPD_BLDGS ..."
./checkDuplicateNames.sh $SPD_BLDGS > checkDuplicateNames.log
checkDuplicateNamesCnt=`cat checkDuplicateNames.log | grep "flt" | wc -l`
echo -e "Comment: Problems regarding duplicate Names at some files: cnt: $checkDuplicateNamesCnt"
###
### update _Transformationspunkte
###
####
echo "Comment: update _Transformationspunkte......"
cd $SPD_BLDGS/../_Transformationspunkte
svn up --username thoden --password SPDsvnTH
cd -
####
###
### Create VERSION_STR (containing a) rev of SPD and b) of this scripts)
###
# result will look like '4573.53084'
#
echo "Comment: create VERSION_STR..."
echo "Comment: current wd is: " `pwd`
# get last mod rev and remove whitespace
VERSION_POST_PROC=`svn info . | grep -E 'Letzte ge|Last Changed Rev' | awk -F ':' '{print $2 }'`
VERSION_POST_PROC=`echo $VERSION_POST_PROC | sed -e 's/[[:space:]]*$//'`
echo "VERSION_POST_PROC = '$VERSION_POST_PROC'"
#####TODO##### if [ -z "$VERSION_POST_PROC" ] ; then echo "VERSION_POST_PROC could not be determined" ; exit; fi
# get lst mod rev and remove whitespace
VERSION1=`svn info $SPD_BLDGS | grep -E 'Letzte ge|Last Changed Rev' | awk -F ':' '{print $2 }'`
VERSION1=`echo $VERSION1 | sed -e 's/[[:space:]]*$//'`
echo "VERSION1 = '$VERSION1'"
if [ -z "$VERSION1" ] ; then echo "VERSION1 could not be determined" ; exit; fi
VERSION2=`svn info $SPD_BLDGS/../_Transformationspunkte | grep -E 'Letzte ge|Last Changed Rev' | awk -F ':' '{print $2 }'`
VERSION2=`echo $VERSION2 | sed -e 's/[[:space:]]*$//'`
echo "VERSION2 = '$VERSION2'"
if [ -z "$VERSION2" ] ; then echo "VERSION2 could not be determined" ; exit; fi
if (( $VERSION1 > $VERSION2 )); then
VERSION_SPD_BLDGS=$VERSION1;
else
VERSION_SPD_BLDGS=$VERSION2;
fi
#####TODO##### if [ -z "$VERSION_POST_PROC" ] ; then echo "VERSION_SPD_BLDGS could not be determined" ; exit; fi
# Please do not add strings to VERSION_STR. rpm -Uhv will have problem with it....
echo "VERSION_SPD_BLDGS = '$VERSION_SPD_BLDGS'"
#####TODO##### echo "VERSION_POST_PROC = '$VERSION_POST_PROC'"
VERSION_STR="${VERSION_SPD_BLDGS}.${VERSION_POST_PROC}"
echo "VERSION_STR = '$VERSION_STR'"
###
### vwm_adjustment
###
# NodeJS:
# multiple dirs: 1st for jenkins, 2nd for CTCAP15/Norbert
export NODE_PATH='/usr/lib/node_modules:../node_modules'
echo "Comment: NODE_PATH=" $NODE_PATH
echo "Comment: vwm_adjustment at dir $SPD_BLDGS"
node ./vwm_adjustment/RECURSIV/pos_dir_guez.js $SPD_BLDGS &> vwm_adjustmentQatar.log
if [ $? -ne 0 ];
then echo " node vwm_adjustment failed" ; tail -n200 vwm_adjustmentQatar.log;
exit
else
echo " node vwm_adjustment finished";
fi
# Renoir-repos has xml files without svn:eol-style.
# So 'svn co' on unix will create files with CR+LF (Windows EOL)
# To ensure usefull 'svn diff' showing only the real differences, convert to CR+LF:
# execute unix2dos on all files adjusted (vwm_adjustment)
echo "Comment: unix2dos (quiet)"
find $FILE -name "*flt.xml" | xargs unix2dos -q
find $FILE -name "*VWM_Building.xml" | xargs unix2dos -q
# for debug:
# svn st ../GuezBuildings/buildings/bldg_0910/
# svn diff ../GuezBuildings/buildings/bldg_0910/
# svn diff ../GuezBuildings/buildings/bldg_0910/bldg_0910.flt.xml
### seperate sheets:
# xlsx to xls
### FILE=$SPD_BLDGS/../_Transformationspunkte/${xlsxfile}.xlsx
### if [ ! -f "$FILE" ]; then echo "$FILE does not exist." ; exit; fi
### cp -v $FILE .
### if [ $? -ne 0 ]; then echo "copy command failed" ; fi
### FILE=./${xlsxfile}.xlsx
### if [ ! -f "$FILE" ]; then echo "$FILE does not exist." ; exit; fi
### soffice --headless --convert-to SOFFICE_CONVERTED.xls $FILE
#-> GUEZ_BWDLZ_BA-0_BA-IV_Transformationspunkte_201210.SOFFICE_CONVERTED.xls
### if [ $? -ne 0 ]; then echo "soffice command failed" ; fi
### # xls to csv
### echo "Comment: xlsx to xls..."
### xlsfile=${xlsxfile}.SOFFICE_CONVERTED.xls
### echo "Comment: xls to single csv files..."
### xls2csv -x ${xlsfile} -n1 -c block_a.csv
### xls2csv -x ${xlsfile} -n2 -c block_b.csv
### xls2csv -x ${xlsfile} -n3 -c block_c.csv
### xls2csv -x ${xlsfile} -n4 -c block_d.csv
### xls2csv -x ${xlsfile} -n5 -c block_e.csv
### xls2csv -x ${xlsfile} -n6 -c block_f.csv
### xls2csv -x ${xlsfile} -n7 -c block_g.csv
### xls2csv -x ${xlsfile} -n8 -c block_h.csv
### xls2csv -x ${xlsfile} -n9 -c block_i.csv
### xls2csv -x ${xlsfile} -n10 -c block_cts.csv
#####TODO#####
# sort
### for loc in ${LOCATIONS_LIST}
### do
### cat block_${loc}.csv | sort > temp.txt
### mv temp.txt block_${loc}.csv
### done
### rm temp.txt
# replace some strings
# like BN_Kan -> BN_Kanaele and so on
#sed -i 's/BN_Kan/BN_Kanaele/g' GUEZ_BWDLZ_salchau.csv
# if [ $? -ne 0 ]; then echo "sed command failed" ; fi
###
### convert_coordinate.py
###
#echo "Comment: convert_coordinates.py angles"
#echo "Comment: current wd is: " `pwd`
# FILE=./convert_coordinates.py
# if [ ! -f "$FILE" ]; then echo "$FILE does not exist." ; exit; fi
###
### convert_coordinate.py has problem with BN_B4,B5 and some more.
### -> Use import_ahtc_instrumented.csv
###
echo "Comment: current wd is: " `pwd`
cp ./import_qatar_instrumented.csv ./import_qatar.csv
#####TODO#####for loc in ${LOCATIONS_LIST}
#####TODO#####do
#####TODO##### csv_cnt=`cat import_${loc}.csv | grep -v "^#" | wc -l`
#####TODO##### python ./convert_coordinates.py GUEZ_BWDLZ_${loc}.csv ./import_${loc}.csv
#####TODO##### cat GUEZ_BWDLZ_${loc}.csv | sort > temp.txt
#####TODO##### mv temp.txt GUEZ_BWDLZ_{loc}.csv
#####TODO#####done
### python ./convert_coordinates.py
###
### Copy some files to $SPD_BLDGS
###
echo "Comment: cd building ; osgconv.sh"
echo "Comment: current wd is: " `pwd`
cp -v ./osgconv.sh $SPD_BLDGS
if [ $? -ne 0 ]; then echo "copy command (osgconv.sh) failed" ; fi
pushd $SPD_BLDGS
if [ $? -ne 0 ]; then echo "cd command failed" ; fi
./osgconv.sh $VERSION_STR qatar ${file_location}/import_qatar.csv
# back to location of this file :-)
popd
echo "Comment: rpmbuild..."
echo "Comment: current wd is: " `pwd`
###
### Prepare spec files:
###
echo "Comment: replace some vars at *.spec"
echo "VERSION_STR = '$VERSION_STR'"
sed -i "s/@VERSION@/$VERSION_STR/g" qatar_buildings_buildingviewer.spec
if [ $? -ne 0 ]; then echo "sed command failed" ; fi
###
### JENKINS:
###
if [ -z "$BUILD_TAG" ] ; then echo "JENKINS BUILD_TAG not defined, set to '-'" ; BUILD_TAG="NoTag" ; fi
if [ -z "$BUILD_NUMBER" ] ; then echo "JENKINS BUILD_NUMBER not defined, set to '0'" ; BUILD_NUMBER=0 ; fi
JENKINS_BUILD_TAG="${BUILD_TAG}"
echo "JENKINS_BUILD_TAG: ${JENKINS_BUILD_TAG}"
sed -i "s/@JENKINS_BUILD_TAG@/${JENKINS_BUILD_TAG}/g" qatar_buildings_buildingviewer.spec
if [ $? -ne 0 ]; then echo "sed command JENKINS_BUILD_TAG failed" ; fi
sed -i "s/@RELEASE@/${BUILD_NUMBER}/g" qatar_buildings_buildingviewer.spec
if [ $? -ne 0 ]; then echo "sed command RELEASE failed" ; fi
rpmbuild -bb --target=noarch qatar_buildings_buildingviewer.spec
if [ $? -ne 0 ]; then echo "rpmbuild command failed for spec 'qatar_buildings_${loc}_buildingviewer.spec'" ; fi
echo "rpmbuild... finished"
csv_cnt_sum=0
rpm_cnt_sum=0
csv_cnt=`cat import_${loc}.csv | grep -v "^#" | wc -l`
rpm_cnt=`rpm -ql ~/rpmbuild/RPMS/noarch/qatar_buildings_buildingviewer-${VERSION_STR}-0.noarch.rpm | grep flt.xml | wc -l`
echo -e "Comment: #bldgs: csv: $csv_cnt \t - rpm: $rpm_cnt \t at import_${loc}.csv"
csv_cnt_sum=$(($csv_cnt_sum + $csv_cnt))
rpm_cnt_sum=$(($rpm_cnt_sum + $rpm_cnt))
echo -e "Comment: #bldgs: csv: $csv_cnt_sum \t - rpm: $rpm_cnt_sum - Over all"
### echo "Comment: Problems of EGCU_CONF..."
### grep "EGCU pro Etage" vwm_adjustment.log | sort -u
### grep "EGCU pro Etage" vwm_adjustment.log | sort -u | wc -l
echo -e "Comment: Problems regarding wrong protectiveFactors at some files: cnt: $protectiveErrorCnt"
echo -e "Comment: Problems regarding duplicate Names at some files: cnt: $checkDuplicateNamesCnt"
## JENKINS?
if [ -z ${WORKSPACE} ]
then
echo "rpmbuild... move to - skipped"
else
echo "rpmbuild... move to "
echo "VERSION_STR = '$VERSION_STR'"
DST_DIR=${WORKSPACE}/rpms/
mkdir ${DST_DIR}
mv -v ~/rpmbuild/RPMS/noarch/qatar_buildings*$VERSION_STR*.rpm ${DST_DIR}
fi