TC5.15 - Snap4City Smart City API Collection and overview, real time

×

Warning message

You can't delete this newsletter because it has not been sent to all its subscribers.

Test Case Title

 TC5.15 - Snap4City Smart City API Collection and overview, real time

Goal

I can Use Snap4City Smart City API to develop web and/or mobile applications and/or other services; to create a web page, to create a web app.

I can use Smart City API for creating web and mobile application independent on the organization. So that this technolocy allows the developer to realize an App that canbe used in multiple Location: Firenze, Helsinki, Antwerp, etc. on the basis of the GPS coordinates adapting the App to the service available, without changing the call to the Smart City API.

Prerequisites

Using a PC or Mobile with a web browser. Access to Smart City API user manual. Access to the development tool kit exemplified. 

The following functionalities are available only for specific Snap4city users with specific privileges.

See also: TC5.16 - Exploiting Smart City API for developing Mobile and Web Apps

Expected successful result

Learn how to use the Advanced Smart City API to create a web and/or mobile applications. We have also experienced in applications that are implemented on POS for producing receipts with advertising regarding events in the city and POI.

Steps

 

 

The updated Snap4City mobile development App Kit as open source for developing mobile and web App using cordoba apache is accessible on GitHUB from: 

https://github.com/disit/snap4cityAppKit

See also: TC5.16 - Exploiting Smart City API for developing Mobile and Web Apps

The whole set of Snap4City API also called Smart City API. They are listed and well documented in SWAGGER  https://www.km4city.org/swagger/external as reported in the above image. In addition, they have been tested and validated by using standard tools.

https://www.snap4city.org/drupal/sites/default/files/swagger.png

The updated Snap4City mobile development App Kit as open source for developing mobile and web App using Cordoba Apache is accessible on GitHUB from: 

https://github.com/disit/snap4cityAppKit

ServiceMap can be accessed from the main menu: "Knowledge and maps--> ServiceMap". Please note that the ServiceMap may be different for each Organization and city to faciliate the positioning of the map in the center of the geo area of the organization. On the other hand, the Smart City API can be generalized by invoking  in the final application the SUPER federated Smart City API with the same API call to create Web and Mobile Applications that are independent on the Organization.

The set of Snap4City API includes the following main API that may have a value for the city developers:

The  Advanced Smart City API can be used to develop Web (HTML5) and Mobile Apps and provides support for a number of services:

  • Search data: by text, near, along line, POI, etc. resolving text to GPS and formal city nodes model, resolving from GPS to street civic number, etc.
  • Empowering the city users: collecting data from end users’ bidirectional data flow; votes, comments, images;
  • Access to event information provided that they are loaded into the storage with some ETL or NodeRED process;
  • accessing to info and service on Public Mobility: busstops, public transport lines (bus, train, and ferry), public routes, public transport position, arrival time, etc.;
  • accessing to info and service on Private Mobility: routing, parking recovery;
  • accessing to Cultural and Touristic information, POI;
  • accessing to health services & Environmental info;
  • requesting routing: car, vehicle, multimodal exploiting pedestrian and any public transport, if any;
  • requesting Suggestions; 
  • requesting Personal Assistant hints, provided that you have an Assistant installed in the solution;
  • subscription/request of a Snap4City Applications;
  • Sharing knowledge among cities
  • providing feedback about services
  • IOT device Discovery
  • IOT sensor/actuator Discovery by ValueType and/or ValueUnit

Snap4City APIs support real time data streams, on demand and event driven. Real time open data are managed in the full stack from IOT Device/Brokers, IOT Applications and Dashboard such as via: WebSockets, MQTT, etc. The real time stream can be managed at level of IOT Device/Application, Data Analytics and directly on Dashboards with WebSockets. In addition, the so-called Sensor API for Mobile Phone and other devices can be used to communicate to the back office about their status, position, etc. It is also used to get back suggestions, hints, assistance, soundages, etc. 

Snap4City Smart City API:

Web/Mobile MicroApplication services:

In addition, internally at the platform there are a number of API which are used to communicate among the modules of the Snap4City platform. Most of API are not accessible from outisde the platform for safety reasons https://www.km4city.org/swagger/internal   They are for IOT device registration, noticator API, DISCES, Resource Manager, Sensors from mobiles devices, event logger, ownerhip, and data management.

The Advanced Smart City APIs are strictly connected with the ServiceMap. In the infrastructure multiple ServiceMap can be hosted and each of them provides a specific Advanced Smart City API entry point. The Snap4City solution can gather background information about the city in several formats and from several different sources. Typically, the initial structural data can be ingested by: Open Street Map regarding the city structure (streets, civic numbers, etc.), that can be in turn enriched with additional information a city/region may have. The process for passing from OSM to Km4City is described into the manual loaded in the Google Drive:

https://www.snap4city.org/download/video/From%20the%20Open%20Street%20Map%20to%20the%20Km4City%20street%20graph.pdf

