def parseFile(sKey: str, oFile: dict) -> bool: oLog.info(aixmParserId + " --> parseFile() by aixmReader.AixmControler()", outConsole=True) bpaTools.createFolder( oFile[poaffCst.cstSpOutPath]) #Init dossier de sortie aixmCtrl = aixmReader.AixmControler(oFile[poaffCst.cstSpSrcFile], oFile[poaffCst.cstSpOutPath], sKey, oLog) #Init controler ret = aixmCtrl.execParser(oOpts, catalogConstruct) #Execution des traitements return ret
def makeAllFiles(sSrcPath: str, sSrcOpenairFile: str, sDstPath: str, sRootSchemaLocation: str) -> None: bpaTools.createFolder(sDstPath) #Init dossier if not copyFile(sSrcPath, sSrcOpenairFile, sDstPath, sSrcOpenairFile): None else: #Files names sSrcOriginFile: str = sSrcOpenairFile.replace(".txt", "_org.txt") sSrcFinalFile: str = sSrcOpenairFile.replace(".txt", "_final.txt") sAixmFile: str = sSrcOpenairFile.replace(".txt", "_aixm45.xml") sGeojsonFile: str = sSrcOpenairFile.replace(".txt", ".geojson") sKmlFile: str = sSrcOpenairFile.replace(".txt", ".kml") #Aixm generator makeOpenair2Aixm(sDstPath, sSrcOpenairFile, sDstPath, sAixmFile, sRootSchemaLocation) #Rename original file with "_org" flag renameFile(sDstPath, sSrcOpenairFile, sDstPath, sSrcOriginFile) #GeoJSON generator iPrevErr: int = oLog.CptCritical + oLog.CptError #Nombre d'erreurs en pré-traitements makeAixm2Geojson(sDstPath, sAixmFile, sDstPath, sGeojsonFile) iActErr: int = oLog.CptCritical + oLog.CptError #Nombre d'erreurs en post-traitements if iActErr != iPrevErr: #Si écart constaté #Mise à jour des référentiels d'altitudes oGEH = GroundEstimatedHeight(oLog, sDstPath, sDstPath + "referentials/", "") oGEH.parseUnknownGroundHeightRef( sDstPath + sGeojsonFile) #Execution des traitements #Nouvelle tentative de regénération des fichiers #oLog.resetFile() #Clean du log oLog.resetCpt() #Reset compteurs sans effacement du log sMsg: str = "...oooOOO Forced reload by second phase OOOooo..." oLog.info("{0}".format(sMsg), outConsole=True) makeAixm2Geojson(sDstPath, sAixmFile, sDstPath, sGeojsonFile) iActErr: int = oLog.CptCritical + oLog.CptError if iActErr > 0: print() sMsg: str = "Abort treatment - Show errors in log file !" oLog.critical(sMsg, outConsole=True) return #Abort treatments #Openair generator makeAixm2Openair(sDstPath, sAixmFile, sDstPath, sSrcFinalFile) #KML generator makeGeojson2Kml(sDstPath, sGeojsonFile, sDstPath, sKmlFile) return
def createGeoJsonFile(sFileSrc, sCountryName, sCountryCode, sCountryIsoCode, sCountryDepCode, oArea, iIdx=-1) -> None: if iIdx==-1: sName = sCountryName elif iIdx>-1 and sCountryName=="France": sName = oFranceNames.get(str(iIdx), str(iIdx)) else: sName = str(iIdx) #Property for new GeoJSON oProperties = {"name":sName} if iIdx>-1: oProperties.update({"id":str(iIdx)}) oProperties.update({"countryName": sCountryName}) oProperties.update({"countryCode": sCountryCode}) oProperties.update({"countryIsoCode": sCountryIsoCode}) if sCountryDepCode!=sCountryCode: oProperties.update({"countryDepCode": sCountryDepCode}) oProperties.update({"src":sFileSrc}) oProperties.update({"creationDatetime":str(bpaTools.getNowISO())}) #Feature content if iIdx==-1: #old = {"type":"FeatureCollection", "features":[oCountry]} oNewFeature = {"type":"Feature", "properties":oProperties, "geometry":oArea["geometry"]} else: oNewFeature = {"type":"Feature", "properties":oProperties, "geometry":{"type":"Polygon", "coordinates":oArea}} oMainFeature = {"type":"FeatureCollection", "features":[oNewFeature]} #Folder destination sDestPath = outPath + sCountryDepCode + "-" + sCountryName + "/" bpaTools.createFolder(sDestPath) #File destination if iIdx==-1: sFileDst = "_" + sCountryDepCode + "-" + sCountryName + "-border_allAreas.geojson" else: sFileDst = sCountryDepCode + "-" + sCountryName + "-border_" + sName + ".geojson" bpaTools.writeJsonFile(sDestPath + sFileDst, oMainFeature) if iIdx==-1: if oArea["geometry"]["type"]=="MultiPolygon": iIdx=0 for oArea in oArea["geometry"]["coordinates"]: createGeoJsonFile(sFileSrc, sCountryName, sCountryCode, sCountryIsoCode, sCountryDepCode, oArea, iIdx) iIdx+=1 return
### Context applicatif callingContext = "Paragliding-OpenAir-FrenchFiles" #Your app calling context linkContext = "http://pascal.bazile.free.fr/paraglidingFolder/divers/GPS/OpenAir-Format/" appName = "groundEstimatedHeight" #or your app name appPath = bpaTools.getFilePath(__file__) #or your app path appVersion = groundEstimatedHeight.appVersion #or your app version appId = appName + " v" + appVersion if False: #For map only #outPath = appPath + "../../poaff/output/SIA/" #headFileName = "SIA@" outPath = appPath + "../../poaff/output/Tests/" headFileName = "BPa-Test4Clean@" else: outPath = appPath + "../out/" headFileName = "" srcPath = outPath refPath = outPath + "referentials/" logFile = outPath + "_" + appName + ".log" bpaTools.createFolder(outPath) #Init dossier de sortie oLog = bpaTools.Logger(appId, logFile) oLog.resetFile() oGEH = GroundEstimatedHeight(oLog, srcPath, refPath, headFileName) oGEH.parseUnknownGroundHeightRef() print() oLog.Report() oLog.closeFile
saveCalalogCSV2(deltaPath + "/" + sFileDst1, oCat1) saveCalalogCSV2(deltaPath + "/" + sFileDst2, oCat2) return if __name__ == '__main__': ### Context applicatif callingContext = "Paragliding-OpenAir-FrenchFiles" #Your app calling context appName = bpaTools.getFileName(__file__) appPath = bpaTools.getFilePath(__file__) #or your app path appVersion = "1.1.0" #or your app version appId = appName + " v" + appVersion outPath = appPath + "../../output/" cfdPath = outPath + "_CFD_www/" flyXCPath = cfdPath + "FlyXC/" deltaPath = cfdPath + "delta/" logFile = deltaPath + "_" + appName + ".log" bpaTools.createFolder(outPath) #Init dossier bpaTools.createFolder(deltaPath) #Init dossier oLog = bpaTools.Logger(appId, logFile) oLog.resetFile() #comparePoaffCfdWithFlyXC() comparePoaffWithPoaff() #extractGeoJSON() print() oLog.Report() oLog.closeFile
#!/usr/bin/env python3 import sys import bpaTools import aixmReader ### Context applicatif bpaTools.ctrlPythonVersion() __AppName__ = bpaTools.getFileName(__file__) __AppPath__ = bpaTools.getFilePath(__file__) __AppVers__ = bpaTools.getVersionFile() ___AppId___ = __AppName__ + " v" + __AppVers__ __OutPath__ = __AppPath__ + "../out/" __LogFile__ = __OutPath__ + "_" + __AppName__ + ".log" bpaTools.createFolder(__OutPath__) #Init dossier de sortie def syntaxe(): print("Aeronautical Information Exchange Model (AIXM) Converter") print( "Call: " + __AppName__ + " <[drive:][path]filename> <Format> <Type> [<Type2> ... <TypeN>] [<Option(s)>]" ) print("With:") print(" <[drive:][path]filename> AIXM source file") print("") print(" <Format> - Output formats:") print(" " + aixmReader.CONST.frmtGEOJSON + " GeoJSON for GoogleMap") print(" " + aixmReader.CONST.frmtOPENAIR + " OpenAir for aeronautical software")
parseFile(sKey, oFile) #Creation des fichiers iPostErr = oLog.CptCritical + oLog.CptError #Nombre d'erreurs en post-traitements if iPostErr != iPrevErr: #Si écart constaté updateReferentials( sKey, oFile) #Forcer mise à jour des référentiels d'altitudes parseFile( sKey, oFile ) #Regénération des fichiers après maj des référentiels return if __name__ == '__main__': sCallingContext = None bpaTools.createFolder(outPath) #Initialisation bpaTools.createFolder(poaffOutPath) #Initialisation bpaTools.createFolder(poaffOutPath + poaffCst.cstReferentialPath) #Initialisation oOpts = bpaTools.getCommandLineOptions(aArgs) #Arguments en dictionnaire oLog = bpaTools.Logger(appId, logFile, poaffCst.callingContext, poaffCst.linkContext, debugLevel=debugLevel, isSilent=bool(aixmReader.CONST.optSilent in oOpts)) if aixmReader.CONST.optCleanLog in oOpts: oLog.resetFile() #Clean du log si demandé #--------- creation des fichiers unitaires ----------