def createNewDocEntry(request): # Attention il faut que l'utilisateur puisse écrire dans la table et d'1, mais aussi qu'il ait le droit sur la SEQUENCE dans PG data = sloads(request.POST['data']) document = Documents() if data['numcom']: document.nocom = int(data['numcom']) else: document.nocom = None if data['nufeco']: document.nufeco = int(data['nufeco']) else: document.nufeco = None if data['numcad']: document.nocad = int(data['numcad']) else: document.nocad = None document.nomcom = data['comnom'] document.doctype = data['doctype'] document.topicfk = data['topicfk'] document.titre = data['titre'] document.titreofficiel = data['titreofficiel'] document.abreviation = data['abreviation'] document.noofficiel = data['noofficiel'] document.url = data['url'] document.statutjuridique = data['statutjuridique'] if data['datesanction']: document.datesanction = data['datesanction'] else: document.datesanction = None if data['dateabrogation']: document.dateabrogation = data['dateabrogation'] else: document.dateabrogation = None document.operateursaisie = data['operateursaisie'] if data['datesaisie']: document.datesaisie = data['datesaisie'] else: document.datesaisie = None document.canton = data['canton'] DBSession.add(document) DBSession.flush() return {'success': True}
def get_XML(geometry, srid, topicid, extracttime, lang, translations): """Gets the XML extract of the federal data feature service for a given topic and validates it against the schema. """ # baseurl of the server of the swiss confederation server = 'https://api3.geo.admin.ch' # rest service call url = '/rest/services/api/MapServer/identify' # layers = 'all:ch.bazl.sicherheitszonenplan.oereb' # bbox = 'mapExtent=671164.31244,253770,690364.31244,259530' # geometry of the feature to call the feature server for feature = geometry # geomtype = 'geometryType=esriGeometryEnvelope' # wktfeature = DBSession.scalar(geometry.ST_AsText()) bbox = get_bbox_from_geometry( DBSession.scalar(functions.ST_AsText(geometry.ST_Envelope()))) # geometrytype used for feature service call geomtype = 'esriGeometryPolygon' # geomtype = 'esriGeometryEnvelope' - BBOX # geomtype = 'esriGeometryPoint' - Point # Size and resolution of the returned image mapparams = '1920,576,96' # geometry tolerance for intersection tolerance = 5 # data format format = 'interlis' xml_layers = { 'R103': 'ch.bazl.projektierungszonen-flughafenanlagen.oereb', 'R108': 'ch.bazl.sicherheitszonenplan.oereb', 'R118': 'ch.bazl.kataster-belasteter-standorte-zivilflugplaetze.oereb', 'R119': 'ch.bav.kataster-belasteter-standorte-oev.oereb' } geomGeoJSON = loads(DBSession.scalar(geometry.ST_AsGeoJSON())) coords = geomGeoJSON['coordinates'] if geomGeoJSON['type'] == 'MultiPolygon': coords = coords[0] # Stupid ESRI stuff: double quotes are needed to call the feature service, thus we have to hardcode "rings" esrifeature = '{"rings":' + str(coords) + '}' # Composing the feature service request fsurl = server + url params = { 'geometry': esrifeature, 'geometryType': geomtype, 'layers': 'all:' + xml_layers[topicid], 'mapExtent': str(bbox.values()).strip('[]'), 'imageDisplay': mapparams, 'tolerance': str(tolerance), 'geometryFormat': format, 'lang': lang } params = urllib.urlencode(params) # Call the feature service URL wich sends back an XML Interlis 2.3 file in the OEREB Transfer structure h = httplib2.Http() (resp_headers, content) = h.request(fsurl, method="POST", body=params) # trim all whitespace and newlines content_lines = content.splitlines() count = 0 for line in content_lines: content_lines[count] = line.strip() count += 1 content = ''.join(content_lines) # validate XML # xmldoc = parseString(content).firstChild xmldoc = parseString(content).getElementsByTagName("TRANSFER")[0] # extract the datasection from the response datasection = xmldoc.getElementsByTagName("DATASECTION")[0] # extract the complete tranfert structure transferstructure = xmldoc.getElementsByTagName( "OeREBKRM09trsfr.Transferstruktur") if len(transferstructure[0].childNodes) > 0: # Get the competent authority for the legal provisions vsauthority = { 'shortname': xmldoc.getElementsByTagName("OeREBKRM09vs.Vorschriften.Amt") [0].getAttributeNode("TID").value, 'namede': xmldoc.getElementsByTagName("OeREBKRM09vs.Vorschriften.Amt") [0].getElementsByTagName("Text")[0].firstChild.data, 'namefr': xmldoc.getElementsByTagName("OeREBKRM09vs.Vorschriften.Amt") [0].getElementsByTagName("Text")[1].firstChild.data, 'namefr': xmldoc.getElementsByTagName("OeREBKRM09vs.Vorschriften.Amt") [0].getElementsByTagName("Text")[2].firstChild.data, 'url': xmldoc.getElementsByTagName("OeREBKRM09vs.Vorschriften.Amt") [0].getElementsByTagName("AmtImWeb")[0].firstChild.data } vslegalprovisions = xmldoc.getElementsByTagName( "OeREBKRM09vs.Vorschriften.Dokument") # Get the WMS and it's legend xtfwms = { 'wmsurl': xmldoc.getElementsByTagName( "OeREBKRM09trsfr.Transferstruktur.DarstellungsDienst") [0].getElementsByTagName("VerweisWMS")[0].firstChild.data, 'wmslegend': xmldoc.getElementsByTagName( "OeREBKRM09trsfr.Transferstruktur.DarstellungsDienst") [0].getElementsByTagName("LegendeImWeb")[0].firstChild.data } # GET restrictions xtfrestrictions = xmldoc.getElementsByTagName( "OeREBKRM09trsfr.Transferstruktur.Eigentumsbeschraenkung") if xtfrestrictions: restrictions = [] restriction = {} for xtfrestriction in xtfrestrictions: restriction = { 'restrictionid': xtfrestriction.getAttributeNode("TID").value, 'teneurde': xtfrestriction.getElementsByTagName("Aussage") [0].getElementsByTagName("Text")[0].firstChild.data, 'teneurfr': xtfrestriction.getElementsByTagName("Aussage") [0].getElementsByTagName("Text")[1].firstChild.data, 'teneurit': xtfrestriction.getElementsByTagName("Aussage") [0].getElementsByTagName("Text")[2].firstChild.data, 'topic': xtfrestriction.getElementsByTagName( "Thema")[0].firstChild.data, 'legalstate': xtfrestriction.getElementsByTagName( "Rechtsstatus")[0].firstChild.data, 'publishedsince': xtfrestriction.getElementsByTagName( "publiziertAb")[0].firstChild.data, 'url': xtfrestriction.getElementsByTagName( "DarstellungsDienst")[0].getAttributeNode("REF").value, 'authority': xtfrestriction.getElementsByTagName( "ZustaendigeStelle")[0].getAttributeNode("REF").value } restrictions.append(restriction) xtfvslinkprovisions = xmldoc.getElementsByTagName( "OeREBKRM09trsfr.Transferstruktur.HinweisVorschrift") vslinkprovisions = [] for vslinkprovision in xtfvslinkprovisions: vslinkprovisions.append({ 'origin': vslinkprovision.getElementsByTagName( "Eigentumsbeschraenkung")[0].getAttributeNode("REF").value, 'link': vslinkprovision.getElementsByTagName("Vorschrift") [0].getAttributeNode("REF").value }) xtfvslinkreferences = xmldoc.getElementsByTagName( "OeREBKRM09vs.Vorschriften.HinweisWeitereDokumente") vslinkreferences = [] for vslinkreference in xtfvslinkreferences: vslinkreferences.append({ 'origin': vslinkreference.getElementsByTagName( "Ursprung")[0].getAttributeNode("REF").value, 'link': vslinkreference.getElementsByTagName("Hinweis") [0].getAttributeNode("REF").value }) xtfvslegalprovisions = xmldoc.getElementsByTagName( "OeREBKRM09vs.Vorschriften.Rechtsvorschrift") vslegalprovisions = [] for vslegalprovision in xtfvslegalprovisions: vslegalprovisions.append({ 'provisionid': vslegalprovision.getAttributeNode("TID").value, 'titel': vslegalprovision.getElementsByTagName( "Text")[0].firstChild.data, 'legalstate': vslegalprovision.getElementsByTagName( "Rechtsstatus")[0].firstChild.data, 'publishedsince': vslegalprovision.getElementsByTagName( "publiziertAb")[0].firstChild.data, 'authority': vslegalprovision.getElementsByTagName( "ZustaendigeStelle")[0].getAttributeNode("REF").value, 'url': vslegalprovision.getElementsByTagName("TextImWeb") [0].firstChild.data }) xtfvsdocuments = xmldoc.getElementsByTagName( "OeREBKRM09vs.Vorschriften.Dokument") vsdocuments = [] for vsdocument in xtfvsdocuments: vsdocuments.append({ 'provisionid': vsdocument.getAttributeNode("TID").value, 'titel': vsdocument.getElementsByTagName("Text")[0].firstChild.data, 'legalstate': vsdocument.getElementsByTagName( "Rechtsstatus")[0].firstChild.data, 'publishedsince': vsdocument.getElementsByTagName( "publiziertAb")[0].firstChild.data, 'authority': vsdocument.getElementsByTagName("ZustaendigeStelle") [0].getAttributeNode("REF").value, 'url': vsdocument.getElementsByTagName("TextImWeb")[0].firstChild.data }) xtflegalprovisions = xmldoc.getElementsByTagName( "OeREBKRM09trsfr.Transferstruktur.HinweisVorschrift") feature = [] for xtflegalprovision in xtflegalprovisions: feature.append({ 'restrictionid': xtflegalprovision.getElementsByTagName( "Eigentumsbeschraenkung")[0].getAttributeNode("REF").value, 'provision': xtflegalprovision.getElementsByTagName("Vorschrift") [0].getAttributeNode("REF").value }) xtfreferences = xmldoc.getElementsByTagName( "OeREBKRM09vs.Vorschriften.HinweisWeitereDokumente") xtfgeoms = xmldoc.getElementsByTagName( "OeREBKRM09trsfr.Transferstruktur.Geometrie") geometries = [] for xtfgeom in xtfgeoms: if xtfgeom.getElementsByTagName("Flaeche"): if xtfgeom.getElementsByTagName("SURFACE"): surfaces = xtfgeom.getElementsByTagName("SURFACE") if xtfgeom.getElementsByTagName("BOUNDARY"): boundaries = xtfgeom.getElementsByTagName("BOUNDARY") if xtfgeom.getElementsByTagName("POLYLINE"): polylines = xtfgeom.getElementsByTagName( "POLYLINE") multipolygon = [] for polyline in polylines: coordlist = [] for coords in polyline.childNodes: coordlist.append( (float( coords.getElementsByTagName("C1") [0].firstChild.data), float( coords.getElementsByTagName("C2") [0].firstChild.data))) # del coordlist[-1] polygon = splPolygon(coordlist) if len(polylines) > 1: multipolygon.append(polygon) geom = splMultiPolygon(multipolygon) else: geom = polygon elif xtfgeom.getElementsByTagName( "Punkt") and not xtfgeom.getElementsByTagName("Flaeche"): point = xtfgeom.getElementsByTagName("Punkt")[0] coordlist = [] for coords in point.childNodes: coordlist.append((float( coords.getElementsByTagName("C1")[0].firstChild.data), float( coords.getElementsByTagName("C2") [0].firstChild.data))) geom = splPoint(coordlist) else: geom = None geometries.append({ 'tid': xtfgeom.getAttributeNode("TID").value, 'restrictionid': xtfgeom.getElementsByTagName( "Eigentumsbeschraenkung")[0].getAttributeNode("REF").value, 'competentAuthority': xtfgeom.getElementsByTagName( "ZustaendigeStelle")[0].getAttributeNode("REF").value, 'legalstate': xtfgeom.getElementsByTagName( "Rechtsstatus")[0].firstChild.data, 'publishedsince': xtfgeom.getElementsByTagName("publiziertAb") [0].firstChild.data, # 'metadata': xtfgeom.getElementsByTagName("MetadatenGeobasisdaten")[0].firstChild.data, 'geom': geom.wkt }) for geometry in geometries: if topicid in [u'R103', '103']: xml_model = CHAirportProjectZonesPDF() xml_model.theme = translations[ 'CHAirportProjectZonesThemeLabel'] # u'Zones réservées des installations aéroportuaires' xml_model.teneur = translations[ 'CHAirportProjectZonesContentLabel'] # u'Limitation de la hauteur des bâtiments et autres obstacles' elif topicid in [u'R108', '108']: xml_model = CHAirportSecurityZonesPDF() xml_model.theme = translations[ 'CHAirportSecurityZonesThemeLabel'] # u'Plan de la zone de sécurité des aéroports' xml_model.teneur = translations[ 'CHAirportSecurityZonesContentLabel'] # u'Limitation de la hauteur des bâtiments et autres obstacles' elif topicid in [u'R118', '118']: xml_model = CHPollutedSitesCivilAirportsPDF() xml_model.theme = translations[ 'CHPollutedSitesCivilAirportsThemeLabel'] # u'Cadastre des sites pollués - domaine des transports publics' xml_model.teneur = translations[ 'CHPollutedSitesCivilAirportsContentLabel'] # u'Sites pollués' elif topicid in [u'R119', '119']: xml_model = CHPollutedSitesPublicTransportsPDF() xml_model.theme = translations[ 'CHPollutedSitesPublicTransportsThemeLabel'] # u'Cadastre des sites pollués - domaine des transports publics' xml_model.teneur = translations[ 'CHPollutedSitesPublicTransportsContentLabel'] # u'Sites pollués' xml_model.codegenre = None if geometry['legalstate'] == u'inKraft': xml_model.statutjuridique = translations[ 'legalstateLabelvalid'] # u'En vigueur' else: xml_model.statutjuridique = translations[ 'legalstateLabelmodification'] # u'En cours d\'approbation' if geometry['publishedsince']: xml_model.datepublication = geometry['publishedsince'] else: xml_model.datepublication = None # It is very important to set the SRID if it's not the default EPSG:4326 !! xml_model.idobj = str(extracttime) + '_' + str( geometry['restrictionid']) xml_model.geom = WKTElement(geometry['geom'], srid) DBSession.add(xml_model) DBSession.flush() return
def get_XML(geometry, topicid, extracttime, lang, translations): """Gets the XML extract of the federal data feature service for a given topic and validates it against the schema. """ # baseurl of the server of the swiss confederation server = 'https://api3.geo.admin.ch' # rest service call url = '/rest/services/api/MapServer/identify' #layers = 'all:ch.bazl.sicherheitszonenplan.oereb' #bbox = 'mapExtent=671164.31244,253770,690364.31244,259530' # geometry of the feature to call the feature server for feature = geometry #geomtype = 'geometryType=esriGeometryEnvelope' wktfeature = DBSession.scalar(geometry.wkt) bbox = get_bbox_from_geometry(DBSession.scalar(geometry.envelope.wkt)) # geometrytype used for feature service call geomtype = 'esriGeometryPolygon' # geomtype = 'esriGeometryEnvelope' - BBOX # geomtype = 'esriGeometryPoint' - Point # Size and resolution of the returned image mapparams = '1920,576,96' # geometry tolerance for intersection tolerance=5 # data format format='interlis' xml_layers = { '103':'ch.bazl.projektierungszonen-flughafenanlagen.oereb', '108':'ch.bazl.sicherheitszonenplan.oereb', '118':'ch.bazl.kataster-belasteter-standorte-zivilflugplaetze.oereb', '119':'ch.bav.kataster-belasteter-standorte-oev.oereb' } coords = geometry.coords(DBSession) # Stupid ESRI stuff: double quotes are needed to call the feature service, thus we have to hardcode "rings" esrifeature = '{"rings":'+ str(coords)+'}' # Composing the feature service request fsurl = server+url params = { 'geometry': esrifeature, 'geometryType': geomtype, 'layers': 'all:'+xml_layers[topicid], 'mapExtent': str(bbox.values()).strip('[]'), 'imageDisplay': mapparams, 'tolerance': str(tolerance), 'geometryFormat': format, 'lang': lang } params = urllib.urlencode(params) # Call the feature service URL wich sends back an XML Interlis 2.3 file in the OEREB Transfer structure response = urllib.urlopen(fsurl, params) content = response.read() # trim all whitespace and newlines content_lines = content.splitlines() count = 0 for line in content_lines: content_lines[count] = line.strip() count += 1 content = ''.join(content_lines) # validate XML #xmldoc = parseString(content).firstChild xmldoc = parseString(content).getElementsByTagName("TRANSFER")[0] # extract the datasection from the response datasection = xmldoc.getElementsByTagName("DATASECTION")[0] # extract the complete tranfert structure transferstructure = xmldoc.getElementsByTagName("OeREBKRM09trsfr.Transferstruktur") if len(transferstructure[0].childNodes) > 0: # Get the competent authority for the legal provisions vsauthority = { 'shortname':xmldoc.getElementsByTagName("OeREBKRM09vs.Vorschriften.Amt")[0].getAttributeNode("TID").value, 'namede':xmldoc.getElementsByTagName("OeREBKRM09vs.Vorschriften.Amt")[0].getElementsByTagName("Text")[0].firstChild.data, 'namefr':xmldoc.getElementsByTagName("OeREBKRM09vs.Vorschriften.Amt")[0].getElementsByTagName("Text")[1].firstChild.data, 'namefr':xmldoc.getElementsByTagName("OeREBKRM09vs.Vorschriften.Amt")[0].getElementsByTagName("Text")[2].firstChild.data, 'url':xmldoc.getElementsByTagName("OeREBKRM09vs.Vorschriften.Amt")[0].getElementsByTagName("AmtImWeb")[0].firstChild.data } vslegalprovisions = xmldoc.getElementsByTagName("OeREBKRM09vs.Vorschriften.Dokument") # Get the WMS and it's legend xtfwms = { 'wmsurl':xmldoc.getElementsByTagName("OeREBKRM09trsfr.Transferstruktur.DarstellungsDienst")[0].getElementsByTagName("VerweisWMS")[0].firstChild.data, 'wmslegend':xmldoc.getElementsByTagName("OeREBKRM09trsfr.Transferstruktur.DarstellungsDienst")[0].getElementsByTagName("LegendeImWeb")[0].firstChild.data } # GET restrictions xtfrestrictions = xmldoc.getElementsByTagName("OeREBKRM09trsfr.Transferstruktur.Eigentumsbeschraenkung") if xtfrestrictions: restrictions = [] restriction = {} for xtfrestriction in xtfrestrictions: restriction = { 'restrictionid':xtfrestriction.getAttributeNode("TID").value, 'teneurde':xtfrestriction.getElementsByTagName("Aussage")[0].getElementsByTagName("Text")[0].firstChild.data, 'teneurfr':xtfrestriction.getElementsByTagName("Aussage")[0].getElementsByTagName("Text")[1].firstChild.data, 'teneurit':xtfrestriction.getElementsByTagName("Aussage")[0].getElementsByTagName("Text")[2].firstChild.data, 'topic':xtfrestriction.getElementsByTagName("Thema")[0].firstChild.data, 'legalstate':xtfrestriction.getElementsByTagName("Rechtsstatus")[0].firstChild.data, 'publishedsince':xtfrestriction.getElementsByTagName("publiziertAb")[0].firstChild.data, 'url':xtfrestriction.getElementsByTagName("DarstellungsDienst")[0].getAttributeNode("REF").value, 'authority':xtfrestriction.getElementsByTagName("ZustaendigeStelle")[0].getAttributeNode("REF").value } restrictions.append(restriction) xtfvslinkprovisions = xmldoc.getElementsByTagName("OeREBKRM09trsfr.Transferstruktur.HinweisVorschrift") vslinkprovisions = [] for vslinkprovision in xtfvslinkprovisions: vslinkprovisions.append({ 'origin':vslinkprovision.getElementsByTagName("Eigentumsbeschraenkung")[0].getAttributeNode("REF").value, 'link':vslinkprovision.getElementsByTagName("Vorschrift")[0].getAttributeNode("REF").value }) xtfvslinkreferences = xmldoc.getElementsByTagName("OeREBKRM09vs.Vorschriften.HinweisWeitereDokumente") vslinkreferences = [] for vslinkreference in xtfvslinkreferences: vslinkreferences.append({ 'origin':vslinkreference.getElementsByTagName("Ursprung")[0].getAttributeNode("REF").value, 'link':vslinkreference.getElementsByTagName("Hinweis")[0].getAttributeNode("REF").value }) xtfvslegalprovisions = xmldoc.getElementsByTagName("OeREBKRM09vs.Vorschriften.Rechtsvorschrift") vslegalprovisions = [] for vslegalprovision in xtfvslegalprovisions: vslegalprovisions.append({ 'provisionid':vslegalprovision.getAttributeNode("TID").value, 'titel':vslegalprovision.getElementsByTagName("Text")[0].firstChild.data, 'legalstate':vslegalprovision.getElementsByTagName("Rechtsstatus")[0].firstChild.data, 'publishedsince':vslegalprovision.getElementsByTagName("publiziertAb")[0].firstChild.data, 'authority':vslegalprovision.getElementsByTagName("ZustaendigeStelle")[0].getAttributeNode("REF").value, 'url':vslegalprovision.getElementsByTagName("TextImWeb")[0].firstChild.data }) xtfvsdocuments = xmldoc.getElementsByTagName("OeREBKRM09vs.Vorschriften.Dokument") vsdocuments = [] for vsdocument in xtfvsdocuments: vsdocuments.append({ 'provisionid':vsdocument.getAttributeNode("TID").value, 'titel':vsdocument.getElementsByTagName("Text")[0].firstChild.data, 'legalstate':vsdocument.getElementsByTagName("Rechtsstatus")[0].firstChild.data, 'publishedsince':vsdocument.getElementsByTagName("publiziertAb")[0].firstChild.data, 'authority':vsdocument.getElementsByTagName("ZustaendigeStelle")[0].getAttributeNode("REF").value, 'url':vsdocument.getElementsByTagName("TextImWeb")[0].firstChild.data }) xtflegalprovisions = xmldoc.getElementsByTagName("OeREBKRM09trsfr.Transferstruktur.HinweisVorschrift") feature = [] for xtflegalprovision in xtflegalprovisions: feature.append({ 'restrictionid':xtflegalprovision.getElementsByTagName("Eigentumsbeschraenkung")[0].getAttributeNode("REF").value, 'provision':xtflegalprovision.getElementsByTagName("Vorschrift")[0].getAttributeNode("REF").value }) xtfreferences = xmldoc.getElementsByTagName("OeREBKRM09vs.Vorschriften.HinweisWeitereDokumente") xtfgeoms = xmldoc.getElementsByTagName("OeREBKRM09trsfr.Transferstruktur.Geometrie") geometries = [] for xtfgeom in xtfgeoms: if xtfgeom.getElementsByTagName("Flaeche"): if xtfgeom.getElementsByTagName("SURFACE"): surfaces = xtfgeom.getElementsByTagName("SURFACE") if xtfgeom.getElementsByTagName("BOUNDARY"): boundaries = xtfgeom.getElementsByTagName("BOUNDARY") if xtfgeom.getElementsByTagName("POLYLINE"): polylines = xtfgeom.getElementsByTagName("POLYLINE") multipolygon = [] for polyline in polylines: coordlist = [] for coords in polyline.childNodes: coordlist.append(( float(coords.getElementsByTagName("C1")[0].firstChild.data), float(coords.getElementsByTagName("C2")[0].firstChild.data) )) #del coordlist[-1] polygon = splPolygon(coordlist) if len(polylines) > 1: multipolygon.append(polygon) geom = splMultiPolygon(multipolygon) else: geom = polygon elif xtfgeom.getElementsByTagName("Punkt") and not xtfgeom.getElementsByTagName("Flaeche"): point = xtfgeom.getElementsByTagName("Punkt")[0] coordlist = [] for coords in point.childNodes: coordlist.append(( float(coords.getElementsByTagName("C1")[0].firstChild.data), float(coords.getElementsByTagName("C2")[0].firstChild.data) )) geom = splPoint(coordlist) else: geom = None geometries.append({ 'tid':xtfgeom.getAttributeNode("TID").value, 'restrictionid':xtfgeom.getElementsByTagName("Eigentumsbeschraenkung")[0].getAttributeNode("REF").value, 'competentAuthority':xtfgeom.getElementsByTagName("ZustaendigeStelle")[0].getAttributeNode("REF").value, 'legalstate':xtfgeom.getElementsByTagName("Rechtsstatus")[0].firstChild.data, 'publishedsince':xtfgeom.getElementsByTagName("publiziertAb")[0].firstChild.data, #'metadata':xtfgeom.getElementsByTagName("MetadatenGeobasisdaten")[0].firstChild.data, 'geom':geom.wkt }) for geometry in geometries: if topicid == '103': xml_model = CHAirportProjectZonesPDF() xml_model.theme = translations['CHAirportProjectZonesThemeLabel'] # u'Zones réservées des installations aéroportuaires' xml_model.teneur = translations['CHAirportProjectZonesContentLabel'] # u'Limitation de la hauteur des bâtiments et autres obstacles' elif topicid == u'108': xml_model = CHAirportSecurityZonesPDF() xml_model.theme = translations['CHAirportSecurityZonesThemeLabel'] # u'Plan de la zone de sécurité des aéroports' xml_model.teneur = translations['CHAirportSecurityZonesContentLabel'] # u'Limitation de la hauteur des bâtiments et autres obstacles' elif topicid == u'118': xml_model = CHPollutedSitesCivilAirportsPDF() xml_model.theme = translations['CHPollutedSitesCivilAirportsThemeLabel'] # u'Cadastre des sites pollués - domaine des transports publics' xml_model.teneur = translations['CHPollutedSitesCivilAirportsContentLabel'] # u'Sites pollués' elif topicid == u'119': xml_model = CHPollutedSitesPublicTransportsPDF() xml_model.theme = translations['CHPollutedSitesPublicTransportsThemeLabel'] # u'Cadastre des sites pollués - domaine des transports publics' xml_model.teneur = translations['CHPollutedSitesPublicTransportsContentLabel'] # u'Sites pollués' xml_model.codegenre = None if geometry['legalstate'] == u'inKraft': xml_model.statutjuridique = translations['legalstateLabelvalid'] # u'En vigueur' else: xml_model.statutjuridique = translations['legalstateLabelmodification'] # u'En cours d\'approbation' if geometry['publishedsince']: xml_model.datepublication = geometry['publishedsince'] else: xml_model.datepublication = None # It is very important to set the SRID if it's not the default EPSG:4326 !! xml_model.idobj = str(extracttime)+'_'+str(geometry['restrictionid']) xml_model.geom = WKTSpatialElement(geometry['geom'], 21781) DBSession.add(xml_model) DBSession.flush() return