In particular:

The updated Snap4City mobile development App Kit as open source for developing mobile and web App using cordoba apache is accessible on GitHUB from: 

https://github.com/disit/snap4cityAppKit


Example 1: make a request to Advanced Smart City API to get data related to POI and/or IOT devices

They extended the open Smart City API of Km4City for developing Web (HTML5) and Mobile Apps [devkit]. Advanced Smart City API provides support for many services:

  • Search data: by text, near, along line, POI, etc. resolving text to GPS and formal city nodes model

 

In all cases, the resulting data are provided in JSON similar to:
{
"BusStops": {
"fullCount": 25,
"type": "FeatureCollection",
"features":[
{
"geometry":{"type": "Point","coordinates":[11.248678, 43.775333]},
"type": "Feature",
"properties": {
"name": "Stazione Santa Caterina",
"typeLabel": "Fermata",
"tipo": "fermata",
"serviceType": "TransferServiceAndRenting_BusStop",
"busLines": "13 - 14 - 17 - 17N - 22 - 6",
"serviceUri": "http://www.disit.org/km4city/resource/Bus_ataflinea_Stop_FM7004_5",
"distance": "0.039300903508044216",
"agency": "Ataf&Linea",
"agencyUri": "http://www.disit.org/km4city/resource/Bus_ataflinea_Agency_172",
"photoThumbs": []
},
"id": 1
},
{
"geometry":{"type": "Point","coordinates":[11.249319, 43.776028]},
"type": "Feature",
"properties": {
"name": "Stazione Parcheggio",
"typeLabel": "Fermata",
"tipo": "fermata",
"serviceType": "TransferServiceAndRenting_BusStop",
"busLines": "12",
"serviceUri": "http://www.disit.org/km4city/resource/Bus_ataflinea_Stop_FM0313_5",
"distance": "0.053986855820746346",
"agency": "Ataf&Linea",
"agencyUri": "http://www.disit.org/km4city/resource/Bus_ataflinea_Agency_172",
"photoThumbs": []
},
"id": 2
},
{
"geometry":{"type": "Point","coordinates":[11.249555, 43.776028]},
"type": "Feature",
"properties": {
"name": "Firenze Stazione Valfonda",
"typeLabel": "Fermata",
"tipo": "fermata",
"serviceType": "TransferServiceAndRenting_BusStop",
"busLines": "SI330 - SI90",
"serviceUri": "http://www.disit.org/km4city/resource/Bus_etruriamobilita_Stop_F0287_2",
"distance": "0.06511370212220095",
"agency": "Etruria Mobilità",
"agencyUri": "http://www.disit.org/km4city/resource/Bus_etruriamobilita_Agency_168",
"photoThumbs": []
},
"id": 3
}]}
,"SensorSites": {
"fullCount": 3,
"type": "FeatureCollection",
"features": [
{
"geometry":{"type": "Point","coordinates":[11.2498200023853,43.7750499961699]},
"type": "Feature",
"properties": {
"name": "FI055ZTL00101",
"tipo": "sensore",
"typeLabel": "Sensore",
"serviceType": "TransferServiceAndRenting_SensorSite",
"serviceUri": "http://www.disit.org/km4city/resource/FI055ZTL00101",
"distance": "0.08971043872639867",
"photoThumbs": []
},
"id": 1
},
{
"geometry":{"type": "Point","coordinates":[11.2500286102,43.7747001648]},
{

..
..

 


Example 2: Getting GPS services structured information:

The following example return an HTML, the same call with JSON at the end can allow you to get the data

 


Example 3: Getting GPS coordinate from services

number

"1"

address

"VIA GIOVANNI ANTONIO SOGLIANI"

addressUri

"http://www.disit.org/km4city/resource/RT048017011032CV"

municipality

"FIRENZE"

municipalityUri

"http://www.disit.org/km4city/resource/048017"

number

"7"

address

"VIALE FRATELLI ROSSELLI"

intersect

 

 

distance

0.00021905954402899085

name

"Firenze Card"

type

"LineString"

uri

"http://www.disit.org/km4city/resource/2a93692aa1eb7d680d9b4e0da668b408"

class

"http://www.disit.org/km4city/schema#Tourist_trail"

1

 

distance

name

"Spartitraffico di viale Fratelli Rosselli - piazzale di Porta al Prato"

type

"Polygon"

uri

"http://www.disit.org/km4city/resource/ff05267eb9e6a7cc8ea3d9f8b6ae93cd"

class

"http://www.disit.org/km4city/schema#Green_areas"

2

 

distance

name

"ZCS_1_D"

type

"Polygon"

uri

"http://www.disit.org/km4city/resource/bee219f7c86416cc5d57e45744d42eed"

class

"http://www.disit.org/km4city/schema#Controlled_parking_zone"

3

 

distance

0.0002675171725087246

name

"percorsi_ciclabili.191"

type

"LineString"

uri

"http://www.disit.org/km4city/resource/b9256bc7d310eb012fc2db96bca187e3"

class

"http://www.disit.org/km4city/schema#Cycle_paths"

4

 

agency

"Ataf&Linea"

distance

0.00028637316303552354

name

"C2"

type

"LineString"

uri

"http://www.disit.org/km4city/resource/Bus_ataflinea_Trip_2199_3472052"

class

"http://vocab.gtfs.org/terms#Route"

routeType

"Bus"

direction

"Leopolda"

5

 

agency

"Autolinee Chianti Valdarno"

distance

0.0003337107962910289

name

"365 A"

type

"LineString"

uri

"http://www.disit.org/km4city/resource/Bus_acvbus_Trip_2215_12374"

class

"http://vocab.gtfs.org/terms#Route"

routeType

"Bus"

direction

"Alamanni 5"

..

..

 


Example 4: Getting GPS services from TEXT search.

 


Example 5: requesting Suggestions;

Provide suggestion to a specific user for services, events and other entities around a specific position.
https://screcommender.km4city.org/SmartCityRecommender/?action=recommend&user=3043b85d23d6f4879e1765c2c2e431cbc71d393065af06b03486ba4a04642b5b&profile=student&language=en&latitude=43.7727&longitude=11.2532&distance=1&version=1    
 
The JSON allow creating views of suggested data on web and mobile devices.
[{"suggestions":[{"Service":{"features":[{"geometry":{"coordinates":[11.2536,43.7725],"type":"Point"},"id":1,"type":"Feature","properties":{"serviceType":"ShoppingAndService_Newspapers_and_stationery","note":"","city":"FIRENZE","serviceUri":"http:\/\/www.disit.org\/km4city\/resource\/29bc98571a8bf9bcb31ee1c68cd1a227","description":"","description2":"","photos":[],"civic":"2","cap":"50100","avgStars":0.0,"province":"FI","wktGeometry":"","starsCount":0,"fax":"","photoThumbs":[],"photoOrigs":[],"email":"","website":"","address":"VIA DEI BRUNELLESCHI","comments":[],"linkDBpedia":[],"multimedia":"","phone":"","name":"DEL VANGA - PASTORINI","typeLabel":"Newspapers and Stationery"}}],"type":"FeatureCollection"}},{"Service":{"features":[{"geometry":{"coordinates":[11.2535,43.772],"type":"Point"},"id":1,"type":"Feature","properties":{"serviceType":"Entertainment_Discotheque","note":"","city":"FIRENZE","serviceUri":"http:\/\/www.disit.org\/km4city\/resource\/1a250825df03b4a308a4a98a511e39f4","description":"SOCIETA' A RESPONSABILITA' LIMITATA CON UNICO SOCIO - Società di capitale","description2":"","photos":[],"civic":"1","cap":"50100","avgStars":0.0,"province":"FI","wktGeometry":"","starsCount":0,"fax":"","photoThumbs":[],"photoOrigs":[],"email":"","website":"","address":"VIA BRUNELLESCHI","comments":[],"linkDBpedia":[],"multimedia":"","phone":"","name":"STUDIO BALLO E ASSOCIATI S.R.L. IN……………………
 


Example 6: Providing comments, ranks, images, etc.

  • This information is collected into the user profile.
  • Comments provided by users can be accessed ad validated using url: https://servicemap.snap4city.org/WebAppGrafo/comments.jsp (accessible only from intranet)
  • You can access from your account into the VM of the Development Environment:

  • and photos submitted can be validated using url: https://servicemap.snap4city.org/WebAppGrafo/photo.jsp (accessible only from intranet)
  • You can access from your account into the VM of the Development Environment:
    • The Direct insertion for a POI of an image, comment and ranks from one URI, for Web app is possible. While, the direct access to this feature as MicroApplication is not yet available.
       
  1. Managing Mobile Device Behaviour.
    The Smart City API includes a service for providing from the mobile the movements and Sensor Data of the phone: GPS, accelerator sensors, device kind, date and time, velocity, etc. This information is collected into the user profile. This data is currently saved on a Phoenix/HBase table and it is accessible only internally using Apache Zeppelin (see the following figure).
    • To test click on the link to see a live example only in the Florence/Tuscany area by using the Km4City mobile Applications.
    • For Web app and mobile app view: see F1.2.8-ADDITIONAL--produce on demand hints computed on the basis of the user behaviour (Personal Assistant)
    • You can access to your movements log if you have downloaded and installed the mobile app “Firenze dove cosa” and you have accepted the terms of use performing a registration. Once registered you can go on the user profile portal to access at your log and personal data according to the GDPR.
    • The resulting data collected from server side as shown to the city users according to the following view.


 
Activities' timeline of a user behaviour classified by transportation means (draft)