forked from fbl/keyserver
fetch: merge geolocation types
This commit is contained in:
parent
47cb18592a
commit
41179fbcf5
|
@ -13,7 +13,7 @@ const UPSTREAM_URL = "https://keyserver.freifunk-franken.de/v2/"
|
||||||
func run() error {
|
func run() error {
|
||||||
var root []root
|
var root []root
|
||||||
|
|
||||||
err := os.Mkdir("hoods", 0777)
|
err := os.MkdirAll("hoods", 0777)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -43,12 +43,9 @@ func run() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(h.Polygons) == 0 {
|
if len(h.Polygons) == 0 {
|
||||||
hood.Location = []HoodCoordinate{{Lat: h.Lat, Long: h.Long}}
|
hood.Location = []GeoCoordinate{{Lat: h.Lat, Long: h.Long}}
|
||||||
} else {
|
} else {
|
||||||
hood.Location = []HoodCoordinate{}
|
hood.Location = h.Polygons[0]
|
||||||
for _, p := range h.Polygons[0] {
|
|
||||||
hood.Location = append(hood.Location, HoodCoordinate{Lat: p.Lat, Long: p.Long})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
b, err := json.MarshalIndent(hood, "", " ")
|
b, err := json.MarshalIndent(hood, "", " ")
|
||||||
|
@ -60,6 +57,8 @@ func run() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Printf("%s\n", hood.HoodInfo.Name)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
type root struct {
|
type root struct {
|
||||||
Id uint `json:"id"`
|
Id uint `json:"id"`
|
||||||
Active uint `json:"active"`
|
Active uint `json:"active"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Lat float64 `json:"lat"`
|
Lat float64 `json:"lat"`
|
||||||
Long float64 `json:"lon"`
|
Long float64 `json:"lon"`
|
||||||
Polygons [][]InputCoordinate `json:"polygons"`
|
Polygons [][]GeoCoordinate `json:"polygons"`
|
||||||
Hood Hood
|
Hood Hood
|
||||||
}
|
}
|
||||||
|
|
||||||
type InputCoordinate struct {
|
type GeoCoordinate struct {
|
||||||
Lat float64 `json:"lat"`
|
Lat float64 `json:"lat"`
|
||||||
Long float64 `json:"lon"`
|
Long float64 `json:"lon"`
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ type Hood struct {
|
||||||
// one coordinate: voronoi
|
// one coordinate: voronoi
|
||||||
// two coordinates: invalid
|
// two coordinates: invalid
|
||||||
// three or more coordinates: polygon
|
// three or more coordinates: polygon
|
||||||
Location []HoodCoordinate `json:"location,omitempty"`
|
Location []GeoCoordinate `json:"location,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type HoodNetwork struct {
|
type HoodNetwork struct {
|
||||||
|
@ -58,8 +58,3 @@ type HoodInfo struct {
|
||||||
NtpIp string `json:"ntp_ip"`
|
NtpIp string `json:"ntp_ip"`
|
||||||
Timestamp uint64 `json:"timestamp"`
|
Timestamp uint64 `json:"timestamp"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type HoodCoordinate struct {
|
|
||||||
Lat float64 `json:"lat"`
|
|
||||||
Long float64 `json:"lon"`
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue