diff --git a/cli/cmd/map.go b/cli/cmd/map.go index 2342eea..eb18691 100644 --- a/cli/cmd/map.go +++ b/cli/cmd/map.go @@ -145,7 +145,6 @@ var getmapCommand = &cobra.Command{ return err } } - if cmd.Flag("dry-run").Changed { fmt.Println(s) fmt.Println("File name:", name) diff --git a/getcap/abilities.go b/getcap/abilities.go index 98c806e..1580d2c 100644 --- a/getcap/abilities.go +++ b/getcap/abilities.go @@ -33,7 +33,11 @@ func (ll Layers) GetLayer(layer string) Layer { // GetBBox returns a BBox based on a specific EPSG code func (a Abilities) GetBBox(epsg int) BBox { - return a.Layers.GetBBox(epsg) + bbox := a.Layers.GetBBox(epsg) + if bbox.MinX != 0 && bbox.MaxX != 0 { + return bbox + } + return a.BBoxes.GetBBox(epsg) } // GetBBox returns a BBox based on a specific EPSG code @@ -60,7 +64,16 @@ func (bb BBoxes) GetBBox(epsg int) BBox { // GetBBoxes returns BBoxes merged from all Layers func (a Abilities) GetBBoxes() BBoxes { - return a.Layers.GetBBoxes() + var bb []BBox + + for _, b := range append(a.Layers.GetBBoxes(), a.BBoxes...) { + if (b.CRS == "" && b.SRS == "") || (b.MinX == 0 && b.MaxX == 0) { + continue + } + bb = append(bb, b) + } + + return bb } // GetBBoxes returns BBoxes merged from Layers diff --git a/getcap/format.go b/getcap/format.go index 4f5286d..1a8bf60 100644 --- a/getcap/format.go +++ b/getcap/format.go @@ -26,6 +26,10 @@ func (a Abilities) String() string { result += "\nLayers:\n" result += a.Layers.String() } + if a.BBoxes != nil { + result += "\nBBoxes:\n" + result += a.BBoxes.String() + } return result } diff --git a/getcap/getcap.go b/getcap/getcap.go index f686540..5665ccd 100644 --- a/getcap/getcap.go +++ b/getcap/getcap.go @@ -29,6 +29,7 @@ type Abilities struct { Abstract string `xml:"Service>Abstract"` Formats Formats `xml:"Capability>Request>GetMap>Format"` Layers Layers `xml:"Capability>Layer>Layer"` + BBoxes BBoxes `xml:"Capability>Layer>BoundingBox"` } // Layer of a GetCapabilities-Request diff --git a/getmap/getmap.go b/getmap/getmap.go index 83fe350..7068c9b 100644 --- a/getmap/getmap.go +++ b/getmap/getmap.go @@ -156,7 +156,7 @@ func AddLayers(layers ...string) func(*Service) error { func (s *Service) AddLayers(layers ...string) (err error) { for _, l := range layers { cl := s.Capabilities.GetLayer(l) - if cl.Name == "" || len(cl.BBoxes) < 1 { + if cl.Name == "" { return InvalidValue{"Layer", l, s.Capabilities.GetLayerNames()} } } @@ -198,7 +198,7 @@ func AddEPSG(epsgCode int) func(*Service) error { // AddEPSG adds an EPSG code to a Service func (s *Service) AddEPSG(epsgCode int) (err error) { - epsgCap := s.Capabilities.GetLayers(s.Layers...).GetBBoxes().GetEPSG() + epsgCap := s.Capabilities.GetBBoxes().GetEPSG() if len(epsgCap) == 0 { return errors.New("Adding EPSG failed") } @@ -361,7 +361,7 @@ func (s *Service) GetMap(minx, miny, maxx, maxy float64, o Option) (r *bytes.Rea err = InvalidInput("Invalid: Image is too big: " + strconv.Itoa(width*height) + " Max Pixel: " + strconv.Itoa(MaxPixel)) return } - epsgCap := s.Capabilities.GetLayers(s.Layers...).GetBBoxes().GetEPSG() + epsgCap := s.Capabilities.GetBBoxes().GetEPSG() if !containsInt(epsgCap, s.EPSG) { from := wgs84.EPSG().Code(s.EPSG) if from == nil {