Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. JavaScript
    5. [gelöst] Standort herausfiltern

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    [gelöst] Standort herausfiltern

    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      Chrille1507 last edited by Chrille1507

      Liebes Forum,

      erneut muss ich um eure Hilfe bitten.
      Ich möchte OpenCage nutzen, um den Standort einzelner Personen darzustellen. Die Abfrage der Daten ist erst einmal kein Problem aber ich bin nicht in der Lage, gewisse Daten aus den JSON Response herauszufiltern.
      Könnt ihr mir bitte dabei helfen?

      Das JSON Response sieht so aus:

      {
        "documentation": "https://opencagedata.com/api",
        "licenses": [
          {
            "name": "see attribution guide",
            "url": "https://opencagedata.com/credits"
          }
        ],
        "rate": {
          "limit": 2500,
          "remaining": 2483,
          "reset": 1670284800
        },
        "results": [
          {
            "annotations": {
              "DMS": {
                "lat": "52° 23' 16.01880'' N",
                "lng": "9° 44' 0.38184'' E"
              },
              "MGRS": "32UND4991404423",
              "Maidenhead": "JO42uj83ab",
              "Mercator": {
                "x": 1083521.518,
                "y": 6836676.75
              },
              "OSM": {
                "edit_url": "https://www.openstreetmap.org/edit?node=9041448608#map=16/52.38778/9.73344",
                "note_url": "https://www.openstreetmap.org/note/new#map=16/52.38778/9.73344&layers=N",
                "url": "https://www.openstreetmap.org/?mlat=52.38778&mlon=9.73344#map=16/52.38778/9.73344"
              },
              "UN_M49": {
                "regions": {
                  "DE": "276",
                  "EUROPE": "150",
                  "WESTERN_EUROPE": "155",
                  "WORLD": "001"
                },
                "statistical_groupings": [
                  "MEDC"
                ]
              },
              "callingcode": 49,
              "currency": {
                "alternate_symbols": [
      
                ],
                "decimal_mark": ",",
                "html_entity": "€",
                "iso_code": "EUR",
                "iso_numeric": "978",
                "name": "Euro",
                "smallest_denomination": 1,
                "subunit": "Cent",
                "subunit_to_unit": 100,
                "symbol": "€",
                "symbol_first": 0,
                "thousands_separator": "."
              },
              "flag": "🇩🇪",
              "geohash": "u1qfj2zsvwd6ntczum3r",
              "qibla": 131.65,
              "roadinfo": {
                "drive_on": "right",
                "road": "Philipsbornstraße",
                "speed_in": "km/h"
              },
              "sun": {
                "rise": {
                  "apparent": 1670224440,
                  "astronomical": 1670216940,
                  "civil": 1670222040,
                  "nautical": 1670219460
                },
                "set": {
                  "apparent": 1670252940,
                  "astronomical": 1670260440,
                  "civil": 1670255340,
                  "nautical": 1670257920
                }
              },
              "timezone": {
                "name": "Europe/Berlin",
                "now_in_dst": 0,
                "offset_sec": 3600,
                "offset_string": "+0100",
                "short_name": "CET"
              },
              "what3words": {
                "words": "wiege.abbiegen.bauwerke"
              }
            },
            "bounds": {
              "northeast": {
                "lat": 52.387833,
                "lng": 9.7334894
              },
              "southwest": {
                "lat": 52.387733,
                "lng": 9.7333894
              }
            },
            "components": {
              "ISO_3166-1_alpha-2": "DE",
              "ISO_3166-1_alpha-3": "DEU",
              "ISO_3166-2": [
                "DE-NI"
              ],
              "_category": "building",
              "_type": "building",
              "city": "Hannover",
              "city_district": "Vahrenwald-List",
              "continent": "Europe",
              "country": "Deutschland",
              "country_code": "de",
              "county": "Region Hannover",
              "house_number": "2",
              "office": "Design Offices",
              "political_union": "European Union",
              "postcode": "30165",
              "road": "Philipsbornstraße",
              "state": "Niedersachsen",
              "state_code": "NI",
              "suburb": "Vahrenwald"
            },
            "confidence": 10,
            "formatted": "Design Offices, Philipsbornstraße 2, 30165 Hannover, Deutschland",
            "geometry": {
              "lat": 52.387783,
              "lng": 9.7334394
            }
          }
        ],
        "status": {
          "code": 200,
          "message": "OK"
        },
        "stay_informed": {
          "blog": "https://blog.opencagedata.com",
          "twitter": "https://twitter.com/OpenCage"
        },
        "thanks": "For using an OpenCage API",
        "timestamp": {
          "created_http": "Mon, 05 Dec 2022 08:09:25 GMT",
          "created_unix": 1670227765
        },
        "total_results": 1
      }
      

      Für mich wären alle Informationen aus dem Bereich "Components" interessant. Leider gelingt es mir nicht, die Daten einzeln aufzuschlüsseln.

      arteck liv-in-sky paul53 3 Replies Last reply Reply Quote 0
      • arteck
        arteck Developer Most Active @Chrille1507 last edited by arteck

        @chrille1507 sagte in Standort herausfiltern:

        Lage, gewisse Daten aus den JSON Response herauszufiltern.

        warum nicht ?? was geht den nicht

        C 1 Reply Last reply Reply Quote 0
        • liv-in-sky
          liv-in-sky @Chrille1507 last edited by liv-in-sky

          @chrille1507 sagte in Standort herausfiltern:

          Components

          in javascript oder blockly??
          was genau willst du damit machen? also wie willst du die daten aufbereiten - was genau suchst du daraus?

          {
            "ISO_3166-1_alpha-2": "DE",
            "ISO_3166-1_alpha-3": "DEU",
            "ISO_3166-2": [
              "DE-NI"
            ],
            "_category": "building",
            "_type": "building",
            "city": "Hannover",
            "city_district": "Vahrenwald-List",
            "continent": "Europe",
            "country": "Deutschland",
            "country_code": "de",
            "county": "Region Hannover",
            "house_number": "2",
            "office": "Design Offices",
            "political_union": "European Union",
            "postcode": "30165",
            "road": "xxxxxxx",
            "state": "Niedersachsen",
            "state_code": "NI",
            "suburb": "Vahrenwald"
          }
          
          C 1 Reply Last reply Reply Quote 0
          • C
            Chrille1507 @arteck last edited by

            @arteck

            Ich habe es mit Blockly versucht aber bekomme immer "null" als Ergebnis.
            Ich habe schon diverse Sachen im Bereich "Attribut" getestet aber leider immer das gleiche Ergebnis erhalten.

            ef3f27be-b782-4e3d-a91d-7ea6e6188f98-grafik.png

            liv-in-sky 1 Reply Last reply Reply Quote 0
            • liv-in-sky
              liv-in-sky @Chrille1507 last edited by liv-in-sky

              @chrille1507

              das annotation gehört weg

              1 Reply Last reply Reply Quote 0
              • C
                Chrille1507 @liv-in-sky last edited by

                @liv-in-sky Hallo,

                ich benötige vor allem die Straße (road) und Hausnummer (house_number).

                Damit wäre mir schon geholfen und falls ich mehr benötige, hoffe ich das Prinzip dahinter verstanden zu haben und den Rest alleine zu schaffen.

                Zur zeit versuche ich mein Glück mit Blockly, würde tatsächlich es aber lieber in javascript haben wollen.

                liv-in-sky Homoran 3 Replies Last reply Reply Quote 0
                • liv-in-sky
                  liv-in-sky @Chrille1507 last edited by

                  @chrille1507

                  "results.components.house_number"
                  "results.components.road"

                  1 Reply Last reply Reply Quote 0
                  • liv-in-sky
                    liv-in-sky @Chrille1507 last edited by

                    @chrille1507

                    und ändere in deinem obigen post den eintrag für deine adresse 🙂 im json - einfach im post die straße überschreiben

                    1 Reply Last reply Reply Quote 0
                    • Homoran
                      Homoran Global Moderator Administrators @Chrille1507 last edited by

                      @chrille1507
                      Screenshot_20221205-100122_Firefox.jpg

                      und die .0. nicht vergessen

                      C 1 Reply Last reply Reply Quote 2
                      • paul53
                        paul53 @Chrille1507 last edited by

                        @chrille1507

                        let strasse = JSON.parse(json).results[0].components.road;
                        
                        1 Reply Last reply Reply Quote 0
                        • C
                          Chrille1507 @Homoran last edited by Chrille1507

                          @homoran
                          Vielen Dank. Das ist die Lösung. Die 0 hat gefehlt

                          Herzlichen Dank an euch alle für die schnelle Hilfe!!!

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post

                          Support us

                          ioBroker
                          Community Adapters
                          Donate

                          411
                          Online

                          31.9k
                          Users

                          80.2k
                          Topics

                          1.3m
                          Posts

                          5
                          11
                          433
                          Loading More Posts
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes
                          Reply
                          • Reply as topic
                          Log in to reply
                          Community
                          Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                          The ioBroker Community 2014-2023
                          logo