-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.go
41 lines (35 loc) · 990 Bytes
/
model.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package gnis
import (
"github.com/twpayne/go-geom"
"github.com/twpayne/go-geom/encoding/geojson"
"github.com/bzimmer/gravl/pkg/providers/geo"
)
var _ geo.GeoJSON = &GeographicName{}
// GeographicName information about the official name for places, features, and areas
type GeographicName struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Source string `json:"source,omitempty"`
Class string `json:"class,omitempty"`
Locale string `json:"locale,omitempty"`
Point *geom.Point `json:"point,omitempty"`
}
func (g *GeographicName) MarshalJSON() ([]byte, error) {
f, err := g.GeoJSON()
if err != nil {
return nil, err
}
return f.MarshalJSON()
}
func (g *GeographicName) GeoJSON() (*geojson.Feature, error) {
return &geojson.Feature{
ID: g.ID,
Geometry: g.Point,
Properties: map[string]interface{}{
"name": g.Name,
"source": g.Source,
"class": g.Class,
"locale": g.Locale,
},
}, nil
}