mirror of
https://github.com/TiddlyWiki/TiddlyWiki5.git
synced 2026-05-04 19:16:45 +00:00
Add basic support for traveltime.com isochrone API
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
title: $:/plugins/geospatial/demo/features/us-states
|
||||
type: application/json
|
||||
tags: $:/tags/GeoLayer
|
||||
|
||||
{"type":"FeatureCollection","features":[
|
||||
{"type":"Feature","id":"01","properties":{"name":"Alabama","density":94.65},"geometry":{"type":"Polygon","coordinates":[[[-87.359296,35.00118],[-85.606675,34.984749],[-85.431413,34.124869],[-85.184951,32.859696],[-85.069935,32.580372],[-84.960397,32.421541],[-85.004212,32.322956],[-84.889196,32.262709],[-85.058981,32.13674],[-85.053504,32.01077],[-85.141136,31.840985],[-85.042551,31.539753],[-85.113751,31.27686],[-85.004212,31.003013],[-85.497137,30.997536],[-87.600282,30.997536],[-87.633143,30.86609],[-87.408589,30.674397],[-87.446927,30.510088],[-87.37025,30.427934],[-87.518128,30.280057],[-87.655051,30.247195],[-87.90699,30.411504],[-87.934375,30.657966],[-88.011052,30.685351],[-88.10416,30.499135],[-88.137022,30.318396],[-88.394438,30.367688],[-88.471115,31.895754],[-88.241084,33.796253],[-88.098683,34.891641],[-88.202745,34.995703],[-87.359296,35.00118]]]}},
|
||||
|
||||
11
plugins/tiddlywiki/geospatial/demo/maps.tid
Normal file
11
plugins/tiddlywiki/geospatial/demo/maps.tid
Normal file
@@ -0,0 +1,11 @@
|
||||
title: $:/plugins/tiddlywiki/geospatial/demo/maps
|
||||
caption: Maps
|
||||
tags: $:/tags/GeospatialDemo
|
||||
|
||||
! Map with Layers and Markers
|
||||
|
||||
<$geomap
|
||||
markers="[all[tiddlers+shadows]tag[$:/tags/GeoMarker]]"
|
||||
layers="[all[tiddlers+shadows]tag[$:/tags/GeoLayer]]"
|
||||
/>
|
||||
|
||||
92
plugins/tiddlywiki/geospatial/demo/traveltime.tid
Normal file
92
plugins/tiddlywiki/geospatial/demo/traveltime.tid
Normal file
@@ -0,0 +1,92 @@
|
||||
title: $:/plugins/tiddlywiki/geospatial/demo/traveltime
|
||||
caption: Traveltime
|
||||
tags: $:/tags/GeospatialDemo
|
||||
|
||||
\define completion-actions()
|
||||
<$action-log/>
|
||||
<$action-setfield $tiddler="$:/temp/_StatusCode" text=<<status>>/>
|
||||
<$action-setfield $tiddler="$:/temp/_StatusText" text=<<statusText>>/>
|
||||
<$action-setfield $tiddler="$:/temp/_Error" text=<<error>>/>
|
||||
<$action-setfield $tiddler="$:/temp/_Result" text=<<data>>/>
|
||||
<$action-setfield $tiddler="$:/temp/_Headers" text=<<headers>>/>
|
||||
<$list filter="[<status>match[200]]" variable="ignore">
|
||||
<$action-setfield $tiddler="$:/temp/_IsochroneLayer" text={{{ [<data>] }}} tags="$:/tags/GeoLayer"/>
|
||||
</$list>
|
||||
\end
|
||||
|
||||
\define progress-actions()
|
||||
<$action-log message="In progress-actions"/>
|
||||
<$action-log/>
|
||||
\end
|
||||
|
||||
\define payload-source()
|
||||
\rules only transcludeinline transcludeblock filteredtranscludeinline filteredtranscludeblock
|
||||
{
|
||||
"departure_searches": [
|
||||
{
|
||||
"id": "My first isochrone",
|
||||
"coords": {
|
||||
"lat": 51.507609,
|
||||
"lng": -0.128315
|
||||
},
|
||||
"departure_time": "2021-09-27T08:00:00Z",
|
||||
"travel_time": 3600,
|
||||
"transportation": {
|
||||
"type": "driving"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
\end
|
||||
|
||||
\define get-traveltime-actions()
|
||||
<$wikify name="payload" text=<<payload-source>>>
|
||||
<$action-log $message="Making payload"/>
|
||||
<$action-log/>
|
||||
<$action-sendmessage
|
||||
$message="tm-http-request"
|
||||
url="https://api.traveltimeapp.com/v4/time-map"
|
||||
method="POST"
|
||||
header-accept="application/geo+json"
|
||||
header-Content-Type="application/json"
|
||||
password-header-X-Api-Key="traveltime-secret-key"
|
||||
password-header-X-Application-Id="traveltime-application-id"
|
||||
body=<<payload>>
|
||||
var-context="Context string"
|
||||
bind-status="$:/temp/plugins/tiddlywiki/geospatial/demo/traveltime/status"
|
||||
bind-progress="$:/temp/plugins/tiddlywiki/geospatial/demo/traveltime/progress"
|
||||
oncompletion=<<completion-actions>>
|
||||
onprogress=<<progress-actions>>
|
||||
/>
|
||||
</$wikify>
|
||||
\end
|
||||
|
||||
|
||||
|
||||
<$button actions=<<get-traveltime-actions>>>
|
||||
Call ~TravelTime
|
||||
</$button>
|
||||
|
||||
Status:
|
||||
<pre><code><$text text={{$:/temp/plugins/tiddlywiki/geospatial/demo/traveltime/status}}/></code></pre>
|
||||
|
||||
Progress:
|
||||
<pre><code><$text text={{$:/temp/plugins/tiddlywiki/geospatial/demo/traveltime/progress}}/></code></pre>
|
||||
|
||||
Response
|
||||
|
||||
~StatusCode:
|
||||
<pre><code><$text text={{$:/temp/_StatusCode}}/></code></pre>
|
||||
|
||||
~StatusText:
|
||||
<pre><code><$text text={{$:/temp/_StatusText}}/></code></pre>
|
||||
|
||||
Error:
|
||||
<pre><code><$text text={{$:/temp/_Error}}/></code></pre>
|
||||
|
||||
Headers:
|
||||
<pre><code><$text text={{$:/temp/_Headers}}/></code></pre>
|
||||
|
||||
Result:
|
||||
<pre><code><$text text={{$:/temp/_Result}}/></code></pre>
|
||||
|
||||
Reference in New Issue
Block a user