Skip to content

Commit

Permalink
new transformer wip parking onstreet bz (axians)
Browse files Browse the repository at this point in the history
  • Loading branch information
clezag committed Nov 21, 2024
1 parent 8e41fac commit 147b38a
Show file tree
Hide file tree
Showing 17 changed files with 329 additions and 0 deletions.
6 changes: 6 additions & 0 deletions LICENSES/LicenseRef-axians.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
These files were provided by

AXIANS Italia SPA
Via Gallarate, 205 (MI) 20151 Milan, Italy

under no explicit license
20 changes: 20 additions & 0 deletions transformers/parking-onstreet-bz/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# SPDX-FileCopyrightText: 2024 NOI Techpark <[email protected]>
#
# SPDX-License-Identifier: CC0-1.0

LOG_LEVEL="DEBUG"
MQ_LISTEN_URI="amqp://localhost:5672"
MQ_LISTEN_QUEUE="municipality-bolzano.parking-macello"
MQ_LISTEN_EXCHANGE="routed"
MQ_LISTEN_KEY="municipality-bolzano.parking-macello"
MQ_LISTEN_CONSUMER="tr-parking-os-sfhera-dev"
MONGO_URI="mongodb://user:password@localhost:27017/?directConnection=true"

BDP_BASE_URL=https://share.opendatahub.testingmachine.eu
BDP_PROVENANCE_VERSION=0.1.0
BDP_PROVENANCE_NAME=odh-a22-traffic-quality
BDP_ORIGIN=a22

ODH_TOKEN_URL=https://auth.opendatahub.testingmachine.eu/auth/realms/noi/protocol/openid-connect/token
ODH_CLIENT_ID=odh-a22-dataprocessor
ODH_CLIENT_SECRET=
5 changes: 5 additions & 0 deletions transformers/parking-onstreet-bz/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.env
/target
.vscode
__debug
tmp/
20 changes: 20 additions & 0 deletions transformers/parking-onstreet-bz/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# SPDX-FileCopyrightText: 2024 NOI Techpark <[email protected]>
#
# SPDX-License-Identifier: CC0-1.0

services:
app:
build:
dockerfile: infrastructure/docker/Dockerfile
context: .
target: dev
env_file:
- .env
volumes:
- ./src:/code
- pkg:/go/pkg/mod
working_dir: /code
# host mode so we can use the port forwards
network_mode: host
volumes:
pkg:
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2024 NOI Techpark <[email protected]>

SPDX-License-Identifier: CC0-1.0
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2019 AXIANS Italia

SPDX-License-Identifier: LicenseRef-axians
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: 2024 NOI Techpark <[email protected]>
#
# SPDX-License-Identifier: CC0-1.0

services:
app:
image: ${DOCKER_IMAGE}:${DOCKER_TAG}
build:
context: ../
dockerfile: infrastructure/docker/Dockerfile
target: build
27 changes: 27 additions & 0 deletions transformers/parking-onstreet-bz/infrastructure/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# SPDX-FileCopyrightText: 2024 NOI Techpark <[email protected]>
#
# SPDX-License-Identifier: CC0-1.0

FROM golang:1.23-bookworm as base

FROM base as build-env
WORKDIR /app
COPY src/. .
RUN go mod download
RUN CGO_ENABLED=0 GOOS=linux go build -o main

# BUILD published image
FROM alpine:latest as build
WORKDIR /app
COPY --from=build-env /app/main .
ENTRYPOINT [ "./main"]

# LOCAL DEVELOPMENT
FROM base as dev
WORKDIR /code
CMD ["go", "run", "main.go"]

# TESTS
FROM base as test
WORKDIR /code
CMD ["go", "test", "."]
31 changes: 31 additions & 0 deletions transformers/parking-onstreet-bz/infrastructure/helm/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
env:
# ODH Core Writer Connection
BDP_BASE_URL: https://share.opendatahub.testingmachine.eu
BDP_PROVENANCE_NAME:
BDP_PROVENANCE_VERSION:
BDP_ORIGIN: AXIANS

LOG_LEVEL: INFO

MQ_EXCHANGE: routed
MQ_QUEUE: parking-onstreet.bz-axians
MQ_KEY: parking-onstreet.bz-axians
MQ_CONSUMER: tr-parking-onstreet-bz

envSecretRef:
- name: MQ_URI
secret: rabbitmq-svcbind
key: uri
- name: MONGO_URI
secret: mongodb-collector-svcbind
key: uri

