diff pkg/wfs/capabilities.go @ 1679:2dc7768be0e4

Waterway axis import: More on reading data from WFS. TODO: Parse to concrete features.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 26 Dec 2018 21:01:29 +0100
parents efc409e330a6
children 6caf5cd6249e
line wrap: on
line diff
--- a/pkg/wfs/capabilities.go	Wed Dec 26 10:54:52 2018 +0100
+++ b/pkg/wfs/capabilities.go	Wed Dec 26 21:01:29 2018 +0100
@@ -15,6 +15,7 @@
 
 import (
 	"encoding/xml"
+	"errors"
 	"io"
 	"regexp"
 	"strconv"
@@ -315,6 +316,19 @@
 	return max
 }
 
+var (
+	ErrInvalidCRS = errors.New("Invalid CRS string")
+	crsRe         = regexp.MustCompile(`urn:ogc:def:crs:EPSG:[^:]*:(\d+)`)
+)
+
+func CRSToEPSG(s string) (int, error) {
+	m := crsRe.FindStringSubmatch(s)
+	if m == nil {
+		return 0, ErrInvalidCRS
+	}
+	return strconv.Atoi(m[1])
+}
+
 func ParseCapabilities(r io.Reader) (*Capabilities, error) {
 
 	decoder := xml.NewDecoder(r)