Ankündigung

Einklappen
Keine Ankündigung bisher.

osm-xpath Abrrage mit PHP simpleXML

Einklappen

Neue Werbung 2019

Einklappen
X
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • #16
    hi danke

    Zitat von tr0y Beitrag anzeigen
    Das ist schon der Fall. die Sub-Arrays in $data tragen alle Attribute vom node tag und alle assoziativen Daten aus den Tag-Unterknoten.

    die großen Zusammenhänge mach ich mir mal später (heut abend klar)

    PHP-Code:
    $result $dom->xpath("node[tag/@k='amenity' and tag/@v='school']"); 
    ...brauchen mehr tags hier...

    BTW:
    wie im Threadstart bemerkt sind es ja Anfragen an dem Overpass-Endpoint:


    hier:


    PHP-Code:

    $endpoint 
    'http://overpass-api.de/api/interpreter'
    hier die kpl. Abfragen:


    PHP-Code:

    <?php
    /**
     * OSM Overpass API with PHP SimpleXML / XPath
     *
     * PHP Version: 5.4 - Can be back-ported to 5.3 by using 5.3 Array-Syntax (not PHP 5.4's square brackets)
     */


    //
    // 1.) Query an OSM Overpass API Endpoint
    //

    $query 'node
      ["amenity"~".*"]
      (38.415938460513274,16.06338500976562,39.52205163048525,17.51220703125);
    out;'
    ;

    $context stream_context_create(['http' => [
        
    'method'  => 'POST',
        
    'header' => ['Content-Type: application/x-www-form-urlencoded'],
        
    'content' => 'data=' urlencode($query),
    ]]);

    # please do not stress this service, this example is for demonstration purposes only.
    $endpoint 'http://overpass-api.de/api/interpreter';
    libxml_set_streams_context($context);
    $start microtime(true);

    $result simplexml_load_file($endpoint);
    printf("Query returned %2\$d node(s) and took %1\$.5f seconds.\n\n"microtime(true) - $startcount($result->node));

    //
    oder auch dieser untenstehenden - wo mehr als 2000 records /(resultate ) herauskommen.
    Da stellt sich natürlich die Frage - in manchen sind viele in manchen sind wenige Values zu den k attributen vorhanden.

    PHP-Code:

    <?php

    $query 
    'node
      ["addr:postcode"~"RM12"]
      (51.5557914,0.2118915,51.5673083,0.2369398);
       node
      (around:1000)
      ["amenity"~"fast_food"];
               out;'
    ;

    $context stream_context_create(['http' => [
        
    'method'  => 'POST',
        
    'header' => ['Content-Type: application/x-www-form-urlencoded'],
        
    'content' => 'data=' urlencode($query),
    ]]);

    $endpoint 'http://overpass-api.de/api/interpreter';
    libxml_set_streams_context($context);

    $result simplexml_load_file($endpoint);
    printf("Query returned %2\$d node(s) and took %1\$.5f seconds.\n\n"microtime(true) - $startcount($result->node));
    }
    und da sind dann unterschiedl. Mengen an Werten ( vorhanden)...
    Die es interessanterweise herauszuholen gilt....

    meld mich heut abend wieder


    vg dilbert

    update: es geht mir um ein catch all nodes ...


    vgl.
    PHP-Code:
    //node() | //@* | //namespace::* 
    ... this selects any node (of type document node /, element node, text node, processing instruction node and comment node) and any attribute node and any namespace node -- that is all nodes because there are no other types of nodes. How you access the obtained XmlNodeList containing the selected nodes depends on the API of the specific XPath engine you are using -- read and use your documentation.

    vgl auch hier: http://stackoverflow.com/questions/8...ath-expression




    What is the xpath expression to select all nodes of a document?
    Given this example XML:

    PHP-Code:
    <div class="header"/> 
    It contains three nodes: <div> (element), class= (attribute) and "header" (text).

    PHP-Code:
    $doc = new DOMDocument;
    $doc->loadXml('<div class="header"/>');
    $xpath = new DOMXPath($doc); 
    I tried with
    PHP-Code:
     //node(): 
    PHP-Code:


    $xpath
    ->query('//node()'); 
    which returns all element nodes only
    (I assume because of //).
    Is there a way to add other nodes
    like attributes and textnodes in attribute values?

    Kommentar


    • #17
      hi irgendwie komm ich hier nicht weiter --- ich

      will mal am we versuchen noch ein paar tags zu adden

      operator=* - Name of operator, often the local education authority.
      addr=* - Address details
      capacity=*, for the number of pupils taught at the school
      isced:level=*, for the educational level (proposed tags)
      fee=yes if the the school makes a direct charge for core services.
      religion=*, if the school is associated with a particular religion (also denomination=*)
      wikipedia=*, for a link to a Wikipedia article about the school
      website=*, for a link to the school's own website

      http://wiki.openstreetmap.org/wiki/Tag:amenity%3Dschool

      Kommentar

      Lädt...
      X