-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add first osm attempt (missing ways and relations)
- Loading branch information
Michele Masili
committed
Jul 18, 2021
1 parent
8caab03
commit b651385
Showing
18 changed files
with
3,183 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Go | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*.*.*' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.16 | ||
|
||
- name: Build Windows | ||
run: env GOOS=windows GOARCH=amd64 go build -o experive.exe -v cmd/cli/main.go | ||
|
||
- name: Build Linux x64 | ||
run: env GOOS=linux GOARCH=amd64 go build -o experive cmd/cli/main.go | ||
|
||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: | | ||
experive.exe | ||
experive | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package json | ||
|
||
type OsmParser struct { | ||
node int64 | ||
ways int64 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package json | ||
|
||
import ( | ||
"fmt" | ||
"github.com/meekyphotos/experive-cli/core/commands/osm" | ||
"io" | ||
"os" | ||
"runtime" | ||
"testing" | ||
) | ||
|
||
func (o *OsmParser) CountNodes() { | ||
open, err := os.Open("netherlands.osm.pbf") | ||
if err != nil { | ||
panic(err) | ||
} | ||
d := osm.NewDecoder(open) | ||
d.SetBufferSize(osm.MaxBlobSize) | ||
d.Skip(false, true, true) | ||
if err := d.Start(runtime.GOMAXPROCS(-1)); err != nil { | ||
panic(err) | ||
} | ||
for { | ||
v, err := d.Decode() | ||
if err == io.EOF { | ||
break | ||
} | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
switch v.(type) { | ||
case *osm.Node: | ||
o.node++ | ||
//fmt.Println(v) | ||
case *osm.Way: | ||
o.ways++ | ||
case *osm.Relation: | ||
default: | ||
} | ||
} | ||
} | ||
|
||
// 9.991.103 in 14.69s only counting and skipping ways and relations | ||
func TestParsing(t *testing.T) { | ||
parser := OsmParser{} | ||
parser.CountNodes() | ||
fmt.Println(parser.node, parser.ways) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package osm | ||
|
||
import "time" | ||
|
||
type BoundingBox struct { | ||
Left float64 | ||
Right float64 | ||
Top float64 | ||
Bottom float64 | ||
} | ||
|
||
type Header struct { | ||
BoundingBox *BoundingBox | ||
RequiredFeatures []string | ||
OptionalFeatures []string | ||
WritingProgram string | ||
Source string | ||
OsmosisReplicationTimestamp time.Time | ||
OsmosisReplicationSequenceNumber int64 | ||
OsmosisReplicationBaseUrl string | ||
} | ||
|
||
type Info struct { | ||
Version int32 | ||
Uid int32 | ||
Timestamp time.Time | ||
Changeset int64 | ||
User string | ||
Visible bool | ||
} | ||
|
||
type Node struct { | ||
OsmId int64 | ||
Class string | ||
Type string | ||
Lat float64 | ||
Lon float64 | ||
Tags string | ||
Names string | ||
} | ||
|
||
type Way struct { | ||
ID int64 | ||
Tags map[string]string | ||
NodeIDs []int64 | ||
Info Info | ||
} | ||
|
||
type MemberType int | ||
|
||
const ( | ||
NodeType MemberType = iota | ||
WayType | ||
RelationType | ||
) | ||
|
||
type Member struct { | ||
ID int64 | ||
Type MemberType | ||
Role string | ||
} | ||
|
||
type Relation struct { | ||
ID int64 | ||
Tags map[string]string | ||
Members []Member | ||
Info Info | ||
} |
Oops, something went wrong.