Skip to content

Commit

Permalink
Rename from osmf to osmar
Browse files Browse the repository at this point in the history
  • Loading branch information
codesoap committed Apr 3, 2022
1 parent 9345116 commit 2bdda55
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ from `osm2pgsql`). Read `SETUP_DATABASE.md` to learn how to set up the
required database.

Note that `osm2pgsql` by default does not put all available tags into
the database and osmf only deals with this limited tag-set.
the database and osmar only deals with this limited tag-set.

# Installation
```bash
git clone [email protected]:codesoap/osmf.git
cd osmf
git clone [email protected]:codesoap/osmar.git
cd osmar
go install
# The binary is now at ~/go/bin/osmf.
# The binary is now at ~/go/bin/osmar.
```

If you don't want to install the go compiler, you can download binaries
from the
[latest release page](https://github.com/codesoap/osmf/releases/tag/v2.0.0).
[latest release page](https://github.com/codesoap/osmar/releases/tag/v2.0.0).

# Basic Usage
```console
$ # Find all entries within 50m of the center of Bremen, Germany:
$ osmf 53.076 8.807 50
$ osmar 53.076 8.807 50
table: planet_osm_polygon
distance_meters: 0
osm_id: -3133460
Expand All @@ -41,7 +41,7 @@ way_area: 19706300.000000
...

$ # Use UNIX tools to compact the output:
$ osmf 53.076 8.807 50 | awk '/^$/ /^(distance|osm_link|name)/'
$ osmar 53.076 8.807 50 | awk '/^$/ /^(distance|osm_link|name)/'
distance_meters: 0
osm_link: https://www.openstreetmap.org/relation/3133460
name: Bremen I
Expand All @@ -52,7 +52,7 @@ name: Umweltzone Bremen
...

$ # Find a bicycle shop near the center of Bremen:
$ osmf 53.076 8.807 500 shop=bicycle | awk '/^(table|osm_id):/ {next} //'
$ osmar 53.076 8.807 500 shop=bicycle | awk '/^(table|osm_id):/ {next} //'
distance_meters: 244
osm_link: https://www.openstreetmap.org/node/834082330
addr:housenumber: 30-32
Expand All @@ -64,42 +64,42 @@ shop: bicycle
# More Examples
```bash
# Find a natural forest of at least 1km²:
osmf 53.076 8.807 3300 natural=wood 'way_area>1e+6'
osmar 53.076 8.807 3300 natural=wood 'way_area>1e+6'

# Find a bakery:
osmf 53.076 8.807 200 shop=bakery
osmar 53.076 8.807 200 shop=bakery

# Find nearby public transport stations:
osmf 53.076 8.807 200 public_transport=stop_position
osmar 53.076 8.807 200 public_transport=stop_position

# Find nearby hiking routes:
osmf 53.076 8.807 500 route=hiking
osmar 53.076 8.807 500 route=hiking

# Searching for multiple values of the same tag is also possible:
osmf 53.076 8.807 3000 sport=climbing sport=swimming
osmar 53.076 8.807 3000 sport=climbing sport=swimming

# Pro tip: Use "_" to search for any value:
osmf 53.076 8.807 500 sport=_
osmar 53.076 8.807 500 sport=_

# Learn about the population of the city and it's urban districts:
osmf 53.076 8.807 10000 population=_
osmar 53.076 8.807 10000 population=_
```

# Custom Database Connection
A custom database connection can be used by setting
the `OSMF_CONN` environment variable; find more info
the `OSMAR_CONN` environment variable; find more info
[here](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING):

```console
OSMF_CONN='postgres://user:password@localhost:5432/gis' osmf 53.076 8.807 50
OSMAR_CONN='postgres://user:password@localhost:5432/gis' osmar 53.076 8.807 50
```

# Full Usage Info
```
osmf <lat> <long> <radius_meter> [way_area<<value>] [way_area><value>] [<tag>=<value>]...
osmar <lat> <long> <radius_meter> [way_area<<value>] [way_area><value>] [<tag>=<value>]...
Environment:
OSMF_CONN Custom connection string for the PostgreSQL database.
OSMAR_CONN Custom connection string for the PostgreSQL database.
General tags:
access
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/codesoap/osmf
module github.com/codesoap/osmar

go 1.13

Expand Down
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (
_ "github.com/jackc/pgx/v4/stdlib"
)

const usage = `Usage: osmf <lat> <long> <radius_meter> [way_area<<value>] [way_area><value>] [<tag>=<value>]...
const usage = `Usage: osmar <lat> <long> <radius_meter> [way_area<<value>] [way_area><value>] [<tag>=<value>]...
Info about tags: https://wiki.openstreetmap.org/wiki/Map_Features
Environment:
OSMF_CONN Custom connection string for the PostgreSQL database.
OSMAR_CONN Custom connection string for the PostgreSQL database.
`

var pool *sql.DB
Expand Down Expand Up @@ -55,7 +55,7 @@ func (a byDistance) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a byDistance) Less(i, j int) bool { return a[i].distance < a[j].distance }

func init() {
dataSourceName := os.Getenv("OSMF_CONN")
dataSourceName := os.Getenv("OSMAR_CONN")
if dataSourceName == "" {
dataSourceName = defaultDataSourceName
}
Expand Down

0 comments on commit 2bdda55

Please sign in to comment.