New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

github.com/turistikrota/osm

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/turistikrota/osm

  • v0.0.5
  • Source
  • Go
  • Socket score

Version published
Created
Source

turistikrota osm

The osm package provides functions to interact with the OpenStreetMap API. It includes functionalities for reverse geocoding, retrieving details about specific OSM objects, searching for places, and looking up information based on OSM type and ID.

Installation

To install the package, use:

go get github.com/turistikrota/osm

Usage

Importing the Package

import "github.com/turistikrota/osm"

Methods

  • Reverse(ctx context.Context, lat float64, long float64, opts ...optFunc) (*ReverseResult, error)
  • Details(ctx context.Context, osmType string, osmID int, opts ...optFunc) (*DetailsResult, error)
  • DetailsWithPlaceID(ctx context.Context, placeID int, opts ...optFunc) (*DetailsResult, error)
  • Search(ctx context.Context, q string, opts ...optFunc) ([]SearchResult, error)
  • Lookup(ctx context.Context, osmType string, osmID int, opts ...optFunc) (*LookupResult, error)

Internationalization

The package supports internationalization. To set the language for the API requests, use the WithLanguage option:

result, err := osm.Reverse(ctx, 40.748817, -73.985428, osm.WithLocale("de"))

or change the default language:

osm.DefaultConfig = osm.Config{
    Locale: "de",
}

Examples

Reverse Geocoding
package main

import (
    "context"
    "fmt"
    "github.com/turistikrota/osm"
)

func main() {
    ctx := context.Background()
    result, err := osm.Reverse(ctx, 40.748817, -73.985428) // Latitude and Longitude for the Empire State Building
    if err != nil {
        fmt.Println("Error:", err)
        return
    }
    fmt.Println("Reverse Geocoding Result:", result)
}
Retrieving Details
package main

import (
    "context"
    "fmt"
    "github.com/turistikrota/osm"
)

func main() {
    ctx := context.Background()
    result, err := osm.DetailsWithPlaceID(ctx, 240109189) // PlaceID for the Empire State Building
    if err != nil {
        fmt.Println("Error:", err)
        return
    }
    fmt.Println("Details Result:", result)
}
Searching for Places
package main

import (
    "context"
    "fmt"
    "github.com/turistikrota/osm"
)

func main() {
    ctx := context.Background()
    results, err := osm.Search(ctx, "Central Park")
    if err != nil {
        fmt.Println("Error:", err)
        return
    }
    for _, result := range results {
        fmt.Println("Search Result:", result)
    }
}
Looking Up Information
package main

import (
    "context"
    "fmt"
    "github.com/turistikrota/osm"
)

func main() {
    ctx := context.Background()
    result, err := osm.Lookup(ctx, "way", 123456789) // Example OSM type and ID
    if err != nil {
        fmt.Println("Error:", err)
        return
    }
    fmt.Println("Lookup Result:", result)
}

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

FAQs

Package last updated on 22 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc