Skip to content

Commit

Permalink
Merge branch 'clydedacruz-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekSi committed Mar 25, 2018
2 parents e1e4854 + d03e78c commit 52ee967
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
2 changes: 0 additions & 2 deletions decode_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ func (dec *dataDecoder) parseNodes(pb *OSMPBF.PrimitiveBlock, nodes []*OSMPBF.No
info := extractInfo(st, node.GetInfo(), dateGranularity)

dec.q = append(dec.q, &Node{id, latitude, longitude, tags, info})

panic("Please test this first")
}

}
Expand Down
36 changes: 25 additions & 11 deletions decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@ import (
)

const (
// Test files are stored at https://gist.github.com/AlekSi/d4369aa13cf1fc5ddfac3e91b67b2f7b
// 8604f36a7357adfbd6b5292c2ea4972d9d0bfd3d is the latest commit.
GistURL = "https://gist.githubusercontent.com/AlekSi/d4369aa13cf1fc5ddfac3e91b67b2f7b/raw/8604f36a7357adfbd6b5292c2ea4972d9d0bfd3d/"

// Originally downloaded from http://download.geofabrik.de/europe/great-britain/england/greater-london.html
// Stored at https://gist.github.com/AlekSi/d4369aa13cf1fc5ddfac3e91b67b2f7b
London = "greater-london-140324.osm.pbf"
LondonURL = "https://gist.githubusercontent.com/AlekSi/d4369aa13cf1fc5ddfac3e91b67b2f7b/raw/f87959d6c9466547d9759971e071a15049b67ae2/greater-london-140324.osm.pbf"
London = "greater-london-140324.osm.pbf"

// Same file as above, but without 'DenseNodes'. This has been generated using the below command (using osmium-tool http://osmcode.org/osmium-tool/)
// "osmium cat -o greater-london-140324-nondense.osm.pbf greater-london-140324.osm.pbf -f osm.pbf,pbf_dense_nodes=false"
LondonNonDense = "greater-london-140324-nondense.osm.pbf"
)

func parseTime(s string) time.Time {
Expand Down Expand Up @@ -141,16 +147,16 @@ func init() {
}
}

func downloadTestOSMFile(t *testing.T) {
_, err := os.Stat(London)
func downloadTestOSMFile(fileName string, t *testing.T) {
_, err := os.Stat(fileName)
if err == nil {
return
}
if !os.IsNotExist(err) {
t.Fatal(err)
}

resp, err := http.Get(LondonURL)
resp, err := http.Get(GistURL + fileName)
if err != nil {
t.Fatal(err)
}
Expand All @@ -160,7 +166,7 @@ func downloadTestOSMFile(t *testing.T) {
t.Fatalf("expected 200, got %d", resp.StatusCode)
}

out, err := os.Create(London)
out, err := os.Create(fileName)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -199,10 +205,10 @@ func checkHeader(a *Header) bool {
return true
}

func TestDecode(t *testing.T) {
downloadTestOSMFile(t)
func decodePBF(PBFfileName string, t *testing.T) {
downloadTestOSMFile(PBFfileName, t)

f, err := os.Open(London)
f, err := os.Open(PBFfileName)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -288,8 +294,16 @@ func TestDecode(t *testing.T) {
}
}

func TestDecodePBFWithDenseNodes(t *testing.T) {
decodePBF(London, t)
}

func TestDecodePBFWithNodes(t *testing.T) {
decodePBF(LondonNonDense, t)
}

func TestDecodeConcurrent(t *testing.T) {
downloadTestOSMFile(t)
downloadTestOSMFile(London, t)

f, err := os.Open(London)
if err != nil {
Expand Down

0 comments on commit 52ee967

Please sign in to comment.