- name: ODH_TOKEN_URL
secret: oauth-collector
key: tokenUri
- name: ODH_CLIENT_ID
secret: oauth-collector
key: clientId
- name: ODH_CLIENT_SECRET
secret: oauth-collector
key: clientSecret
26 changes: 26 additions & 0 deletions transformers/parking-onstreet-bz/src/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module opendatahub.com/tr-parking-onstreet-bz

go 1.23

require (
github.com/gocarina/gocsv v0.0.0-20240520201108-78e41c74b4b1
github.com/kelseyhightower/envconfig v1.4.0
github.com/noi-techpark/go-opendatahub-ingest v0.0.0-20241119065535-d68a9695ad44
gotest.tools/v3 v3.5.1
)

require (
github.com/golang/snappy v0.0.4 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/montanaflynn/stats v0.7.1 // indirect
github.com/rabbitmq/amqp091-go v1.10.0 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
go.mongodb.org/mongo-driver v1.17.1 // indirect
golang.org/x/crypto v0.29.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/text v0.20.0 // indirect
)
62 changes: 62 additions & 0 deletions transformers/parking-onstreet-bz/src/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gocarina/gocsv v0.0.0-20240520201108-78e41c74b4b1 h1:FWNFq4fM1wPfcK40yHE5UO3RUdSNPaBC+j3PokzA6OQ=
github.com/gocarina/gocsv v0.0.0-20240520201108-78e41c74b4b1/go.mod h1:5YoVOkjYAQumqlV356Hj3xeYh4BdZuLE0/nRkf2NKkI=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8=
github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg=
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE=
github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
github.com/noi-techpark/go-opendatahub-ingest v0.0.0-20241119065535-d68a9695ad44 h1:rr/a0Lha81kj2sase8SXQrFrWHeFduUehgMAjiZwRC0=
github.com/noi-techpark/go-opendatahub-ingest v0.0.0-20241119065535-d68a9695ad44/go.mod h1:OR71Qot9WXWSNwLjNNuhhdIts1KbDfDzbwv2F/Q6KOk=
github.com/rabbitmq/amqp091-go v1.10.0 h1:STpn5XsHlHGcecLmMFCtg7mqq0RnD+zFr4uzukfVhBw=
github.com/rabbitmq/amqp091-go v1.10.0/go.mod h1:Hy4jKW5kQART1u+JkDTF9YYOQUHXqMuhrgxOEeS7G4o=
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY=
github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4=
github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8=
github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM=
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM=
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.mongodb.org/mongo-driver v1.17.1 h1:Wic5cJIwJgSpBhe3lx3+/RybR5PiYRMpVFgO7cOHyIM=
go.mongodb.org/mongo-driver v1.17.1/go.mod h1:wwWm/+BuOddhcq3n68LKRmgk2wXzmF6s0SFOa0GINL4=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU=
gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=
56 changes: 56 additions & 0 deletions transformers/parking-onstreet-bz/src/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// SPDX-FileCopyrightText: 2024 NOI Techpark <[email protected]>
//
// SPDX-License-Identifier: CC0-1.0

package main

import (
"os"

"github.com/gocarina/gocsv"
"github.com/kelseyhightower/envconfig"
"github.com/noi-techpark/go-opendatahub-ingest/dto"
"github.com/noi-techpark/go-opendatahub-ingest/ms"
"github.com/noi-techpark/go-opendatahub-ingest/tr"
)

var cfg struct {
tr.Env
}

type MqttRaw struct {
MsgId uint16
Topic string
Payload string
}

func main() {
envconfig.MustProcess("", &cfg)
ms.InitLog(cfg.LOG_LEVEL)

// b := bdplib.FromEnv()
tr.ListenFromEnv(cfg.Env, func(r *dto.Raw[MqttRaw]) error {

return nil
})
}

type Station struct {
DevEUI string
Id string
Group string
Longitude float64
Latitude float64
Description string
}

func readStations() []Station {
f, err := os.Open("stations.csv")
ms.FailOnError(err, "failed reading stations csv")
defer f.Close()

stations := []Station{}

ms.FailOnError(gocsv.Unmarshal(f, &stations), "failed unmarshalling csv")
return stations
}
24 changes: 24 additions & 0 deletions transformers/parking-onstreet-bz/src/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-FileCopyrightText: 2024 NOI Techpark <[email protected]>
//
// SPDX-License-Identifier: CC0-1.0

package main

import (
"testing"

"gotest.tools/v3/assert"
)

