Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions .github/workflows/lint.yml

This file was deleted.

129 changes: 0 additions & 129 deletions .golangci.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ogc-specifications
[![Lint](https://github.com/PDOK/ogc-specifications/actions/workflows/lint.yml/badge.svg)](https://github.com/PDOK/ogc-specifications/actions/workflows/lint.yml)

![GitHub license](https://img.shields.io/github/license/PDOK/ogc-specifications)
[![GitHub
release](https://img.shields.io/github/release/PDOK/ogc-specifications.svg)](https://github.com/PDOK/ogc-specifications/releases)
Expand Down
19 changes: 11 additions & 8 deletions pkg/utils/xml.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,35 @@ type XMLAttribute []xml.Attr

// StripDuplicateAttr removes the duplicate Attributes from a []Attribute
func StripDuplicateAttr(attr []xml.Attr) []xml.Attr {
attributeMap := make(map[xml.Name]string)
attributemap := make(map[xml.Name]string)
for _, a := range attr {
attributeMap[xml.Name{Space: a.Name.Space, Local: a.Name.Local}] = a.Value
attributemap[xml.Name{Space: a.Name.Space, Local: a.Name.Local}] = a.Value
}

var strippedAttr []xml.Attr
for k, v := range attributeMap {
for k, v := range attributemap {
strippedAttr = append(strippedAttr, xml.Attr{Name: k, Value: v})
}
return strippedAttr
}

// UnmarshalXML func for the XMLAttr struct
func (xmlattr *XMLAttribute) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
var newAttributes XMLAttribute
var newattributes XMLAttribute
for _, attr := range start.Attr {
newAttributes = append(newAttributes, xml.Attr{Name: attr.Name, Value: attr.Value})
switch attr.Name.Local {
default:
newattributes = append(newattributes, xml.Attr{Name: attr.Name, Value: attr.Value})
}
}
*xmlattr = newAttributes
*xmlattr = newattributes

for {
// if it got this far the XML is 'valid' and the xmlattr are set
// so we ignore the err
token, _ := d.Token()

if el, ok := token.(xml.EndElement); ok {
switch el := token.(type) {
case xml.EndElement:
if el == start.End() {
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/wcs201/capabilities.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package wcs201

// ParseXML func
func (c *Capabilities) ParseXML(_ []byte) error {
func (c *Capabilities) ParseXML(doc []byte) error {
return nil
}

// ParseYAML func
func (c *Capabilities) ParseYAML(_ []byte) error {
func (c *Capabilities) ParseYAML(doc []byte) error {
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/wcs201/getcapabilities_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (gc *GetCapabilitiesRequest) Type() string {
}

// Validate validates the GetCapabilities struct
func (gc *GetCapabilitiesRequest) Validate(_ Capabilities) []wsc200.Exception {
func (gc *GetCapabilitiesRequest) Validate(c Capabilities) []wsc200.Exception {
return nil
}

Expand Down
11 changes: 5 additions & 6 deletions pkg/wfs200/capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ package wfs200

import (
"encoding/xml"

"github.com/pdok/ogc-specifications/pkg/wsc110"
)

// ParseXML func
func (c *Capabilities) ParseXML(_ []byte) error {
func (c *Capabilities) ParseXML(doc []byte) error {
return nil
}

// ParseYAML func
func (c *Capabilities) ParseYAML(_ []byte) error {
func (c *Capabilities) ParseYAML(doc []byte) error {
return nil
}

Expand Down Expand Up @@ -165,7 +164,7 @@ type MetadataHref struct {
// FilterCapabilities struct for the WFS 2.0.0
type FilterCapabilities struct {
Conformance Conformance `xml:"fes:Conformance" yaml:"conformance"`
IDCapabilities IDCapabilities `xml:"fes:Id_Capabilities" yaml:"idCapabilities"`
IDCapabilities IdCapabilities `xml:"fes:Id_Capabilities" yaml:"idCapabilities"`
ScalarCapabilities ScalarCapabilities `xml:"fes:Scalar_Capabilities" yaml:"scalarCapabilities"`
SpatialCapabilities SpatialCapabilities `xml:"fes:Spatial_Capabilities" yaml:"spatialCapabilities"`
// NO TemporalCapabilities!!!
Expand All @@ -177,8 +176,8 @@ type Conformance struct {
Constraint []ValueConstraint `xml:"fes:Constraint" yaml:"constraint"`
}

// IDCapabilities struct for the WFS 2.0.0
type IDCapabilities struct {
// IdCapabilities struct for the WFS 2.0.0
type IdCapabilities struct {
ResourceIdentifier ResourceIdentifier `xml:"fes:ResourceIdentifier" yaml:"resourceIdentifier"`
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/wfs200/crs.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const (

// CRS struct with namespace/authority/registry and code
type CRS struct {
Namespace string // TODO maybe AuthorityType is a better name...?
Namespace string //TODO maybe AuthorityType is a better name...?
Code int
}

Expand Down
14 changes: 9 additions & 5 deletions pkg/wfs200/crs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ othercrs:
err := yaml.Unmarshal(test.yaml, &ftl)
if err != nil {
t.Errorf("test: %d, yaml.UnMarshal failed with '%s'\n", k, err)
} else if ftl.DefaultCRS.Code != test.expectedcrs.Code || ftl.DefaultCRS.Namespace != test.expectedcrs.Namespace {
t.Errorf("test: %d, expected: %v+,\n got: %v+", k, test.expectedcrs, ftl.DefaultCRS)
} else {
if ftl.DefaultCRS.Code != test.expectedcrs.Code || ftl.DefaultCRS.Namespace != test.expectedcrs.Namespace {
t.Errorf("test: %d, expected: %v+,\n got: %v+", k, test.expectedcrs, ftl.DefaultCRS)
}
}
}
}
Expand All @@ -68,11 +70,13 @@ func TestMarshalYAMLCrs(t *testing.T) {
}
for k, test := range tests {
yamlCRS, err := yaml.Marshal(test.CRS)

if err != nil {
t.Errorf("test: %d, yaml.Marshal failed with '%s'\n", k, err)
} else if stringCRS := string(yamlCRS); stringCRS != test.expectedYAML {
t.Errorf("test: %d, expected: %v+,\n got: %v+", k, test.expectedYAML, stringCRS)
} else {
stringCRS := string(yamlCRS)
if stringCRS != test.expectedYAML {
t.Errorf("test: %d, expected: %v+,\n got: %v+", k, test.expectedYAML, stringCRS)
}
}
}
}
2 changes: 1 addition & 1 deletion pkg/wfs200/describefeaturetype_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (d DescribeFeatureTypeRequest) Type() string {
}

// Validate returns GetCapabilities
func (d DescribeFeatureTypeRequest) Validate(_ wsc110.Capabilities) []wsc110.Exception {
func (d DescribeFeatureTypeRequest) Validate(c wsc110.Capabilities) []wsc110.Exception {
return nil
}

Expand Down
5 changes: 3 additions & 2 deletions pkg/wfs200/describefeaturetype_request_pv.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (
"github.com/pdok/ogc-specifications/pkg/wsc110"
)

//nolint:govet
type describeFeatureTypeRequestParameterValue struct {
service string `yaml:"service" json:"service"`
baseParameterValueRequest

typeName *string `yaml:"typeName" json:"typeName"` // [0..*]
outputFormat *string `yaml:"outputFormat" json:"outputFormat"` // default: "text/xml; subtype=gml/3.2"
}
Expand Down Expand Up @@ -45,12 +45,13 @@ func (dpv *describeFeatureTypeRequestParameterValue) parseQueryParameters(query
return nil
}

func (dpv *describeFeatureTypeRequestParameterValue) parseDescribeFeatureTypeRequest(dft DescribeFeatureTypeRequest) {
func (dpv *describeFeatureTypeRequestParameterValue) parseDescribeFeatureTypeRequest(dft DescribeFeatureTypeRequest) []wsc110.Exception {
dpv.request = describefeaturetype
dpv.version = dft.Version
dpv.service = dft.Service
dpv.typeName = dft.TypeNames
dpv.outputFormat = dft.OutputFormat
return nil
}

func (dpv describeFeatureTypeRequestParameterValue) toQueryParameters() url.Values {
Expand Down
2 changes: 0 additions & 2 deletions pkg/wfs200/describefeaturetype_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ func TestDescribeFeatureTypeType(t *testing.T) {
}
}

//nolint:nestif
func TestDescribeFeatureTypeParseXML(t *testing.T) {
var tests = []struct {
body []byte
Expand Down Expand Up @@ -101,7 +100,6 @@ func TestDescribeFeatureTypeParseXML(t *testing.T) {
}
}

//nolint:nestif
func TestDescribeFeatureTypeParseQueryParameters(t *testing.T) {
var tests = []struct {
query url.Values
Expand Down
1 change: 0 additions & 1 deletion pkg/wfs200/exception.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package wfs200

import (
"encoding/xml"

"github.com/pdok/ogc-specifications/pkg/wsc110"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/wfs200/exception_codes.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func LockHasExpired() wsc110.Exception {
// OperationParsingFailed exception
func OperationParsingFailed(value, locator string) wsc110.Exception {
return exception{
ExceptionText: "Failed to parse the operation, found: " + value,
ExceptionText: fmt.Sprintf("Failed to parse the operation, found: %s", value),
LocatorCode: locator,
ExceptionCode: "OperationParsingFailed"}
}
Expand Down
Loading
Loading