comparison pkg/wfs/rawfeaturecollection.go @ 1624:943823d03d50

WFS downloader: Started with mapping return features to Go structs.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 18 Dec 2018 18:36:02 +0100
parents
children 92da44ba610c
comparison
equal deleted inserted replaced
1623:20c98c2964f7 1624:943823d03d50
1 // This is Free Software under GNU Affero General Public License v >= 3.0
2 // without warranty, see README.md and license for details.
3 //
4 // SPDX-License-Identifier: AGPL-3.0-or-later
5 // License-Filename: LICENSES/AGPL-3.0.txt
6 //
7 // Copyright (C) 2018 by via donau
8 // – Österreichische Wasserstraßen-Gesellschaft mbH
9 // Software engineering by Intevation GmbH
10 //
11 // Author(s):
12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de>
13
14 package wfs
15
16 import (
17 "encoding/json"
18 "io"
19 )
20
21 type RawFeatureCollection struct {
22 CRS struct {
23 Properties struct {
24 Name string `json:"name"`
25 } `json:"properties"`
26 } `json:"crs"`
27 Features []*struct {
28 Geometry struct {
29 Coordinates *json.RawMessage `json:"coordinates"`
30 Type string `json:"type"`
31 } `json:"geometry"`
32 Properties *json.RawMessage `json:"properties"`
33 } `json:"features"`
34 }
35
36 func ParseRawFeatureCollection(r io.Reader) (*RawFeatureCollection, error) {
37 rfc := new(RawFeatureCollection)
38 if err := json.NewDecoder(r).Decode(rfc); err != nil {
39 return nil, err
40 }
41 return rfc, nil
42 }