Skip to content

Commit

Permalink
tr/echarging-ocpi fix value conversion error for coordinates string/f…
Browse files Browse the repository at this point in the history
…loat
  • Loading branch information
clezag committed Nov 5, 2024
1 parent e116bb7 commit 63b078c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 34 deletions.
62 changes: 32 additions & 30 deletions transformers/echarging-ocpi/src/dto.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

package main

import "time"
import (
"time"
)

type OCPILocationsOperator struct {
Name string `json:"name"`
Expand Down Expand Up @@ -32,35 +34,35 @@ type OCPIEvse struct {
}

type OCPILocations struct {
CountryCode string `json:"country_code"`
PartyID string `json:"party_id"`
ID string `json:"id"`
Publish *bool `json:"publish"`
Name string `json:"name"`
Address string `json:"address"`
City string `json:"city"`
PostalCode string `json:"postal_code"`
Country string `json:"country"`
CountryCode string
PartyID string
ID string
Publish *bool
Name string
Address string
City string
PostalCode string
Country string
Coordinates struct {
Latitude float64 `json:"latitude,string"`
Longitude float64 `json:"longitude,string"`
} `json:"coordinates"`
Evses []OCPIEvse `json:"evses"`
ParkingType string `json:"parking_type"`
Operator OCPILocationsOperator `json:"operator"`
Suboperator OCPILocationsOperator `json:"suboperator"`
Owner OCPILocationsOperator `json:"owner"`
Facilities []string `json:"facilities"`
TimeZone string `json:"time_zone"`
Latitude string
Longitude string
}
Evses []OCPIEvse
ParkingType string
Operator OCPILocationsOperator
Suboperator OCPILocationsOperator
Owner OCPILocationsOperator
Facilities []string
TimeZone string
OpeningTimes *struct {
Twentyfourseven bool `json:"twentyfourseven,omitempty"`
RegularHours []interface{} `json:"regular_hours,omitempty"`
ExceptionalOpenings []interface{} `json:"exceptional_openings,omitempty"`
ExceptionalClosings []interface{} `json:"exceptional_closings,omitempty"`
} `json:"opening_times,omitempty"`
LastUpdated time.Time `json:"last_updated"`
PublishAllowedTo []interface{} `json:"publish_allowed_to"`
RelatedLocations []interface{} `json:"related_locations"`
Images []interface{} `json:"images"`
Directions *[]interface{} `json:"directions,omitempty"`
Twentyfourseven bool
RegularHours []interface{}
ExceptionalOpenings []interface{}
ExceptionalClosings []interface{}
}
LastUpdated time.Time
PublishAllowedTo []interface{}
RelatedLocations []interface{}
Images []interface{}
Directions *[]interface{}
}
11 changes: 7 additions & 4 deletions transformers/echarging-ocpi/src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"log/slog"
"os"
"strconv"
"sync"

"github.com/kelseyhightower/envconfig"
Expand Down Expand Up @@ -144,12 +145,14 @@ func main() {
plugData := b.CreateDataMap()

for _, loc := range r.Rawdata {
lat, _ := strconv.ParseFloat(loc.Coordinates.Latitude, 64)
lon, _ := strconv.ParseFloat(loc.Coordinates.Longitude, 64)
station := bdplib.CreateStation(
loc.ID,
loc.Name,
stationTypeLocation,
loc.Coordinates.Latitude,
loc.Coordinates.Longitude,
lat,
lon,
b.Origin)

station.MetaData = map[string]any{
Expand All @@ -173,8 +176,8 @@ func main() {
evse.UID,
evse.EvseID,
stationTypePlug,
loc.Coordinates.Latitude,
loc.Coordinates.Longitude,
station.Latitude,
station.Longitude,
b.Origin)

plug.ParentStation = station.Id
Expand Down

0 comments on commit 63b078c

Please sign in to comment.