It's an SCN World on the SAP HANA Cloud Platform
Background
My blog is a follow up to the ideas I covered in my SAP HANA Cloud Portal movie challenge entry. That post was about ideas to use SAPHCP as a platform to share maps and site statistics about SCN.
I have followed up and implemented a demo of the “Where in the world are you?” ideas in that blog using the HCP. I will use my HCP demo site as an entry to the Data Genius challange. The idea being that you, dear reader, will be prepared to share your location on my map and then see other SCN users on the overall map. As part of the overall map I have added two SAP events (2015 Techeds for Las Vegas and Barcelona) and use an HCP XS service to determine which event is closer to the selected SCN member on the map. And finally I have also used the spatial capabilities of the SAPHCP platform to map SDN points totals from 2004 to 2010.
So onto the details of my SAPHCP demo site and how to use it. I will keep the site active until the end of the Data Genius competition which is due to end in December 2015 and hopefully you have registered your location by that time :).
Main Page Tiles
The main page of my site is at the following link
https://s5hanaxs.hanatrial.ondemand.com/p1248461150trial/hihanaxs/neogeoxs/
Tile One
is to submit (or subsequently used to update) your location to the SCN map.
To locate any user then the process relies on a modern browsers geo-location functionality. Therefore to use the service you must be prepared to share your location via any prompts from the browser.
Click on the first tile
When the page loads then you need to agree to share your location. E.g. the Firefox browser’s prompt may look like the following screenshot.
Select the “Share Location” ( agree to share the location on any other modern browser ).
If the following screen remains for more than a few minutes then please check you have the location services active and running. There are a few links in the page for various browsers/platforms location services. If you need to activate the location service then please reload the page.
The above screen should automatically be replaced by the following location screen after a short wait.
Step 1
Move the marker to a position you would want to register your location on the map. E.g. you may not want the position that is automatically chosen by the browser. The marker can be dragged to any location - I would prefer it still to be in the general area and not another country for example
Step 2
Enter twitter id (with the @ e.g. @rjruss). You do not need to enter a twitter id, a name/nickname can be entered but for the twitter feature to work in the overall map then only enter the twitter id and it must start with the @ character.
Step 3
Select the submit/update your location button.
Confirmation of the update
Once the submit button is entered then a prompt should confirm success
That’s the end of the first phase.
Tile Two
click on the middle/second tile
The following screen should appear
Using the map zoom icons (+/-) move and zoom in on the map to your location (you should see a borrowed SCN icon in your general area) and click on the icon. Following the twitter link in the popup should display the twitter profile page as below.
SAP Event Locations
As part of the map I have added two SAP events, those being the Techeds this year in Las Vegas and Barcelona (I have used the general location of each event from the SAP Teched pages for both events). The following screenshot is the default location for the Barcelona Teched.
When I select Tammy Powlas’s location on my map (I’ll cover Tammy’s involvement in testing my site later but thanks Tammy :)) then there is a call to an XS service to determine which SAP event is closer to Tammy.
The SCN rocket icon as moved to Las Vegas as the closest event and there is a detail popup for the events registered on my site.
If you have an SCN/SAP event that I can add to the map then that would be great, just let me know the location and I will add it to the map.
3d Globe View
A 3d globe view of the world is available if you have a compatible computer and browser that works with WebGL. Select the “Enable/Disable ol3-cesium” button to swap between the 2d and 3d maps. The popups and twitter links do NOT work in the globe view.
Final Tile
The last tile is a link to my SDN points data set in the SAP HCP cloud. This is using the data and spatial capabilities of the SAPHCP. The following screen is the initial 2004 data.
I used my own ESRI Shapefile for the SDN points data from 2004 to 2010 , using data collected via my ABAP code I shared in my blog here. Here is a link to a video about the country that inspired me to get into maps (and thematic maps ) again, I have shared it previously here and yet again here so I must like that video
Originally I had thought about using the Google Earth API as per the method I used from my original blog. However Google had already announced the depreciation of Google Earth API. So I took a look around for another globe and found the Javascript/ WebGL based Cesium project. Also as I was familiar with Openlayers mapping library I was able to create a map with Openlayers and visualise it with Cesium via the following library http://openlayers.org/ol3-cesium/
Back to the options on the page
The dropdown box can select the year and the “update map” button has to be selected to load the data.
Selecting the “Enable/Disable ol3-cesium” button again will show a 3d globe view. Changing the year and updating the map while it is in 3d mode will NOT work and will most likely need a refresh of the entire page to restore the settings. Only updating the year in 2d mode will work.
Site Details
Thank you
When I created the SCN location map I was interested in people checking the service from other countries. As I have been thankful for their help previously I contacted Tammy Powlas and Sergio Ferrari to test out the site. Tammy replied and was able to help out and test. Sergio kindly took time and replied during his holiday and was not able to test at the time of asking. Thank you both once again. Some of the above screenshots were taken after Tammy had tested the site.
Also other SCN members I would like to thank as their information on SCN allowed me to complete my demo site.
First a thank you again to Stoyan Manchev for his blog on XS applications on the HCP. His blog is one I would like to mark higher than 5 stars as it was my reference for all other activities in putting together my demo XS application.
8 Easy Steps to Develop an XS application on the SAP HANA Cloud Platform
Louenas Hamdi’s blog on build a basic REST service
Get started on HANA Cloud Platform (HCP) XS development: build a basic REST service
Trinoy Hazarika’s blog for geo spatial HANA information that made me realise I could achieve what I wanted with the geo-spatial features of HANA and I tried the approach with the HCP.
Experiences with SAP HANA Geo-Spatial Features – Part 2
Kevin Small’s blog for the geojson information
Visualising BW Query Usage Statistics on a Globe using HANA, XSJS, SAPUI5 & D3
Henrique Pinto’s post about using a GET method to update a HANA database.
http://scn.sap.com/docs/DOC-33902
Thomas Jung’s blog about various HANA developer tools. I took the information about the UPSERT command. Also thanks to Thomas’s for other general HANA blogs and also I read about preventing potential SQL injection methods by using prepared SQL statements from his comment linked below.
http://scn.sap.com/docs/DOC-33902#comment-331203
References to Sites used for the Maps
The way I use these tools can be seen in the source code for the web page. So if you are interested follow the url to see how I use these libraries/tools.
Nearest SAP event
I adapted an answer to this stackoverflow SQL question for my HANA XS service to identify which SAP event would be closest to the selected user.
http://stackoverflow.com/questions/574691/mysql-great-circle-distance-haversine-formula
https://developers.google.com/maps/articles/phpsqlsearch_v3
Uploading a Shapefile to the SAPHCP
The eclipse HANA tools allow uploading ESRI Shapefiles to the SAPHCP from a local computer. The following screenshots allowed me to upload my previously created shapefile for the SDN points data from 2004-10. Using Trinoy’s and Kevin’s blogs referenced earlier I was able to turn these into XS geojson services. Combining that with Stoyen’s base blog about allowing HANA views to be setup for use with an XS service. I did find I had to create a pure HANA dimension calculation view as this was only allowed with spatial data types. I do load over 1.6mb of geojson to map each years data, a next step for me is to separate the spatial data from the actual points data as this would improve the load times and creation of the map.
In the next screen, select your system and the next screen would be to import from the current client
The name of the shapefile and table is then displayed and then choose your schema in the next screen.
Screenshot below of the calculation view I use on my site.
Public SAPID based XS Service
As I wanted to allow all SAP HCP trial users to use my service I thought about registering over 2 million accounts in my access model file ;). Then I thought again and read the help and used the following method to allow my services to be used by all end user accounts.
https://help.hana.ondemand.com/help/frameset.htm?2cb80530a7a748f792050730782f9bef.html
“HCP_GRANT_TO_PUBLIC_ROLE(role_name NVARCHAR(256)) - you use this procedure to grant an activated hdbrole to theHCP_PUBLIC role. HCP_PUBLIC role is granted to all end users by default. For the trial landscape, the end user name is their C, D, P, S, or Iuser.”
In my XS service to update the location table I use the $.session.getUsername() command to get the user id and hash this to mask the actual value. More details of how I do that next.
SAP ID Service
I use the SAP ID default account to identify individual users for the map. As the trial SAP HCP uses this as a default authentication method then it is a good way to identify users. If I only share the link on SCN then there is a very good chance I only get registered SCN users on my map.
Masking the SAP ID user id
As I didn’t want to store your SAP ID user account in my trial account HANA database (have you registered your location yet ) , I have used the SHA256 HASH function as a mask. This way if I concat the SAP ID and a known random string I can mask your ID. E.g. for example and not the actual random text I use to hash the user ID.
SELECT HASH_SHA256(to_binary('" + SAPIDUserName + "'), to_binary('Some Random Text')) HASH FROM DUMMY
This would generate the following value that I would store in my HCP site and this combination means I do not know the user id of any user on my map.
Timeout
There is a timeout SAML issue for the site and after some time there will be an error due to a timeout of authentication. The issue “Assertion did not contain a valid MessageID” is discussed here http://scn.sap.com/docs/DOC-50418 for SAML based XS services. I did attempt to capture the error (and other potential errors) by following the jquery jqXHR method discussed here. My adapted code looks for any status errors and force reloads the page. This will then re-authenticate and allow the process to complete. You can always reload the page if it appears that nothing is updating after a period of inactivity on my site.
Thanks for reading and registering your location on my map
.