def	load_hsnr_from_cad_file(fnadresses):
	xmladresses = ET.parse(fnadresses)
	dict_node_relations = {}
	for asso in xmladresses.iter('relation'):
		dtags = get_tags(asso)
		if not 'type' in dtags:
			continue
		if dtags['type'] != 'associatedStreet':
			continue
		if not 'name' in dtags:
			continue
		if len(dtags['name']) < 2:
			continue
		adresses.register(dtags['name'])
		adresses.add_voie(dtags['name'],'CADASTRE')
		for n in asso.iter('member'):
			if n.get('type') == 'node':
				if not n.get('ref') in dict_node_relations:
					dict_node_relations[n.get('ref')] = []
				dict_node_relations[n.get('ref')].append(normalize(dtags['name']))
	for n in xmladresses.iter('node'):
		dtags = get_tags(n)
		n_id = n.get('id')
		if 'addr:housenumber' in dtags and n_id in dict_node_relations:
			if is_valid_housenumber(dtags['addr:housenumber']):
				for v in dict_node_relations[n_id]:
					nd = Node({'id':n_id,'lon':n.get('lon'),'lat':n.get('lat')},{})
					adresses.add_adresse(Adresse(nd,dtags['addr:housenumber'],adresses.a[v]['voies']['CADASTRE'],''),source)
			else:
				print('Numero invalide : {:s}'.format(dtags['addr:housenumber'].encode('utf8')))
예제 #2
0
def load_hsnr_from_cad_file(fnadresses):
    xmladresses = ET.parse(fnadresses)
    dict_node_relations = {}
    for asso in xmladresses.iter("relation"):
        dtags = get_tags(asso)
        if not "type" in dtags:
            continue
        if dtags["type"] != "associatedStreet":
            continue
        if not "name" in dtags:
            continue
        if len(dtags["name"]) < 2:
            continue
        adresses.register(dtags["name"])
        adresses.add_voie(dtags["name"], "CADASTRE")
        for n in asso.iter("member"):
            if n.get("type") == "node":
                if not n.get("ref") in dict_node_relations:
                    dict_node_relations[n.get("ref")] = []
                dict_node_relations[n.get("ref")].append(normalize(dtags["name"]))
    for n in xmladresses.iter("node"):
        dtags = get_tags(n)
        n_id = n.get("id")
        if "addr:housenumber" in dtags and n_id in dict_node_relations:
            if is_valid_housenumber(dtags["addr:housenumber"]):
                for v in dict_node_relations[n_id]:
                    nd = Node({"id": n_id, "lon": n.get("lon"), "lat": n.get("lat")}, {})
                    adresses.add_adresse(
                        Adresse(nd, dtags["addr:housenumber"], adresses.a[v]["voies"]["CADASTRE"], ""), source
                    )
            else:
                print("Numero invalide : {:s}".format(dtags["addr:housenumber"].encode("utf8")))
 def add_adresse(self, ad, source):
     """ une adresses est considérée dans la commune si sans Fantoir ou avec un Fantoir de la commune"""
     if (ad.fantoir == '' or
         (is_valid_fantoir(ad.fantoir) and ad.fantoir[0:5]
          == code_insee)) and is_valid_housenumber(ad.numero):
         cle = normalize(ad.voie)
         self.add_voie(ad.voie, source)
         self.a[cle]['numeros'][ad.numero] = ad
         if ad.fantoir != '':
             self.a[cle]['fantoirs']['OSM'] = ad.fantoir
     else:
         print(u'adresse rejetée : {:s} {:s}'.format(ad.numero, ad.fantoir))
예제 #4
0
 def add_adresse(self, ad, source):
     """ une adresses est considérée dans la commune si sans Fantoir ou avec un Fantoir de la commune"""
     if (
         ad.fantoir == "" or (is_valid_fantoir(ad.fantoir) and ad.fantoir[0:5] == code_insee)
     ) and is_valid_housenumber(ad.numero):
         cle = normalize(ad.voie)
         self.add_voie(ad.voie, source)
         self.a[cle]["numeros"][ad.numero] = ad
         if ad.fantoir != "":
             self.a[cle]["fantoirs"]["OSM"] = ad.fantoir
     else:
         print(u"adresse rejetée : {:s} {:s}".format(ad.numero, ad.fantoir))
예제 #5
0
	def get_as_SQL_import_parcelle(self):
		str_query = ''
		a_values = []
		id_cadastre = ''
		if 'ref:FR:CADASTRE:PARCELLE' in self.tags:
			id_cadastre = self.tags['ref:FR:CADASTRE:PARCELLE']
		for i in range(0,9):
			voie = ''
			numero = ''
			fantoir = ''
			street_tag = 'addr{:d}:street'.format(i)
			hsnr_tag = 'addr{:d}:housenumber'.format(i)
			if not street_tag in self.tags and not hsnr_tag in self.tags:
				break
			if street_tag in self.tags:
				voie = self.tags[street_tag].replace('\'','\'\'')
			else:
				continue
			if hsnr_tag in self.tags and is_valid_housenumber(self.tags[hsnr_tag]):
				numero = self.tags[hsnr_tag]
			a_values.append('(SELECT ST_Transform(ST_SetSRID(ST_MakePolygon(ST_GeomFromText({:s})),4326),900913)),\'{:s}\',\'{:s}\',\'{:s}\',\'{:s}\',\'{:s}\''.format(self.geom.get_geom_as_linestring_text(),code_insee,id_cadastre,numero,voie,fantoir))
		if a_values:
			str_query = 'INSERT INTO parcelles VALUES ({:s});'.format('),('.join(a_values))
		return str_query