OpenGovIntelligence / json-qb-api-implementation

3 stars 3 forks source link

Updating json response format to match visualization needs #7

Closed mohadelrezk closed 7 years ago

mohadelrezk commented 7 years ago

From @mohadelrezk on December 2, 2016 12:54

our visualization tools expects the following json response (result) format:

path: cubeQueryingAPI/LqbMeta? dsuri=http%3A%2F%2Fogi.eu%2F%23RPBYmunicipality_ds&limit=500)

results:

[{"name":"3","type":"http://purl.org/linked-data/cube#order"},{"name":"http://ogi.eu/#municipality","type":"http://purl.org/linked-data/cube#dimension"},{"name":"6","type":"http://purl.org/linked-data/cube#order"},{"name":"http://ogi.eu/#county","type":"http://purl.org/linked-data/cube#dimension"},{"name":"5","type":"http://purl.org/linked-data/cube#order"},{"name":"http://ogi.eu/#counrty","type":"http://purl.org/linked-data/cube#dimension"},{"name":"4","type":"http://purl.org/linked-data/cube#order"},{"name":"http://ogi.eu/#sex","type":"http://purl.org/linked-data/cube#dimension"},{"name":"1","type":"http://purl.org/linked-data/cube#order"},{"name":"http://ogi.eu/#time_period","type":"http://purl.org/linked-data/cube#dimension"},{"name":"1","type":"http://purl.org/linked-data/cube#order"},{"name":"http://ogi.eu/#resident_population_at_the_beginning_of_the_year_persons","type":"http://purl.org/linked-data/cube#measure"},{"name":"2","type":"http://purl.org/linked-data/cube#order"},{"name":"http://ogi.eu/#age","type":"http://purl.org/linked-data/cube#dimension"}]

path:

cubeQueryingAPI/listdataofLqb?dsuri=http%3A%2F%2Fogi.eu%2F%23IWaveBNetwork30Min_ds&limit=500

results:

[{"SeaTemperature":"","latitude":"54.233932","MeanCurDirTo":"","Time":"2016-08-29T11:00:00Z","PeakPeriod_qc":"0.0","SignificantWaveHeight":"","TimebyYear":"2016","Hmax_qc":"0.0","longitude":"-10.1429","UpcrossPeriod":"","station_id":"Belmullet Wave Buoy Berth B","PeakPeriod":"","UpcrossPeriod_qc":"0.0","SeaTemperature_qc":"0.0","TimebyMonth":"2016-08","THmax":"4.2","THmax_qc":"0.0","PeakDirection":"","TimebyDay":"2016-08-29","MeanCurSpeed":"","SignificantWaveHeight_qc":"0.0","MeanCurSpeed_qc":"0.0","PeakDirection_qc":"0.0","MeanCurDirTo_qc":"0.0","Hmax":"174.0"},{"SeaTemperature":"16.5","latitude":"53.227","MeanCurDirTo":"","Time":"2016-08-30T13:25:00Z","PeakPeriod_qc":"0.0","SignificantWaveHeight":"","TimebyYear":"2016","Hmax_qc":"0.0","longitude":"-9.271","UpcrossPeriod":"","station_id":"Galway Bay Wave Buoy","PeakPeriod":"","UpcrossPeriod_qc":"0.0","SeaTemperature_qc":"0.0","TimebyMonth":"2016-08","THmax":"","THmax_qc":"0.0","PeakDirection":"","TimebyDay":"2016-08-30","MeanCurSpeed":"","SignificantWaveHeight_qc":"0.0","MeanCurSpeed_qc":"0.0","PeakDirection_qc":"0.0","MeanCurDirTo_qc":"0.0","Hmax":""},{"SeaTemperature":"16.55","latitude":"53.227","MeanCurDirTo":"","Time":"2016-08-25T01:45:00Z","PeakPeriod_qc":"0.0","SignificantWaveHeight":"","TimebyYear":"2016","Hmax_qc":"0.0","longitude":"-9.271","UpcrossPeriod":"","station_id":"Galway Bay Wave Buoy","PeakPeriod":"","UpcrossPeriod_qc":"0.0","SeaTemperature_qc":"0.0","TimebyMonth":"2016-08","THmax":"","THmax_qc":"0.0","PeakDirection":"","TimebyDay":"2016-08-25","MeanCurSpeed":"","SignificantWaveHeight_qc":"0.0","MeanCurSpeed_qc":"0.0","PeakDirection_qc":"0.0","MeanCurDirTo_qc":"0.0","Hmax":""}, .....

Example draft for adapting the API to visualization requirements: https://github.com/mohadelrezk/ogi-drafts/blob/master/adaptingJSONAPI.py

Copied from original issue: zeginis/JSON-QB-REST-API#8

mohadelrezk commented 7 years ago

This will ease data analysis components also, as in this format data is more like a csv which is easy to consume by data analysis tools.

zeginis commented 7 years ago

For the first query. There are the @Path("/dimensions") and @Path("/measures") that return the information you need.

For the second query there is the @Path("/slice") that returns all the observations as you need. You can choose to fix some dimensions (e.g. timePeriod=2015) or not An example json respond is below. The json output format is draft and will be changed based on the specification. We could adopt the format you suggest.

[{"observationValues": {"http://id.vlaanderen.be/statistieken/def#aantalappartementen":"438", "http://id.vlaanderen.be/statistieken/def#refArea":"http://id.fedstats.be/nis/02000#id", "http://id.vlaanderen.be/statistieken/def#timePeriod":"http://id.vlaanderen.be/statistieken/concept/jaar_2002#id", "http://id.vlaanderen.be/statistieken/def#verhuringentype":"http://id.vlaanderen.be/statistieken/concept/verhuringtype_andereverhuring#id", "id":"http://opencube-project.eu/observation_8577480426713050916"}}, {"observationValues":{"http://id.vlaanderen.be/statistieken/def#aantalappartementen":"2752", "http://id.vlaanderen.be/statistieken/def#refArea":"http://id.fedstats.be/nis/02000#id", "http://id.vlaanderen.be/statistieken/def#timePeriod":"http://id.vlaanderen.be/statistieken/concept/jaar_2002#id", "http://id.vlaanderen.be/statistieken/def#verhuringentype":"http://id.vlaanderen.be/statistieken/concept/verhuringtype_leegstand#id", "id":"http://opencube-project.eu/observation_747554993538521094"}}, ....]

mohadelrezk commented 7 years ago

/Slice is a good option if we could add the following features: 1- Adding an option to query without defining measures or dimension, just the data-set and limit. 2- Adding an option to retrieve labels of the dimensions and measures, and its values instead of URIs.

zeginis commented 7 years ago

Fixed this issue. /slice get the parameters: