Compare commits
2 commits
e2dd0451d2
...
b11b8965bd
Author | SHA1 | Date | |
---|---|---|---|
b11b8965bd | |||
ae15cff014 |
25 changed files with 865 additions and 180 deletions
22
README.md
Normal file
22
README.md
Normal file
|
@ -0,0 +1,22 @@
|
|||
|
||||
|
||||
## Related
|
||||
|
||||
- https://github.com/asplendidday/ACbus
|
||||
- https://github.com/feuerrot/aseag-python
|
||||
- https://github.com/RobertKrajewski/PyASEAG
|
||||
- https://github.com/RobinMeis/pyASEAG
|
||||
- https://github.com/lebu/ASEAG-Busabfahrten
|
||||
- https://git.rwth-aachen.de/markus.witt/aseag-cli
|
||||
- https://github.com/stklcode/juraclient
|
||||
- https://github.com/acmurmeltier69/Alexa-Busauskunft
|
||||
|
||||
|
||||
- http://content.tfl.gov.uk/tfl-live-bus-river-bus-arrivals-api-documentation.pdf
|
||||
|
||||
|
||||
# API Endpoints
|
||||
|
||||
http://countdown.api.tfl.gov.uk
|
||||
http://ivu.aseag.de/interfaces/
|
||||
http://opendata.avv.de/current_GTFS/AVV_GTFS_mit_SPNV.zip
|
21
api/Dockerfile
Normal file
21
api/Dockerfile
Normal file
|
@ -0,0 +1,21 @@
|
|||
FROM golang:1.14
|
||||
|
||||
# Set the Current Working Directory inside the container
|
||||
WORKDIR $GOPATH/src/app
|
||||
|
||||
# Copy everything from the current directory to the PWD(Present Working Directory) inside the container
|
||||
COPY . .
|
||||
|
||||
# Download all the dependencies
|
||||
RUN go get -d -v ./...
|
||||
|
||||
# Install the package
|
||||
RUN go install -v ./...
|
||||
|
||||
# This container exposes port 8080 to the outside world
|
||||
EXPOSE 8080
|
||||
|
||||
ENV GIN_MODE=release
|
||||
|
||||
# Run the executable
|
||||
CMD ["ura"]
|
9
api/Makefile
Normal file
9
api/Makefile
Normal file
|
@ -0,0 +1,9 @@
|
|||
IMAGE = stv0g/connectiq-ura
|
||||
|
||||
all: push
|
||||
|
||||
image:
|
||||
docker build . -t $(IMAGE)
|
||||
|
||||
push: image
|
||||
docker push $(IMAGE)
|
13
api/go.mod
Normal file
13
api/go.mod
Normal file
|
@ -0,0 +1,13 @@
|
|||
module ura
|
||||
|
||||
go 1.15
|
||||
|
||||
require (
|
||||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 // indirect
|
||||
github.com/gin-gonic/gin v1.6.3 // indirect
|
||||
github.com/kellydunn/golang-geo v0.7.0 // indirect
|
||||
github.com/kylelemons/go-gypsy v1.0.0 // indirect
|
||||
github.com/lib/pq v1.9.0 // indirect
|
||||
github.com/umahmood/haversine v0.0.0-20151105152445-808ab04add26 // indirect
|
||||
github.com/ziutek/mymysql v1.5.4 // indirect
|
||||
)
|
51
api/go.sum
Normal file
51
api/go.sum
Normal file
|
@ -0,0 +1,51 @@
|
|||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y=
|
||||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
|
||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14=
|
||||
github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M=
|
||||
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=
|
||||
github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8=
|
||||
github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=
|
||||
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
|
||||
github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY=
|
||||
github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI=
|
||||
github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I=
|
||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/kellydunn/golang-geo v0.7.0 h1:A5j0/BvNgGwY6Yb6inXQxzYwlPHc6WVZR+MrarZYNNg=
|
||||
github.com/kellydunn/golang-geo v0.7.0/go.mod h1:YYlQPJ+DPEzrHx8kT3oPHC/NjyvCCXE+IuKGKdrjrcU=
|
||||
github.com/kylelemons/go-gypsy v1.0.0 h1:7/wQ7A3UL1bnqRMnZ6T8cwCOArfZCxFmb1iTxaOOo1s=
|
||||
github.com/kylelemons/go-gypsy v1.0.0/go.mod h1:chkXM0zjdpXOiqkCW1XcCHDfjfk14PH2KKkQWxfJUcU=
|
||||
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
|
||||
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
|
||||
github.com/lib/pq v1.9.0 h1:L8nSXQQzAYByakOFMTwpjRoHsMJklur4Gi59b6VivR8=
|
||||
github.com/lib/pq v1.9.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
|
||||
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
||||
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
|
||||
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
|
||||
github.com/umahmood/haversine v0.0.0-20151105152445-808ab04add26 h1:UFHFmFfixpmfRBcxuu+LA9l8MdURWVdVNUHxO5n1d2w=
|
||||
github.com/umahmood/haversine v0.0.0-20151105152445-808ab04add26/go.mod h1:IGhd0qMDsUa9acVjsbsT7bu3ktadtGOHI79+idTew/M=
|
||||
github.com/ziutek/mymysql v1.5.4 h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs=
|
||||
github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0=
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg=
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
263
api/main.go
Normal file
263
api/main.go
Normal file
|
@ -0,0 +1,263 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
geo "github.com/kellydunn/golang-geo"
|
||||
)
|
||||
|
||||
var returnList = []string{
|
||||
"StopPointName",
|
||||
"StopID",
|
||||
"StopPointIndicator",
|
||||
"StopPointState",
|
||||
"Latitude",
|
||||
"Longitude",
|
||||
}
|
||||
|
||||
var apiBase string = "http://ivu.aseag.de/interfaces/ura"
|
||||
|
||||
type StopPoint struct {
|
||||
Name string `json:"name"`
|
||||
ID int `json:"id"`
|
||||
Indicator string `json:"indicator"`
|
||||
State bool `json:"state"`
|
||||
Coordinates *geo.Point `json:"coord"`
|
||||
Distance float64 `json:"dist"`
|
||||
Bearing float64 `json:"bearing"`
|
||||
BearingString string `json:"bearing_str"`
|
||||
}
|
||||
|
||||
func BearingToCardinal(b float64) string {
|
||||
var card = []string{"N", "NE", "E", "SE", "S", "SW", "W", "NW"}
|
||||
|
||||
b += 22.5
|
||||
if b < 0 {
|
||||
b += 360
|
||||
}
|
||||
b /= 45
|
||||
|
||||
return card[int(b)]
|
||||
}
|
||||
|
||||
func (sp *StopPoint) UnmarshalJSON(buf []byte) error {
|
||||
// Ex: [0,"Bahnhof Rothe Erde","100302","H.1",0,50.7703152,6.1174127]
|
||||
|
||||
var rType int
|
||||
var id string
|
||||
var state int
|
||||
var err error
|
||||
var lat, lng float64
|
||||
|
||||
tmp := []interface{}{&rType, &sp.Name, &id, &sp.Indicator, &state, &lat, &lng}
|
||||
wantLen := len(tmp)
|
||||
|
||||
if err := json.Unmarshal(buf, &tmp); err != nil {
|
||||
return fmt.Errorf("Failed to parse: %s", buf)
|
||||
}
|
||||
|
||||
sp.ID, err = strconv.Atoi(id)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
sp.State = state != 0
|
||||
sp.Coordinates = geo.NewPoint(lat, lng)
|
||||
|
||||
if rType != 0 {
|
||||
return fmt.Errorf("Invalid response type: %d != 0", rType)
|
||||
}
|
||||
|
||||
if g, e := len(tmp), wantLen; g != e {
|
||||
return fmt.Errorf("wrong number of fields in Notification: %d != %d", g, e)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type Prediction struct {
|
||||
LineName string `json:"line"`
|
||||
DestinationName string `json:"dest"`
|
||||
EstimatedTime time.Time `json:"estimated"`
|
||||
ExpireTime time.Time `json:"expire"`
|
||||
Delta int `json:"delta"`
|
||||
DeltaString string `json:"delta_str"`
|
||||
}
|
||||
|
||||
func (p *Prediction) UnmarshalJSON(buf []byte) error {
|
||||
// Ex: [1,"33","Vaals Heuvel",1610732635000,1610732880000]
|
||||
|
||||
var rType int
|
||||
var estimated, expired json.Number
|
||||
|
||||
tmp := []interface{}{&rType, &p.LineName, &p.DestinationName, &estimated, &expired}
|
||||
wantLen := len(tmp)
|
||||
|
||||
if err := json.Unmarshal(buf, &tmp); err != nil {
|
||||
return fmt.Errorf("Failed to parse: %s", buf)
|
||||
}
|
||||
|
||||
expiredInt, _ := expired.Int64()
|
||||
estimatedInt, _ := estimated.Int64()
|
||||
|
||||
p.ExpireTime = time.Unix(expiredInt/1000, 0)
|
||||
p.EstimatedTime = time.Unix(estimatedInt/1000, 0)
|
||||
|
||||
if rType != 1 {
|
||||
return fmt.Errorf("Invalid response type: %d != 1", rType)
|
||||
}
|
||||
|
||||
if g, e := len(tmp), wantLen; g != e {
|
||||
return fmt.Errorf("wrong number of fields in Notification: %d != %d", g, e)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
r := gin.Default()
|
||||
|
||||
r.GET("/stops", func(c *gin.Context) {
|
||||
latStr := c.Query("latitude")
|
||||
lngStr := c.Query("longitude")
|
||||
distStr := c.Query("distance")
|
||||
limitStr := c.Query("limit")
|
||||
|
||||
var lat, lng float64
|
||||
var dist float64
|
||||
var err error
|
||||
var limit int
|
||||
|
||||
lat, err = strconv.ParseFloat(latStr, 64)
|
||||
if err != nil {
|
||||
|
||||
}
|
||||
|
||||
lng, err = strconv.ParseFloat(lngStr, 64)
|
||||
if err != nil {
|
||||
|
||||
}
|
||||
|
||||
point := geo.NewPoint(lat, lng)
|
||||
|
||||
dist, err = strconv.ParseFloat(distStr, 64)
|
||||
if err != nil {
|
||||
|
||||
}
|
||||
|
||||
limit, err = strconv.Atoi(limitStr)
|
||||
if err != nil {
|
||||
|
||||
}
|
||||
|
||||
res, _ := http.Get(apiBase + "/instant_V1" +
|
||||
fmt.Sprintf("?Circle=%f,%f,%f", point.Lat(), point.Lng(), dist) +
|
||||
"&StopPointState=0" +
|
||||
"&ReturnList=" + strings.Join(returnList, ","))
|
||||
|
||||
var sps = []StopPoint{}
|
||||
|
||||
scanner := bufio.NewScanner(res.Body)
|
||||
|
||||
if !scanner.Scan() {
|
||||
|
||||
}
|
||||
|
||||
_ = scanner.Bytes()
|
||||
|
||||
for scanner.Scan() {
|
||||
line := scanner.Bytes()
|
||||
|
||||
var sp StopPoint
|
||||
err = json.Unmarshal(line, &sp)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
sp.Distance = point.GreatCircleDistance(sp.Coordinates) * 1000
|
||||
sp.Bearing = point.BearingTo(sp.Coordinates)
|
||||
sp.BearingString = BearingToCardinal(sp.Bearing)
|
||||
|
||||
sps = append(sps, sp)
|
||||
}
|
||||
|
||||
sort.Slice(sps, func(a, b int) bool {
|
||||
return sps[a].Distance < sps[b].Distance
|
||||
})
|
||||
|
||||
if limit > len(sps) || limit == 0 {
|
||||
limit = len(sps)
|
||||
}
|
||||
|
||||
c.JSON(200, sps[:limit])
|
||||
})
|
||||
|
||||
r.GET("/departures", func(c *gin.Context) {
|
||||
var err error
|
||||
var limit int
|
||||
|
||||
idStr := c.Query("id")
|
||||
limitStr := c.Query("limit")
|
||||
|
||||
id, err := strconv.Atoi(idStr)
|
||||
if err != nil {
|
||||
|
||||
}
|
||||
|
||||
limit, err = strconv.Atoi(limitStr)
|
||||
if err != nil {
|
||||
|
||||
}
|
||||
|
||||
res, _ := http.Get(apiBase + "/instant_V1" +
|
||||
fmt.Sprintf("?StopID=%d", id) +
|
||||
"&ReturnList=LineName,DestinationName,EstimatedTime,ExpireTime")
|
||||
|
||||
var ps = []Prediction{}
|
||||
|
||||
scanner := bufio.NewScanner(res.Body)
|
||||
|
||||
if !scanner.Scan() {
|
||||
|
||||
}
|
||||
|
||||
_ = scanner.Bytes()
|
||||
|
||||
for scanner.Scan() {
|
||||
line := scanner.Bytes()
|
||||
|
||||
var p Prediction
|
||||
err = json.Unmarshal(line, &p)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
delta := time.Until(p.EstimatedTime)
|
||||
|
||||
p.Delta = int(delta / 1e9) // to secs
|
||||
p.DeltaString = delta.Truncate(time.Second).String()
|
||||
|
||||
ps = append(ps, p)
|
||||
}
|
||||
|
||||
sort.Slice(ps, func(a, b int) bool {
|
||||
return ps[a].EstimatedTime.Before(ps[b].EstimatedTime)
|
||||
})
|
||||
|
||||
if limit > len(ps) || limit == 0 {
|
||||
limit = len(ps)
|
||||
}
|
||||
|
||||
c.JSON(200, ps[:limit])
|
||||
})
|
||||
|
||||
r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
|
||||
}
|
2
connectiq/.settings/IQ_IDE.prefs
Normal file
2
connectiq/.settings/IQ_IDE.prefs
Normal file
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
project_manifest=manifest.xml
|
1
connectiq/bin/ura-busstops-settings.json
Normal file
1
connectiq/bin/ura-busstops-settings.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"settings":[{"key":"api_url_index","valueType":"number","defaultValue":1,"configTitle":"ApiUrl","configPrompt":"ApiUrlPrompt","configHelpUrl":null,"configError":null,"configType":"list","configReadonly":false,"configRequired":false,"configOptions":[{"display":"ApiUrlLocalhost","value":0},{"display":"ApiUrlNulll","value":1}],"configMin":null,"configMax":null,"configMaxLength":null}],"languages":{"valyrian":{"ApiUrl":"API URL","ApiUrlNulll":"https://connectiq-ura.0l.de","ApiUrlLocalhost":"http://localhost:8080","AppName":"Bus Stops","ApiUrlPrompt":"API URL:"}}}
|
|
@ -1,16 +1,16 @@
|
|||
<!-- This is a generated file. It is highly recommended that you DO NOT edit this file. --><iq:manifest xmlns:iq="http://www.garmin.com/xml/connectiq" version="1">
|
||||
<iq:application entry="BusStopApp" id="1CFE9C7CA0D44751A1CE1DF93F59268A" launcherIcon="@Drawables.LauncherIcon" name="@Strings.AppName" type="widget">
|
||||
|
||||
<iq:application entry="BusStopApp" id="1c850645cb504a699e92fc1eeb6afe0e" launcherIcon="@Drawables.LauncherIcon" minSdkVersion="3.2.0" name="@Strings.AppName" type="widget">
|
||||
<iq:products>
|
||||
<iq:product id="square_watch"/>
|
||||
<iq:product id="tall_watch"/>
|
||||
<iq:product id="round_watch"/>
|
||||
<iq:product id="fr745"/>
|
||||
</iq:products>
|
||||
|
||||
<iq:permissions>
|
||||
<iq:uses-permission id="Communications"/>
|
||||
<iq:uses-permission id="Positioning"/>
|
||||
<iq:uses-permission id="Sensor"/>
|
||||
</iq:permissions>
|
||||
|
||||
<iq:languages/>
|
||||
|
||||
<iq:languages>
|
||||
<iq:language>deu</iq:language>
|
||||
<iq:language>eng</iq:language>
|
||||
</iq:languages>
|
||||
</iq:application>
|
||||
</iq:manifest>
|
||||
|
|
2
connectiq/monkey.jungle
Normal file
2
connectiq/monkey.jungle
Normal file
|
@ -0,0 +1,2 @@
|
|||
project.manifest = manifest.xml
|
||||
|
48
connectiq/resources/drawables/ASEAG.svg
Normal file
48
connectiq/resources/drawables/ASEAG.svg
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Creator: CorelDRAW -->
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="3583px" height="395px" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd"
|
||||
viewBox="0 0 3673.14 404.499"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<defs>
|
||||
<style type="text/css">
|
||||
<![CDATA[
|
||||
.fil0 {fill:#1F1A17;fill-rule:nonzero}
|
||||
.fil1 {fill:#EF4023;fill-rule:nonzero}
|
||||
]]>
|
||||
</style>
|
||||
</defs>
|
||||
<symbol id="Fm19-61-0" viewBox="1791.5 38.9138 4.27169 4.27169">
|
||||
<path class="fil0" d="M1793.31 42.0631l-0.0012108 0c-0.0181619,0.223997 -0.0496426,0.314807 -0.0726478,0.314807 -0.0665938,0 -0.116236,-0.389876 -0.116236,-1.10546 0,-0.808812 0.0581182,-1.51107 0.150139,-1.51107 0.0641722,0 0.115026,0.265164 0.113815,0.885092l-0.0605398 0c0,-0.279694 -0.0193727,-0.423779 -0.0520642,-0.423779 -0.0629614,0 -0.0908097,0.570285 -0.0908097,1.04976 0,0.342655 0.0193727,0.644144 0.0605398,0.644144 0.0423779,0 0.065383,-0.220365 0.0750694,-0.538804l-0.0629614 0 0.00968637 -0.409249 0.116236 0 -0.0314807 1.34883 -0.0375347 0 0 -0.254267z"/>
|
||||
<polygon class="fil0" points="1792.7,39.8231 1792.91,39.8231 1792.9,40.2844 1792.75,40.2844 1792.74,40.7554 1792.88,40.7554 1792.87,41.1804 1792.73,41.1804 1792.72,41.856 1792.86,41.856 1792.85,42.3161 1792.64,42.3161 "/>
|
||||
<path class="fil0" d="M1792.27 41.3547l0.0484318 -0.872984 0.00726478 0.872984 -0.0556966 0zm0.0956529 -1.53045l-0.0641722 0 -0.154982 2.49303 0.0690154 0 0.0302699 -0.523064 0.0847557 -0.0012108 0.00484318 0.524275 0.059329 0 -0.0290591 -2.49303z"/>
|
||||
<path class="fil0" d="M1792.99 41.3547l0.0484318 -0.872984 0.00726478 0.872984 -0.0556966 0zm0.0956529 -1.53045l-0.0641722 0 -0.154982 2.49303 0.0690154 0 0.0302699 -0.523064 0.0847557 -0.0012108 0.00484318 0.524275 0.059329 0 -0.0290591 -2.49303z"/>
|
||||
<path class="fil1" d="M1793.54 42.0231l0.0254267 0c0.0859665,0 0.0920205,-1.0098 0.0920205,-1.14905 0,-0.293013 -0.0133188,-0.703473 -0.0556966,-0.703473l-0.0290591 0 -0.0326915 1.85252zm0.0665938 -2.14553c0.0835449,0 0.0944421,0.651408 0.0944421,0.968637 0,0.0484318 -0.00363239,1.4687 -0.140452,1.4687l-0.0678046 0 0.0435887 -2.43733 0.0702262 0z"/>
|
||||
<path class="fil1" d="M1793.81 40.9576c0.0012108,-0.111393 -0.00484318,-0.161036 -0.0145296,-0.161036 -0.0181619,0 -0.0363239,0.237316 -0.0460103,0.556966 0.0314807,-0.0266375 0.059329,-0.173144 0.0605398,-0.39593zm0.0157403 1.1551c-0.0254267,0.209468 -0.0520642,0.244581 -0.0702262,0.244581 -0.0302699,0 -0.0508534,-0.265164 -0.0508534,-0.682889 0,-0.487951 0.0363239,-1.14178 0.100496,-1.14178 0.0181619,0 0.0411671,0.111393 0.0411671,0.362028 0,0.452838 -0.0641722,0.688943 -0.0992853,0.703473 -0.00242159,0.139242 -0.0012108,0.441941 0.0266375,0.449205 0.0108972,0.00363239 0.0266375,-0.0460103 0.0411671,-0.163457l0.0108972 0.22884z"/>
|
||||
<path class="fil1" d="M1793.92 40.8741l0.0012108 0.00605398 0.00968637 -0.135609c0.00605398,-0.0726478 0.0169511,-0.211889 0.0290591,-0.211889 0.00847557,0 0.0169511,0.0556966 0.0217943,0.124712l-0.0205835 0.328126c-0.00363239,-0.0145296 -0.00726478,-0.0351131 -0.0145296,-0.0351131 -0.0145296,0 -0.0290591,0.128344 -0.0363239,0.504902l-0.0145296 0.859665 -0.0387455 0 0.0302699 -1.74112 0.0387455 0 -0.00605398 0.300277z"/>
|
||||
<path class="fil1" d="M1794.14 40.8111c-0.0169511,0 -0.0496426,0.250635 -0.0496426,0.863298 0,0.233684 0.00968637,0.378979 0.0254267,0.378979 0.0181619,0 0.0484318,-0.211889 0.0556966,-1.0994 -0.012108,-0.118658 -0.0157403,-0.142874 -0.0314807,-0.142874zm0.0496426 1.34762c-0.0145296,0.772488 -0.0569074,1.02676 -0.100496,1.02676 -0.0217943,0 -0.0435887,-0.059329 -0.059329,-0.163457l0.0133188 -0.285748c0.012108,0.104128 0.0278483,0.150139 0.0484318,0.150139 0.0254267,0 0.0496426,-0.188884 0.0569074,-0.592079l0.00484318 -0.237316 0 -0.00605398 -0.00847557 0.0968637c-0.00484318,0.0629614 -0.0242159,0.209468 -0.0496426,0.209468 -0.0290591,0 -0.047221,-0.272429 -0.047221,-0.647776 0,-0.556966 0.0399563,-1.17689 0.0908097,-1.17689 0.0133188,0 0.0290591,0.0556966 0.0363239,0.159825l0.00363239 -0.118658 0.0387455 0 -0.0278483 1.58493z"/>
|
||||
<path class="fil1" d="M1794.33 41.9674l-0.0012108 -0.00726478c-0.0217943,0.316018 -0.0411671,0.397141 -0.0617506,0.397141 -0.0145296,0 -0.0339023,-0.111393 -0.0339023,-0.400774 0,-0.100496 0.0012108,-0.226419 0.00363239,-0.38019l0.0193727 -1.00254 0.0387455 0 -0.0181619 1.00012c-0.00242159,0.100496 -0.00363239,0.176776 -0.00363239,0.239738 0,0.187673 0.0108972,0.24337 0.0157403,0.24337 0.0181619,0 0.0447995,-0.406827 0.053275,-0.900832l0.00968637 -0.582393 0.0387455 0 -0.0302699 1.74112 -0.0387455 0 0.00847557 -0.347498z"/>
|
||||
<path class="fil1" d="M1794.49 42.2459c-0.012108,0.0726478 -0.0278483,0.111393 -0.0399563,0.111393 -0.0290591,0 -0.0447995,-0.157403 -0.0351131,-0.62356l0.0169511 -0.922627 -0.0205835 0 0.00484318 -0.237316 0.0205835 0 0.00726478 -0.417725 0.0399563 -0.104128 -0.00847557 0.521853 0.0387455 0 -0.00484318 0.237316 -0.0387455 0 -0.0169511 0.86693c-0.00605398,0.358396 0.00605398,0.397141 0.0145296,0.397141 0.00847557,0 0.0133188,-0.0278483 0.0193727,-0.059329l0.00242159 0.230051z"/>
|
||||
<path class="fil1" d="M1794.61 40.9576c0,-0.111393 -0.00484318,-0.161036 -0.0157403,-0.161036 -0.0169511,0 -0.0363239,0.237316 -0.0447995,0.556966 0.0302699,-0.0266375 0.059329,-0.173144 0.0605398,-0.39593zm0.0157403 1.1551c-0.0266375,0.209468 -0.053275,0.244581 -0.071437,0.244581 -0.0302699,0 -0.0496426,-0.265164 -0.0496426,-0.682889 0,-0.487951 0.0363239,-1.14178 0.100496,-1.14178 0.0181619,0 0.0399563,0.111393 0.0399563,0.362028 0,0.452838 -0.0641722,0.688943 -0.0992853,0.703473 -0.00242159,0.139242 -0.0012108,0.441941 0.0278483,0.449205 0.00968637,0.00363239 0.0254267,-0.0460103 0.0411671,-0.163457l0.0108972 0.22884z"/>
|
||||
<polygon class="fil1" points="1794.87,40.1875 1794.8,40.1875 1794.79,40.8765 1794.86,40.8765 1794.85,41.1864 1794.78,41.1864 1794.77,42.0049 1794.85,42.0049 1794.85,42.3149 1794.72,42.3149 1794.77,39.8776 1794.88,39.8776 "/>
|
||||
<path class="fil1" d="M1794.91 40.0519c0.00242159,-0.131977 0.0145296,-0.267586 0.0278483,-0.267586 0.0133188,0 0.0217943,0.131977 0.0193727,0.267586 -0.00242159,0.150139 -0.0145296,0.291802 -0.0290591,0.291802 -0.0133188,0 -0.0205835,-0.141663 -0.0181619,-0.291802zm0.0339023 0.521853l-0.0302699 1.74112 -0.0387455 0 0.0302699 -1.74112 0.0387455 0z"/>
|
||||
<path class="fil1" d="M1795.02 40.9019l0.0012108 0.00605398c0.0242159,-0.291802 0.0447995,-0.375347 0.0665938,-0.375347 0.0230051,0 0.0351131,0.111393 0.0351131,0.399563 0,0.101707 -0.0012108,0.226419 -0.00363239,0.38019l-0.0193727 1.00254 -0.0387455 0 0.0181619 -0.998907c0.00242159,-0.101707 0.00363239,-0.177987 0.00363239,-0.240948 0.0012108,-0.187673 -0.00726478,-0.236105 -0.0181619,-0.236105 -0.0181619,0 -0.0484318,0.400774 -0.0569074,0.894778l-0.00968637 0.581182 -0.0399563 0 0.0314807 -1.74112 0.0375347 0 -0.00726478 0.328126z"/>
|
||||
<path class="fil1" d="M1795.24 40.8741c-0.00726478,-0.0496426 -0.0157403,-0.0835449 -0.0230051,-0.0835449 -0.00847557,0 -0.0205835,0.0726478 -0.0205835,0.22884 0,0.101707 0.00847557,0.192517 0.0205835,0.345077 0.012108,0.129555 0.0205835,0.317229 0.0205835,0.469789 0,0.337812 -0.0278483,0.523064 -0.0605398,0.523064 -0.0230051,0 -0.0363239,-0.0835449 -0.0484318,-0.181619l0.0157403 -0.236105c0.00847557,0.0690154 0.0193727,0.15256 0.0290591,0.15256 0.0157403,0 0.0254267,-0.111393 0.0254267,-0.263954 0,-0.118658 -0.00726478,-0.202203 -0.0217943,-0.369293 -0.0133188,-0.161036 -0.0193727,-0.293013 -0.0193727,-0.411671 0,-0.371714 0.0302699,-0.514588 0.0544858,-0.514588 0.0205835,0 0.0339023,0.0762802 0.0411671,0.15256l-0.0133188 0.188884z"/>
|
||||
<path class="fil1" d="M1795.35 42.2459c-0.0133188,0.0726478 -0.0278483,0.111393 -0.0411671,0.111393 -0.0278483,0 -0.0447995,-0.157403 -0.0351131,-0.62356l0.0181619 -0.922627 -0.0205835 0 0.00363239 -0.237316 0.0205835 0 0.00726478 -0.417725 0.0411671 -0.104128 -0.00968637 0.521853 0.0387455 0 -0.00363239 0.237316 -0.0387455 0 -0.0169511 0.86693c-0.00726478,0.358396 0.00484318,0.397141 0.0133188,0.397141 0.00847557,0 0.0133188,-0.0278483 0.0193727,-0.059329l0.00363239 0.230051z"/>
|
||||
<path class="fil1" d="M1795.41 40.0519c0.00242159,-0.131977 0.0145296,-0.267586 0.0278483,-0.267586 0.0133188,0 0.0217943,0.131977 0.0193727,0.267586 -0.00242159,0.150139 -0.0145296,0.291802 -0.0290591,0.291802 -0.0133188,0 -0.0205835,-0.141663 -0.0181619,-0.291802zm0.0339023 0.521853l-0.0302699 1.74112 -0.0387455 0 0.0302699 -1.74112 0.0387455 0z"/>
|
||||
<path class="fil1" d="M1795.55 40.9576c0,-0.111393 -0.00484318,-0.161036 -0.0157403,-0.161036 -0.0169511,0 -0.0363239,0.237316 -0.0447995,0.556966 0.0302699,-0.0266375 0.059329,-0.173144 0.0605398,-0.39593zm0.0157403 1.1551c-0.0266375,0.209468 -0.053275,0.244581 -0.0702262,0.244581 -0.0302699,0 -0.0508534,-0.265164 -0.0508534,-0.682889 0,-0.487951 0.0363239,-1.14178 0.100496,-1.14178 0.0181619,0 0.0411671,0.111393 0.0411671,0.362028 0,0.452838 -0.0641722,0.688943 -0.100496,0.703473 -0.00242159,0.139242 0,0.441941 0.0278483,0.449205 0.0108972,0.00363239 0.0254267,-0.0460103 0.0411671,-0.163457l0.0108972 0.22884z"/>
|
||||
<path class="fil1" d="M1795.69 40.8111c-0.0169511,0 -0.0496426,0.250635 -0.0496426,0.863298 0,0.233684 0.00968637,0.378979 0.0254267,0.378979 0.0181619,0 0.0484318,-0.211889 0.0556966,-1.0994 -0.012108,-0.118658 -0.0157403,-0.142874 -0.0314807,-0.142874zm0.0496426 1.34762c-0.0145296,0.772488 -0.0569074,1.02676 -0.100496,1.02676 -0.0217943,0 -0.0435887,-0.059329 -0.059329,-0.163457l0.0133188 -0.285748c0.012108,0.104128 0.0278483,0.150139 0.0484318,0.150139 0.0254267,0 0.0496426,-0.188884 0.0569074,-0.592079l0.00484318 -0.237316 0 -0.00605398 -0.00847557 0.0968637c-0.00484318,0.0629614 -0.0242159,0.209468 -0.0496426,0.209468 -0.0290591,0 -0.047221,-0.272429 -0.047221,-0.647776 0,-0.556966 0.0399563,-1.17689 0.0908097,-1.17689 0.0133188,0 0.0290591,0.0556966 0.0363239,0.159825l0.00242159 -0.118658 0.0399563 0 -0.0278483 1.58493z"/>
|
||||
<path class="fil1" d="M1791.76 39.1378c0.00968637,0.0678046 0.0762802,0.548491 0.0823341,0.590869 0.00847557,0.0605398 0.0181619,0.0968637 0.0302699,0.0956529 0.012108,0 0.165879,0 0.165879,0l0.0411671 0.466157c-0.0230051,0 -0.199781,0 -0.216733,0 -0.0169511,0 -0.0278483,-0.00484318 -0.0447995,-0.12229 -0.00605398,-0.0460103 -0.0678046,-0.48674 -0.0859665,-0.615084 -0.0266375,-0.19736 -0.0544858,-0.188884 -0.0847557,-0.187673l-0.107761 0 -0.0387455 -0.451627c0,0 0.100496,0 0.142874,0 0.0375347,0.00363239 0.0569074,0.00363239 0.0738586,0.0339023 0.0230051,0.0399563 0.0326915,0.125923 0.0423779,0.190095z"/>
|
||||
<path class="fil1" d="M1791.85 40.5036c0.0726478,0 0.245792,-0.0012108 0.245792,-0.0012108 0.0133188,0.159825 0.0266375,0.302699 0.0387455,0.449205l-0.301488 0c-0.0193727,0 -0.0302699,-0.0351131 -0.047221,-0.158614 -0.0230051,-0.163457 -0.0556966,-0.400774 -0.0738586,-0.529118 -0.0169511,-0.12229 -0.0290591,-0.217943 -0.0569074,-0.217943l-0.0605398 0 -0.0375347 -0.45647c0,0 0.0787017,0 0.118658,0 0.0157403,0 0.0339023,0.0799125 0.0569074,0.233684 0.0181619,0.117447 0.0556966,0.401984 0.0787017,0.559388 0.0157403,0.116236 0.0278483,0.12108 0.0387455,0.12108z"/>
|
||||
<path class="fil1" d="M1791.79 41.0629c0.0217943,0.157403 0.047221,0.116236 0.059329,0.12229l0.286959 0 -0.0363239 0.441941 -0.290591 0c-0.0205835,0 -0.0375347,-0.0920205 -0.053275,-0.2131 -0.0145296,-0.107761 -0.0484318,-0.336601 -0.0787017,-0.56302 -0.00968637,-0.0690154 -0.0254267,-0.147717 -0.0460103,-0.147717 -0.0242159,0 -0.0738586,0.0012108 -0.0738586,0.0012108l0.0411671 -0.483108c0,0 0.0254267,0 0.0484318,0 0.0193727,0 0.0302699,0.0411671 0.0447995,0.138031 0.0242159,0.180409 0.0762802,0.549701 0.0980745,0.703473z"/>
|
||||
<path class="fil1" d="M1791.76 41.6974c0.0133188,0.0920205 0.0351131,0.146506 0.053275,0.146506l0.271218 0 -0.0411671 0.469789 -0.25911 -0.0012108c-0.0254267,0.0012108 -0.0363239,-0.119869 -0.059329,-0.277272 -0.0133188,-0.101707 -0.0460103,-0.329337 -0.0641722,-0.467367 -0.0193727,-0.140452 -0.0363239,-0.199781 -0.0569074,-0.199781 -0.0387455,0 -0.100496,-0.0012108 -0.100496,-0.0012108 0.0133188,-0.157403 0.0266375,-0.308753 0.0399563,-0.469789 0,0 0.0242159,-0.0012108 0.0339023,-0.0012108 0.0266375,0 0.0690154,-0.0193727 0.0908097,0.13682 0.0399563,0.288169 0.0665938,0.475843 0.0920205,0.664727z"/>
|
||||
<path class="fil0" d="M1792.56 40.8341c-0.0460103,-0.15256 -0.0581182,-0.221576 -0.0581182,-0.352342 0,-0.190095 0.0266375,-0.288169 0.0484318,-0.288169 0.0230051,0 0.0520642,0.101707 0.0520642,0.420146l0.0617506 0c0,-0.661095 -0.0508534,-0.859665 -0.111393,-0.859665 -0.0569074,0 -0.116236,0.194938 -0.116236,0.777331 0,0.362028 0.0278483,0.543647 0.0738586,0.704683 0.047221,0.163457 0.0665938,0.22763 0.0665938,0.404406 0,0.194938 -0.0266375,0.297856 -0.0520642,0.297856 -0.0423779,0 -0.059329,-0.245792 -0.059329,-0.449205l-0.0617506 0c0,0.596922 0.0375347,0.903254 0.119869,0.903254 0.077491,0 0.118658,-0.341445 0.118658,-0.808812 0,-0.386244 -0.0290591,-0.570285 -0.0823341,-0.749483z"/>
|
||||
</symbol>
|
||||
<symbol id="Fm20-63-0" viewBox="1997.11 -74.7098 336.444 37.0504">
|
||||
<use transform="scale(78.7614 8.6735)" x="25.3565" y="-8.61358" width="4.27169" height="4.27169" xlink:href="#Fm19-61-0"/>
|
||||
</symbol>
|
||||
<g id="Ebene_x0020_1">
|
||||
<metadata id="CorelCorpID_0Corel-Layer"/>
|
||||
<use transform="scale(10.9175 10.9175)" y="7.72889e-005" width="336.444" height="37.0504" xlink:href="#Fm20-63-0"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 13 KiB |
BIN
connectiq/resources/drawables/bus_icon.png
Normal file
BIN
connectiq/resources/drawables/bus_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
BIN
connectiq/resources/drawables/bus_stop_sign.png
Normal file
BIN
connectiq/resources/drawables/bus_stop_sign.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
6
connectiq/resources/drawables/bus_stop_sign.svg
Normal file
6
connectiq/resources/drawables/bus_stop_sign.svg
Normal file
|
@ -0,0 +1,6 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" viewBox="0 0 74 74">
|
||||
<circle fill="#F0CA00" cx="37" cy="37" r="37"/>
|
||||
<circle fill="#008754" cx="37" cy="37" r="35"/>
|
||||
<circle fill="#F0CA00" cx="37" cy="37" r="25"/>
|
||||
<path fill="#008754" d="m 44.5,34 -15,0 0,-16 -6,0 0,38 6,0 0,-17 15,0 0,17 6,0 0,-38 -6,0 z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 340 B |
|
@ -1,3 +1,3 @@
|
|||
<drawables>
|
||||
<bitmap id="LauncherIcon" filename="launcher_icon.png" />
|
||||
<bitmap id="LauncherIcon" filename="bus_stop_sign.png" />
|
||||
</drawables>
|
Binary file not shown.
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.9 KiB |
15
connectiq/resources/porperties.xml
Normal file
15
connectiq/resources/porperties.xml
Normal file
|
@ -0,0 +1,15 @@
|
|||
<resources>
|
||||
|
||||
<properties>
|
||||
<property id="api_url_index" type="number">1</property>
|
||||
</properties>
|
||||
|
||||
<settings>
|
||||
<setting propertyKey="@Properties.api_url_index" title="@Strings.ApiUrl" prompt="@Strings.ApiUrlPrompt">
|
||||
<settingConfig type="list">
|
||||
<listEntry value="0">@Strings.ApiUrlLocalhost</listEntry>
|
||||
<listEntry value="1">@Strings.ApiUrlNulll</listEntry>
|
||||
</settingConfig>
|
||||
</setting>
|
||||
</settings>
|
||||
</resources>
|
|
@ -1,3 +1,7 @@
|
|||
<strings>
|
||||
<string id="AppName">ASEAG Fahrplan</string>
|
||||
<string id="AppName">Bus Stops</string>
|
||||
<string id="ApiUrl">API URL</string>
|
||||
<string id="ApiUrlPrompt">API URL:</string>
|
||||
<string id="ApiUrlLocalhost">http://localhost:8080</string>
|
||||
<string id="ApiUrlNulll">https://connectiq-ura.0l.de</string>
|
||||
</strings>
|
|
@ -1,54 +1,57 @@
|
|||
using Toybox.Application as App;
|
||||
using Toybox.Position as Position;
|
||||
using Toybox.Time as Time;
|
||||
using Toybox.Application;
|
||||
using Toybox.Position;
|
||||
using Toybox.Time;
|
||||
using Toybox.Sensor;
|
||||
using Toybox.System;
|
||||
|
||||
class BusStopApp extends App.AppBase {
|
||||
var mView;
|
||||
var mDelegate;
|
||||
class BusStopApp extends Application.AppBase {
|
||||
var view;
|
||||
var delegate;
|
||||
var position;
|
||||
var sensors;
|
||||
var api_url;
|
||||
|
||||
function intialize() {
|
||||
AppBase.initialize();
|
||||
}
|
||||
|
||||
//! onStart() is called on application start up
|
||||
function onStart() {
|
||||
Position.enableLocationEvents(Position.LOCATION_CONTINUOUS, method(:onPosition));
|
||||
}
|
||||
|
||||
//! onStop() is called when your application is exiting
|
||||
function onStop() {
|
||||
Position.enableLocationEvents(Position.LOCATION_DISABLE, method(:onPosition));
|
||||
var offset = 0;
|
||||
var stopId = 0;
|
||||
|
||||
function initialize() {
|
||||
Application.AppBase.initialize();
|
||||
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
function fakePosition() {
|
||||
var pos = new Position.Info();
|
||||
|
||||
pos.accuracy = 0;
|
||||
pos.altitude = 0;
|
||||
pos.heading = 0;
|
||||
pos.speed = 0;
|
||||
pos.when = Time.now();
|
||||
pos.position = new Position.Location({
|
||||
:latitude => 50.7855,
|
||||
:longitude => 6.0541,
|
||||
:format => :degrees
|
||||
});
|
||||
|
||||
mView.setPosition(pos);
|
||||
function onSettingsChanged() {
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
function loadSettings() {
|
||||
var api_url_index = 1; //getProperty("api_url_index");
|
||||
|
||||
switch (api_url_index) {
|
||||
case 0:
|
||||
api_url = "https://localhost:8080";
|
||||
break;
|
||||
|
||||
case 1:
|
||||
api_url = "https://connectiq-ura.0l.de";
|
||||
break;
|
||||
}
|
||||
|
||||
System.println(api_url);
|
||||
}
|
||||
|
||||
function onPosition(info) {
|
||||
positionView.setPosition(info);
|
||||
function onStart(state) {
|
||||
}
|
||||
|
||||
function onStop(state) {
|
||||
}
|
||||
|
||||
//! Return the initial view of your application here
|
||||
function getInitialView() {
|
||||
mView = new BusStopView();
|
||||
mDelegate = new BusStopDelegate();
|
||||
view = new BusStopView(self);
|
||||
delegate = new BusStopDelegate(self);
|
||||
|
||||
fakePosition();
|
||||
|
||||
return [ mView, mDelegate ];
|
||||
return [ view, delegate ];
|
||||
}
|
||||
|
||||
}
|
|
@ -1,10 +1,36 @@
|
|||
using Toybox.WatchUi as Ui;
|
||||
using Toybox.Graphics as Gfx;
|
||||
using Toybox.System as Sys;
|
||||
using Toybox.WatchUi;
|
||||
|
||||
var last_key = null;
|
||||
|
||||
class InputTestDelegate extends Ui.BehaviorDelegate {
|
||||
class BusStopDelegate extends WatchUi.BehaviorDelegate {
|
||||
var app;
|
||||
|
||||
function initialize(a) {
|
||||
WatchUi.BehaviorDelegate.initialize();
|
||||
|
||||
app = a;
|
||||
}
|
||||
|
||||
function onNextPage() {
|
||||
app.view.offset += 1;
|
||||
|
||||
WatchUi.requestUpdate();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function onPreviousPage() {
|
||||
if (app.view.offset > 0) {
|
||||
app.view.offset -= 1;
|
||||
|
||||
WatchUi.requestUpdate();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function onSelect() {
|
||||
app.offset = 0;
|
||||
WatchUi.pushView(new DepartureView(app), new DepartureDelegate(app), WatchUi.SLIDE_LEFT);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,105 +1,205 @@
|
|||
using Toybox.WatchUi as Ui;
|
||||
using Toybox.Graphics as Gfx;
|
||||
using Toybox.System as Sys;
|
||||
using Toybox.Lang as Lang;
|
||||
using Toybox.Communications as Comm;
|
||||
using Toybox.System as Sys;
|
||||
using Toybox.Time as Time;
|
||||
using Toybox.Timer as Timer;
|
||||
using Toybox.WatchUi;
|
||||
using Toybox.Graphics;
|
||||
using Toybox.System;
|
||||
using Toybox.Lang;
|
||||
using Toybox.Communications;
|
||||
using Toybox.System;
|
||||
|
||||
class BusStopView extends Ui.View {
|
||||
var schedule = null;
|
||||
var tmr;
|
||||
class CompassDrawable extends WatchUi.Drawable {
|
||||
|
||||
var bearing = 0;
|
||||
var aWidth = 2;
|
||||
var aLength = 6;
|
||||
var aColor = Graphics.COLOR_RED;
|
||||
|
||||
function initialize(settings) {
|
||||
WatchUi.Drawable.initialize(settings);
|
||||
|
||||
aWidth = settings[:aWidth];
|
||||
aLength = settings[:aLength];
|
||||
aColor = settings[:aColor];
|
||||
}
|
||||
|
||||
function setBearing(b) {
|
||||
bearing = Math.PI * (b - 90) / 180;
|
||||
}
|
||||
|
||||
function draw(dc) {
|
||||
var rPts = new[7];
|
||||
var aPts = [
|
||||
[-0.5*aLength, -0.5*aWidth],
|
||||
[ 0.0, -0.5*aWidth],
|
||||
[ 0.0, -1.0*aWidth],
|
||||
[ 0.5*aLength, 0],
|
||||
[ 0.0, 1.0*aWidth],
|
||||
[ 0.0, 0.5*aWidth],
|
||||
[-0.5*aLength, 0.5*aWidth]
|
||||
];
|
||||
|
||||
var s = Math.sin(bearing);
|
||||
var c = Math.cos(bearing);
|
||||
|
||||
for (var i = 0; i < 7; i++) {
|
||||
var p = aPts[i];
|
||||
rPts[i] = [
|
||||
locX + width * (p[0] * c - p[1] * s),
|
||||
locY + height * (p[0] * s + p[1] * c)
|
||||
];
|
||||
}
|
||||
|
||||
dc.setColor(aColor, Graphics.COLOR_TRANSPARENT);
|
||||
dc.fillPolygon(rPts);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class BusStopView extends WatchUi.View {
|
||||
var stops = null;
|
||||
var app;
|
||||
var compass;
|
||||
|
||||
var offset = 0;
|
||||
var sensors;
|
||||
var position;
|
||||
|
||||
function intialize() {
|
||||
View.initialize();
|
||||
}
|
||||
|
||||
//! Load your resources here
|
||||
function onLayout(dc) {
|
||||
}
|
||||
|
||||
//! Called when this View is brought to the foreground. Restore
|
||||
//! the state of this View and prepare it to be shown. This includes
|
||||
//! loading resources into memory.
|
||||
function onShow() {
|
||||
tmr = new Timer.Timer();
|
||||
tmr.start(method(:redraw), 1000, true);
|
||||
}
|
||||
|
||||
//! Called when this View is removed from the screen. Save the
|
||||
//! state of this View here. This includes freeing resources from
|
||||
//! memory.
|
||||
function onHide() {
|
||||
tmr.stop();
|
||||
}
|
||||
|
||||
//! Update the view
|
||||
function onUpdate(dc) {
|
||||
var string;
|
||||
|
||||
// Set background color
|
||||
dc.setColor( Gfx.COLOR_TRANSPARENT, Gfx.COLOR_BLACK );
|
||||
dc.clear();
|
||||
dc.setColor( Gfx.COLOR_WHITE, Gfx.COLOR_TRANSPARENT );
|
||||
|
||||
if( schedule != null ) {
|
||||
var ts = new Time.Moment(schedule[1][4] / 1000);
|
||||
var duration = Time.now().subtract(ts);
|
||||
var ts_greg = Time.Gregorian.info(ts, Time.FORMAT_MEDIUM);
|
||||
var dur_greg = Time.Gregorian.info(new Time.Moment(duration.value()), Time.FORMAT_SHORT);
|
||||
|
||||
/* Timezone offset */
|
||||
dur_greg.hour -= 2;
|
||||
|
||||
var arr = Lang.format("$1$:$2$:$3$", [
|
||||
(ts_greg.hour - 2),
|
||||
(ts_greg.min).format("%02u"),
|
||||
(ts_greg.sec).format("%02u")
|
||||
]);
|
||||
|
||||
var due = "";
|
||||
if (dur_greg.hour > 0) {
|
||||
due += dur_greg.hour + " h ";
|
||||
}
|
||||
if (dur_greg.min > 0) {
|
||||
due += dur_greg.min + " min ";
|
||||
}
|
||||
if (dur_greg.sec > 0) {
|
||||
due += dur_greg.sec + " sec ";
|
||||
}
|
||||
|
||||
dc.drawText( (dc.getWidth() / 2), (dc.getHeight() / 2) - 80, Gfx.FONT_LARGE, schedule[1][2], Gfx.TEXT_JUSTIFY_CENTER );
|
||||
dc.drawText( (dc.getWidth() / 2), (dc.getHeight() / 2) - 40, Gfx.FONT_SMALL, schedule[1][1], Gfx.TEXT_JUSTIFY_CENTER );
|
||||
dc.drawText( (dc.getWidth() / 2), (dc.getHeight() / 2) - 20, Gfx.FONT_SMALL, schedule[1][3], Gfx.TEXT_JUSTIFY_CENTER );
|
||||
dc.drawText( (dc.getWidth() / 2), (dc.getHeight() / 2) + 10, Gfx.FONT_SMALL, arr, Gfx.TEXT_JUSTIFY_CENTER );
|
||||
dc.drawText( (dc.getWidth() / 2), (dc.getHeight() / 2) + 40, Gfx.FONT_SMALL, due, Gfx.TEXT_JUSTIFY_CENTER );
|
||||
}
|
||||
else {
|
||||
dc.drawText( (dc.getWidth() / 2), (dc.getHeight() / 2), Gfx.FONT_SMALL, "No schedule avail", Gfx.TEXT_JUSTIFY_CENTER );
|
||||
}
|
||||
}
|
||||
|
||||
function setPosition(info) {
|
||||
var url = "http://web.0l.de:8080/";
|
||||
var parameters = { "Circle" => info.position.toDegrees()[0] + "," +
|
||||
info.position.toDegrees()[1] + ",150",
|
||||
"ReturnList" => "StopPointName,DestinationName,LineName,EstimatedTime" };
|
||||
var options = { :method => Comm.HTTP_REQUEST_METHOD_GET };
|
||||
function initialize(a) {
|
||||
WatchUi.View.initialize();
|
||||
|
||||
Comm.makeJsonRequest(url, parameters, options, method(:requestCompleted));
|
||||
app = a;
|
||||
}
|
||||
|
||||
function onLayout(dc) {
|
||||
var compassX = dc.getWidth() / 2;
|
||||
var compassY = dc.getHeight() / 2 - 60;
|
||||
|
||||
compass = new CompassDrawable({
|
||||
:locX => compassX,
|
||||
:locY => compassY,
|
||||
:width => 11,
|
||||
:height => 11,
|
||||
:aWidth => 2,
|
||||
:aLength => 6,
|
||||
:aColor => Graphics.COLOR_DK_RED
|
||||
});
|
||||
}
|
||||
|
||||
function onShow() {
|
||||
Position.enableLocationEvents(Position.LOCATION_CONTINUOUS, method(:onPosition));
|
||||
|
||||
Sensor.setEnabledSensors([Sensor.SENSOR_HEARTRATE]);
|
||||
Sensor.enableSensorEvents(method(:onSensor));
|
||||
}
|
||||
|
||||
function onHide() {
|
||||
Position.enableLocationEvents(Position.LOCATION_DISABLE, method(:updateStops));
|
||||
}
|
||||
|
||||
function onPosition(positionInfo) {
|
||||
System.println("Position: " + positionInfo.position.toDegrees());
|
||||
|
||||
position = positionInfo;
|
||||
updateStops();
|
||||
}
|
||||
|
||||
function onSensor(sensorInfo) {
|
||||
System.println("Heading: " + 180.0 * Math.PI / sensorInfo.heading);
|
||||
|
||||
sensors = sensorInfo;
|
||||
requestUpdate();
|
||||
}
|
||||
|
||||
function onUpdate(dc) {
|
||||
// Set background color
|
||||
dc.setColor(Graphics.COLOR_TRANSPARENT, Graphics.COLOR_BLACK);
|
||||
dc.clear();
|
||||
|
||||
var midW = dc.getWidth() / 2;
|
||||
var midH = dc.getHeight() / 2;
|
||||
var top = Graphics.getFontAscent(Graphics.FONT_SMALL);
|
||||
|
||||
if (stops != null) {
|
||||
if (stops.size() > 0) {
|
||||
if (offset >= stops.size()) {
|
||||
offset = stops.size() - 1;
|
||||
}
|
||||
|
||||
var stop = stops[offset];
|
||||
|
||||
var dist = stop["dist"] < 1000
|
||||
? stop["dist"].format("%.0f") + " m"
|
||||
: (stop["dist"] / 1000).format("%.1f") + " km";
|
||||
|
||||
var bearing = stop["bearing"].format("%.0f") + "° (" + stop["bearing_str"] + ")";
|
||||
|
||||
var y = midH;
|
||||
|
||||
var bDeg = stop["bearing"];
|
||||
var hDeg = 180.0 * sensors.heading / Math.PI;
|
||||
|
||||
dc.setColor(Graphics.COLOR_RED, Graphics.COLOR_TRANSPARENT);
|
||||
dc.setPenWidth(4);
|
||||
dc.drawArc(midW, midH, midW-2, Graphics.ARC_CLOCKWISE, -bDeg+5+90, -bDeg-5+90);
|
||||
|
||||
dc.setColor(Graphics.COLOR_YELLOW, Graphics.COLOR_TRANSPARENT);
|
||||
dc.setPenWidth(4);
|
||||
dc.drawArc(midW, midH, midW-2, Graphics.ARC_CLOCKWISE, -hDeg+5, -hDeg-5);
|
||||
|
||||
compass.setBearing(bDeg);
|
||||
compass.draw(dc);
|
||||
|
||||
dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_TRANSPARENT);
|
||||
dc.drawText(midW, y, Graphics.FONT_MEDIUM, stop["name"], Graphics.TEXT_JUSTIFY_CENTER + Graphics.TEXT_JUSTIFY_VCENTER);
|
||||
|
||||
y += dc.getFontAscent(Graphics.FONT_SMALL) + dc.getFontDescent(Graphics.FONT_MEDIUM);
|
||||
|
||||
if (stop["indicator"].length() > 0) {
|
||||
dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_TRANSPARENT);
|
||||
dc.drawText(midW, y, Graphics.FONT_SMALL, stop["indicator"], Graphics.TEXT_JUSTIFY_CENTER + Graphics.TEXT_JUSTIFY_VCENTER);
|
||||
}
|
||||
|
||||
y += dc.getFontAscent(Graphics.FONT_TINY) + dc.getFontDescent(Graphics.FONT_SMALL);
|
||||
|
||||
dc.setColor(Graphics.COLOR_LT_GRAY, Graphics.COLOR_TRANSPARENT);
|
||||
dc.drawText(midW, y, Graphics.FONT_TINY, dist, Graphics.TEXT_JUSTIFY_CENTER);
|
||||
|
||||
y += dc.getFontAscent(Graphics.FONT_TINY) + dc.getFontDescent(Graphics.FONT_TINY);
|
||||
|
||||
dc.drawText(midW, y, Graphics.FONT_TINY, bearing, Graphics.TEXT_JUSTIFY_CENTER);
|
||||
|
||||
app.stopId = stop["id"];
|
||||
}
|
||||
else {
|
||||
dc.drawText(midW, midH, Graphics.FONT_SMALL, "No stops found!", Graphics.TEXT_JUSTIFY_CENTER);
|
||||
}
|
||||
}
|
||||
else {
|
||||
dc.drawText(midW, midH, Graphics.FONT_SMALL, "Loading...", Graphics.TEXT_JUSTIFY_CENTER);
|
||||
}
|
||||
}
|
||||
|
||||
function updateStops() {
|
||||
var degs = position.position.toDegrees();
|
||||
var params = {
|
||||
"latitude" => degs[0],
|
||||
"longitude" => degs[1],
|
||||
"distance" => 10000,
|
||||
"limit" => 50
|
||||
};
|
||||
|
||||
var options = {
|
||||
:method => Communications.HTTP_REQUEST_METHOD_GET,
|
||||
:responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_JSON
|
||||
};
|
||||
|
||||
Communications.makeWebRequest(app.api_url + "/stops", params, options, method(:requestCompleted));
|
||||
}
|
||||
|
||||
function requestCompleted(responseCode, data) {
|
||||
Sys.println("Request completed: " + responseCode);
|
||||
System.println("Request completed: " + responseCode);
|
||||
|
||||
if (responseCode == 200) {
|
||||
schedule = data;
|
||||
redraw();
|
||||
stops = data;
|
||||
WatchUi.requestUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
function redraw() {
|
||||
WatchUi.requestUpdate();
|
||||
}
|
||||
}
|
||||
|
|
36
connectiq/source/DepartureDelegate.mc
Normal file
36
connectiq/source/DepartureDelegate.mc
Normal file
|
@ -0,0 +1,36 @@
|
|||
using Toybox.WatchUi;
|
||||
|
||||
class DepartureDelegate extends WatchUi.BehaviorDelegate {
|
||||
var app;
|
||||
|
||||
function initialize(a) {
|
||||
WatchUi.BehaviorDelegate.initialize();
|
||||
|
||||
app = a;
|
||||
}
|
||||
|
||||
function onNextPage() {
|
||||
app.offset += 1;
|
||||
|
||||
WatchUi.requestUpdate();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function onPreviousPage() {
|
||||
if (app.offset > 0) {
|
||||
app.offset -= 1;
|
||||
|
||||
WatchUi.requestUpdate();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function onBack() {
|
||||
app.offset = 0;
|
||||
WatchUi.popView(WatchUi.SLIDE_RIGHT);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
84
connectiq/source/DepartureView.mc
Normal file
84
connectiq/source/DepartureView.mc
Normal file
|
@ -0,0 +1,84 @@
|
|||
using Toybox.WatchUi;
|
||||
using Toybox.Graphics;
|
||||
using Toybox.System;
|
||||
using Toybox.Communications;
|
||||
using Toybox.Timer;
|
||||
|
||||
class DepartureView extends WatchUi.View {
|
||||
var departures = null;
|
||||
var tmr;
|
||||
var app;
|
||||
|
||||
function initialize(a) {
|
||||
WatchUi.View.initialize();
|
||||
|
||||
app = a;
|
||||
|
||||
updateDepartures();
|
||||
}
|
||||
|
||||
function onLayout(dc) {
|
||||
|
||||
}
|
||||
|
||||
function onShow() {
|
||||
tmr = new Timer.Timer();
|
||||
tmr.start(method(:updateDepartures), 10000, true);
|
||||
}
|
||||
|
||||
|
||||
function onHide() {
|
||||
tmr.stop();
|
||||
}
|
||||
|
||||
function onUpdate(dc) {
|
||||
dc.setColor(Graphics.COLOR_TRANSPARENT, Graphics.COLOR_BLACK);
|
||||
dc.clear();
|
||||
dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_TRANSPARENT);
|
||||
|
||||
var mid = dc.getWidth() / 2;
|
||||
var top = Graphics.getFontAscent(Graphics.FONT_SMALL);
|
||||
|
||||
if (departures != null) {
|
||||
if (departures.size() > 0) {
|
||||
for (var i = app.offset; i < departures.size(); i++) {
|
||||
var dep = departures[i];
|
||||
|
||||
dc.drawText(mid, top, Graphics.FONT_SMALL, dep["line"] + " " + dep["dest"], Graphics.TEXT_JUSTIFY_CENTER);
|
||||
top += Graphics.getFontAscent(Graphics.FONT_TINY);
|
||||
dc.drawText(mid, top, Graphics.FONT_XTINY, dep["delta_str"], Graphics.TEXT_JUSTIFY_CENTER);
|
||||
|
||||
top += Graphics.getFontHeight(Graphics.FONT_SMALL);
|
||||
}
|
||||
}
|
||||
else {
|
||||
dc.drawText( (dc.getWidth() / 2), (dc.getHeight() / 2), Graphics.FONT_SMALL, "No departures!", Graphics.TEXT_JUSTIFY_CENTER );
|
||||
}
|
||||
}
|
||||
else {
|
||||
dc.drawText( (dc.getWidth() / 2), (dc.getHeight() / 2), Graphics.FONT_SMALL, "Loading...", Graphics.TEXT_JUSTIFY_CENTER );
|
||||
}
|
||||
}
|
||||
|
||||
function updateDepartures() {
|
||||
var parameters = {
|
||||
"id" => app.stopId,
|
||||
"limit" => 10
|
||||
};
|
||||
var options = {
|
||||
:method => Communications.HTTP_REQUEST_METHOD_GET,
|
||||
:responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_JSON
|
||||
};
|
||||
|
||||
Communications.makeWebRequest(app.api_url + "/departures", parameters, options, method(:requestCompleted));
|
||||
}
|
||||
|
||||
function requestCompleted(responseCode, data) {
|
||||
System.println("Request completed: " + responseCode);
|
||||
|
||||
if (responseCode == 200) {
|
||||
departures = data;
|
||||
WatchUi.requestUpdate();
|
||||
}
|
||||
}
|
||||
}
|
8
rev-eng/script.sh
Normal file
8
rev-eng/script.sh
Normal file
|
@ -0,0 +1,8 @@
|
|||
API_BASE="http://ivu.aseag.de/interfaces/ura"
|
||||
|
||||
LOC="50.7802655,6.0752138,400"
|
||||
RL="StopPointName,StopID,StopPointState,StopPointIndicator,Latitude,Longitude,VisitNumber,TripID,VehicleID,LineID,LineName,DirectionID,DestinationName,DestinationText,EstimatedTime,BaseVersion"
|
||||
|
||||
# curl "${API_BASE}/location?searchString=*&maxResults=10000" | jq .
|
||||
|
||||
curl "${API_BASE}/instant_V1?Circle=${LOC}&StopPointState=0&ReturnList=${RL}"
|
|
@ -1,29 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import json
|
||||
import requests
|
||||
|
||||
from wsgiref.simple_server import make_server
|
||||
from cgi import parse_qs, escape
|
||||
|
||||
|
||||
def get(environ, start_response):
|
||||
parameters = parse_qs(environ.get('QUERY_STRING', ''))
|
||||
|
||||
url = 'http://ivu.aseag.de/interfaces/ura/instant_V1'
|
||||
# url = 'http://countdown.api.tfl.gov.uk/interfaces/ura/instant_V1'
|
||||
|
||||
r = requests.get(url, parameters)
|
||||
|
||||
output = []
|
||||
for line in r.text.splitlines():
|
||||
print line
|
||||
output.append(json.loads(line))
|
||||
|
||||
start_response('200 OK', [('Content-Type', 'application/json')])
|
||||
|
||||
return json.dumps(output)
|
||||
|
||||
if __name__ == '__main__':
|
||||
srv = make_server('localhost', 8080, get)
|
||||
srv.serve_forever()
|
Loading…
Add table
Reference in a new issue