-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from tianpf/main
add example encoding.
- Loading branch information
Showing
75 changed files
with
256 additions
and
100 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
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
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
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
Binary file not shown.
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,2 @@ | ||
way_id,pt_id,x,y | ||
0,0,102,0.5 |
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 @@ | ||
{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Point","coordinates":[102,0.5]},"properties":{"prop0":"value0"}}]} |
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 @@ | ||
01070000000100000001010000000000000000805940000000000000e03f |
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 @@ | ||
GEOMETRYCOLLECTION(POINT(102 0.5)) |
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,162 @@ | ||
// Example This is an example . | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/spatial-go/geoos/geoencoding" | ||
) | ||
|
||
func main() { | ||
rawJSON := []byte(` | ||
{ "type": "FeatureCollection", | ||
"features": [ | ||
{ "type": "Feature", | ||
"geometry": {"type": "Point", "coordinates": [102.0, 0.5]}, | ||
"properties": {"prop0": "value0"} | ||
} | ||
] | ||
}`) | ||
|
||
buf := new(bytes.Buffer) | ||
buf.Write(rawJSON) | ||
|
||
if geomFeatureCollection, err := geoencoding.ReadGeoJSON(buf, geoencoding.GeoJSON); err != nil { | ||
fmt.Printf("ReadGeoJSON error:%v", err) | ||
} else { | ||
fmt.Println(geomFeatureCollection) | ||
|
||
filename := "../data/geojson.json" | ||
if file, err := os.Create(filename); err != nil { | ||
fmt.Println(err) | ||
} else { | ||
defer file.Close() | ||
|
||
if err := geoencoding.WriteGeoJSON(file, geomFeatureCollection, geoencoding.GeoJSON); err != nil { | ||
fmt.Printf("WriteGeoJSON error:%v", err) | ||
} | ||
} | ||
|
||
filename = "../data/geojson.json" | ||
if file, err := os.Open(filename); err != nil { | ||
fmt.Println(err) | ||
} else { | ||
defer file.Close() | ||
|
||
if geomFeatureCollection, err := geoencoding.ReadGeoJSON(file, geoencoding.GeoJSON); err != nil { | ||
fmt.Printf("ReadGeoJSON error:%v", err) | ||
} else { | ||
buf := new(bytes.Buffer) | ||
_ = geoencoding.WriteGeoJSON(buf, geomFeatureCollection, geoencoding.GeoJSON) | ||
bufStr := buf.String() | ||
fmt.Println(bufStr) | ||
} | ||
} | ||
|
||
filename = "../data/geobuf.proto" | ||
if file, err := os.Create(filename); err != nil { | ||
fmt.Println(err) | ||
} else { | ||
defer file.Close() | ||
if err := geoencoding.WriteGeoJSON(file, geomFeatureCollection, geoencoding.Geobuf); err != nil { | ||
fmt.Printf("WriteGeoJSON error:%v", err) | ||
} | ||
} | ||
|
||
filename = "../data/geobuf.proto" | ||
if file, err := os.Open(filename); err != nil { | ||
fmt.Println(err) | ||
} else { | ||
defer file.Close() | ||
|
||
if geomFeatureCollection, err := geoencoding.ReadGeoJSON(file, geoencoding.Geobuf); err != nil { | ||
fmt.Printf("ReadGeoJSON error:%v", err) | ||
} else { | ||
buf := new(bytes.Buffer) | ||
_ = geoencoding.WriteGeoJSON(buf, geomFeatureCollection, geoencoding.GeoJSON) | ||
bufStr := buf.String() | ||
fmt.Println(bufStr) | ||
} | ||
} | ||
|
||
filename = "../data/geocsv.csv" | ||
if file, err := os.Create(filename); err != nil { | ||
fmt.Println(err) | ||
} else { | ||
defer file.Close() | ||
if err := geoencoding.WriteGeoJSON(file, geomFeatureCollection, geoencoding.GeoCSV); err != nil { | ||
fmt.Printf("WriteGeoJSON error:%v", err) | ||
} | ||
} | ||
|
||
filename = "../data/geocsv.csv" | ||
if file, err := os.Open(filename); err != nil { | ||
fmt.Println(err) | ||
} else { | ||
defer file.Close() | ||
|
||
if geomFeatureCollection, err := geoencoding.ReadGeoJSON(file, geoencoding.GeoCSV); err != nil { | ||
fmt.Printf("ReadGeoJSON error:%v", err) | ||
} else { | ||
buf := new(bytes.Buffer) | ||
_ = geoencoding.WriteGeoJSON(buf, geomFeatureCollection, geoencoding.GeoJSON) | ||
bufStr := buf.String() | ||
fmt.Println(bufStr) | ||
} | ||
} | ||
|
||
filename = "../data/geowkb.wkb" | ||
if file, err := os.Create(filename); err != nil { | ||
fmt.Println(err) | ||
} else { | ||
defer file.Close() | ||
if err := geoencoding.WriteGeoJSON(file, geomFeatureCollection, geoencoding.WKB); err != nil { | ||
fmt.Printf("WriteGeoJSON error:%v", err) | ||
} | ||
} | ||
|
||
filename = "../data/geowkb.wkb" | ||
if file, err := os.Open(filename); err != nil { | ||
fmt.Println(err) | ||
} else { | ||
defer file.Close() | ||
|
||
if geomFeatureCollection, err := geoencoding.ReadGeoJSON(file, geoencoding.WKB); err != nil { | ||
fmt.Printf("ReadGeoJSON error:%v", err) | ||
} else { | ||
buf := new(bytes.Buffer) | ||
_ = geoencoding.WriteGeoJSON(buf, geomFeatureCollection, geoencoding.GeoJSON) | ||
bufStr := buf.String() | ||
fmt.Println(bufStr) | ||
} | ||
} | ||
|
||
filename = "../data/geowkt.wkt" | ||
if file, err := os.Create(filename); err != nil { | ||
fmt.Println(err) | ||
} else { | ||
defer file.Close() | ||
if err := geoencoding.WriteGeoJSON(file, geomFeatureCollection, geoencoding.WKT); err != nil { | ||
fmt.Printf("WriteGeoJSON error:%v", err) | ||
} | ||
} | ||
|
||
filename = "../data/geowkt.wkt" | ||
if file, err := os.Open(filename); err != nil { | ||
fmt.Println(err) | ||
} else { | ||
defer file.Close() | ||
|
||
if geomFeatureCollection, err := geoencoding.ReadGeoJSON(file, geoencoding.WKT); err != nil { | ||
fmt.Printf("ReadGeoJSON error:%v", err) | ||
} else { | ||
buf := new(bytes.Buffer) | ||
_ = geoencoding.WriteGeoJSON(buf, geomFeatureCollection, geoencoding.GeoJSON) | ||
bufStr := buf.String() | ||
fmt.Println(bufStr) | ||
} | ||
} | ||
} | ||
} |
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
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
4 changes: 2 additions & 2 deletions
4
encoding/geobuf/decode/decode.go → geoencoding/geobuf/decode/decode.go
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
4 changes: 2 additions & 2 deletions
4
encoding/geobuf/decode/feature.go → geoencoding/geobuf/decode/feature.go
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
4 changes: 2 additions & 2 deletions
4
encoding/geobuf/encode/encode.go → geoencoding/geobuf/encode/encode.go
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
4 changes: 2 additions & 2 deletions
4
encoding/geobuf/encode/feature_encode.go → geoencoding/geobuf/encode/feature_encode.go
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
Oops, something went wrong.