func Test_readStations(t *testing.T) {
first := Station{
"001bc506701005c2",
"C-S1",
"area viale Druso",
11.33998888888889,
46.494825,
"Piazza Adriano 1",
}
ss := readStations()
assert.Equal(t, ss[0], first)
}
32 changes: 32 additions & 0 deletions transformers/parking-onstreet-bz/src/stations.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
DevEUI,Id,Group,Longitude,Latitude,Description
001bc506701005c2,C-S1,area viale Druso,11.33998888888889,46.494825,Piazza Adriano 1
001bc50670100539,C-S2,area viale Druso,11.340041666666668,46.4948111,Piazza Adriano 2
001bc50670100594,C-S3,area viale Druso,11.342111111111112,46.4946972,incrocio viale Druso - via Vicenza 1
001bc506701005e0,C-S4,area viale Druso,11.342219444444446,46.4946861,incrocio viale Druso - via Vicenza 2
001bc506701005cd,C-S6,area viale Druso,11.343347222222222,46.4942917,incrocio via Firenze - viale Druso
001bc506701005fb,C-S7,area viale Druso,11.34365,46.4945944,incrocio viale Druso - via Firenze
001bc506701005ae,C-S8,area viale Druso,11.344633333333334,46.4946028,viale Druso caserma carabinieri
001bc506701005d5,C-S9,area viale Druso,11.345608333333335,46.4950611,incrocio viale Venezia - viale Druso
001bc50670100544,C-S10,area viale Druso,11.347066666666667,46.4950028,piazzetta Mazzoni 1
001bc50670100533,C-S11,area viale Druso,11.347075,46.4949806,piazzetta Mazzoni 2
001bc50670100603,C-S5,area viale Druso,11.341866666666668,46.4943528,"incrocio via Vicenza - viale Druso"
001bc50670100557,C-S12,area viale Druso,11.347069444444445,46.495025,piazzetta Mazzoni 3
001bc5067010064d,C-S12,area viale Druso,11.347055555555556,46.4950556,piazzetta Mazzoni 4
001bc50670100556,C-S5,area viale Druso,11.34186388888889,46.4943056,"incrocio via Vicenza - viale Druso 2"
001bc50670100519,815,"Via Holfer, 18",11.358288888888888,46.5010222,"Via Holfer, 18"
001bc506701005ce,816,"Via Holfer, 18",11.358347222222221,46.5010056,"Via Holfer, 18"
001bc50670100518,817,"Leonardo da vinci, 17",11.34955277777778,46.4989722,"Leonardo da vinci, 17"
001bc50670100507,818,"Leonardo da vinci, 17",11.349494444444446,46.4989778,"Leonardo da vinci, 17"
001bc50670100541,819,Via A. Rosmini 22-26,11.348030555555557,46.4982917,Via A. Rosmini 22-26
001bc5067011297c,901,Viale Druso 237,11.328697222222223,46.4950333,Viale Druso 237
001bc50670112976,902,Viale Druso 237,11.328702777777778,46.495,Viale Druso 237
001bc50670112b22,903,Viale Druso 237,11.328691666666666,46.4949694,Viale Druso 237
001bc50670112901,904,Via Amalfi,11.332463888888888,46.4953389,Via Amalfi angolo Via Druso
001bc50670112a6b,905,Via Amalfi,11.332472222222222,46.4952833,Via Amalfi angolo Via Druso
001bc50670112a10,906,Viale Druso 91,11.33575,46.495225,Viale Druso 91
001bc5067011298b,907,Viale Druso 91,11.335816666666668,46.495225,Viale Druso 92
001bc506701128e3,908,Via A. Rosmini 22-26,11.348041666666667,46.4982306,Via A. Rosmini 22-26
001bc50670112ad2,909,Via Michael Gaismar,11.335780555555557,46.4957972,Via Michael Gaismar
001bc50670112b84,910,Via Michael Gaismar,11.335780555555557,46.4957389,Via Michael Gaismar
001bc506701128af,911,Via Cavour 1,11.357391666666667,46.5019972,Via Cavour 1
001bc50670112b3c,912,Via Cavour 1,11.357322222222221,46.5020222,Via Cavour 1
3 changes: 3 additions & 0 deletions transformers/parking-onstreet-bz/src/stations.csv.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2024 NOI Techpark <[email protected]>

SPDX-License-Identifier: CC0-1.0

0 comments on commit 147b38a

Please sign in to comment.