Skip to content

Commit

Permalink
Add README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jneo8 committed Jul 19, 2020
1 parent 0d9f9f9 commit d810f94
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 3 deletions.
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# OSM PBF Parser

- Parse pbf file to osm element(Node, Way and Relation)

- Iterator pattern. Easy to get.

- Progress bar for parsing process.

- Control memory usage by using levelDB.

- Convert Element to GeoJSON
- Support type: Node, Way, Relation(polygon, multipolygon)

## Install

```
go get -u https://github.com/jneo8/osmpbfparser-go
```

## Quick start

- **Download the pbf file**

```go
package main

import (
"fmt"
"github.com/jneo8/osmpbfparser-go"
"log"
)

func main() {
parser := osmpbfparser.New(
osmpbfparser.Args{
PBFFile: "./assert/test.pbf",
LevelDBPath: "/tmp/osmpbfparser",
BatchSize: 10000,
},
)

for emt := range parser.Iterator() {
rawJSON, err := emt.ToGeoJSON()
if err != nil {
log.Fatal(err)
}
fmt.Println(string(rawJSON))
}
if err := parser.Err(); err != nil {
log.Fatal(err)
}
}
```
11 changes: 8 additions & 3 deletions cmd/example/main.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
package main

import (
"fmt"
"github.com/jneo8/osmpbfparser-go"
"log"
)

func main() {
parser := osmpbfparser.New(
osmpbfparser.Args{
PBFFile: "./assert/test.pbf",
PBFFile: "./assert/taiwan-latest.osm.pbf",
LevelDBPath: "/tmp/osmpbfparser",
BatchSize: 10000,
},
)

for range parser.Iterator() {
// fmt.Println(emt)
for emt := range parser.Iterator() {
rawJSON, err := emt.ToGeoJSON()
if err != nil {
log.Fatal(err)
}
fmt.Println(string(rawJSON))
}
if err := parser.Err(); err != nil {
log.Fatal(err)
Expand Down

0 comments on commit d810f94

Please sign in to comment.