forked from paulmach/osm
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmap.go
33 lines (27 loc) · 862 Bytes
/
map.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
package osmapi
import (
"context"
"fmt"
"github.com/onXmaps/osm"
)
// Map returns the latest elements in the given bounding box.
// Delegates to the DefaultDatasource and uses its http.Client to make the request.
func Map(ctx context.Context, bounds *osm.Bounds, opts ...FeatureOption) (*osm.OSM, error) {
return DefaultDatasource.Map(ctx, bounds, opts...)
}
// Map returns the latest elements in the given bounding box.
func (ds *Datasource) Map(ctx context.Context, bounds *osm.Bounds, opts ...FeatureOption) (*osm.OSM, error) {
params, err := featureOptions(opts)
if err != nil {
return nil, err
}
url := fmt.Sprintf("%s/map?bbox=%f,%f,%f,%f&%s", ds.baseURL(),
bounds.MinLon, bounds.MinLat,
bounds.MaxLon, bounds.MaxLat,
params)
o := &osm.OSM{}
if err := ds.getFromAPI(ctx, url, &o); err != nil {
return nil, err
}
return o, nil
}