Osmose

1,138 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,138
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • http://datenkueche.com/osmlive/
  • Osmose

    1. 1. Osmose La détection automatique d’anomalies Frédéric Rodrigo <fred.rodrigo gmail.com> La Cantine - Paris 07/10/2011 – (c)left 2011 - CC-BY-SA v3.0 @
    2. 2. <ul>Osmose </ul><ul>Frontend </ul><ul>Backends </ul><ul><li>Plugin
    3. 3. JOSM </li></ul>
    4. 4. <ul>Backends </ul><ul><li>Analyseurs
    5. 5. Fréquence : une région toutes les 2h </li></ul><ul><ul><li>Limité par les serveurs OSM 5/6
    6. 6. Nouveau serveur OSM 7/8 </li></ul></ul><ul><li>Téléchargement des extracts Geofabrik </li></ul>
    7. 7. <ul>Analyseurs </ul><ul><li>Récupération de données externes </li></ul><ul><ul><li>OpenStreetBugs, Géodésie </li></ul></ul><ul><li>Analyseur SAX des .osm </li></ul><ul><ul><li>Plugins </li></ul></ul><ul><li>Bases osm2pgsql (deprecated) </li></ul><ul><ul><li>Requêtes GIS </li></ul></ul><ul><li>Bases osmosis </li></ul><ul><ul><li>Requêtes
    8. 8. Requêtes GIS </li></ul></ul>
    9. 9. <ul>Analyseurs </ul><ul><li>analyser()
    10. 10. Construit un fichier XML </li></ul>
    11. 11. <ul>Analyseur SAX : Plugins </ul><ul><li>Passe tous les éléments du fichier .osm en revue
    12. 12. Appelle les plugins pour chaque éléments </li></ul>
    13. 13. <ul>Analyseur SAX : Plugins </ul><ul><li>Périmètre d’application </li></ul><ul><ul><li>only_for = [&quot;FR&quot;] </li></ul></ul><ul><li>Méthodes </li></ul><ul><ul><li>init()
    14. 14. node()
    15. 15. way()
    16. 16. relation() </li></ul></ul><ul><li>Retourne une message si erreur détecté </li></ul>
    17. 17. <ul>Plugin : TagManquant_RondPoint </ul>class TagManquant_RondPoint(Plugin): err_102 = 3010 err_102_fr = u&quot;Tag highway manquant sur junction=roundabout&quot; err_102_en = u&quot;Tag highway missing on junction=roundabout&quot; def way(self, data, tags, nds): if u&quot;junction&quot; not in tags: return if u&quot;highway&quot; not in tags: return [(102, 0, {})]
    18. 18. <ul>Plugin : TagWatchWikipedia </ul>def init(self, logger): self.Wiki = re.compile(u&quot;http://([^.]+).wikipedia.+/(.+)&quot;) def node(self, data, tags): err = [] if &quot;wikipedia&quot; in tags: if tags[&quot;wikipedia&quot;].startswith(&quot;http://&quot;): m = self.Wiki.match(tags[&quot;wikipedia&quot;]) if m: err.append((3031, 1, {&quot;en&quot;: u&quot;wikipedia=%s => wikipedia=%s:%s&quot;})) else: err.append((3031, 0, {&quot;en&quot;: u&quot;Not a wikipedia URL&quot;})) return err def way(self, data, tags, nds): return self.node(data, tags)
    19. 19. <ul>Analyseur osmosis </ul>def analyser(config, logger = None): gisconn = PgSQL.Connection(config.dbs) giscurs = gisconn.cursor() apiconn = OsmOsis.OsmOsis(config.dbs, config.dbp) outxml = OsmSax.OsmSaxWriter(open(config.dst, &quot;w&quot;), &quot;UTF-8&quot;) ## output headers outxml.startDocument() outxml.startElement(&quot;analyser&quot;, {&quot;timestamp&quot;: time.gmtime()}) outxml.startElement(&quot;class&quot;, {&quot;id&quot;:&quot;1&quot;, &quot;item&quot;:&quot;1040&quot;}) outxml.Element(&quot;classtext&quot;, {&quot;lang&quot;:&quot;fr&quot;, &quot;title&quot;:&quot;Polygone invalide&quot;}) outxml.endElement(&quot;class&quot;) giscurs.execute(&quot;SET search_path TO %s,public;&quot; % config.dbp) giscurs.execute(&quot;SELECT id FROM ways&quot;) for res in giscurs.fetchall(): ## output data outxml.startElement(&quot;error&quot;, {&quot;class&quot;:&quot;1&quot;}) outxml.WayCreate(apiconn.WayGet(res[0])) outxml.endElement(&quot;error&quot;) outxml.endElement(&quot;analyser&quot;) ## output footers outxml._out.close()
    20. 20. Résultat d'analyse <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> <analyser timestamp=&quot;2011-09-26T20:20:55Z&quot;> <class item=&quot;7011&quot; id=&quot;1&quot;> <classtext lang=&quot;fr&quot; title=&quot;Monument historique&quot; /> </class> <error class=&quot;1&quot; subclass=&quot;7351311549282023996&quot;> <location lat=&quot;49.1182439431&quot; lon=&quot;6.17654968492&quot; /> <text lang=&quot;fr&quot; value=&quot;Manque monument historique name=Immeuble heritage=* (Inscrit); heritage:operator=mhs; ref:mhs=PA0010686 mhs:inscription_date=1947 (20 rue Ladoucette, Metz)&quot; /> </error>

    ×