Skip to content
Rahul Chauhan edited this page Jul 12, 2018 · 10 revisions

Welcome to the Support-of-Unit-Of-Measure-conversion-in-istSOS3 wiki!

Using PostgreSQL_unit

  1. Clone this Repo. git clone https://github.com/ChristophBerg/postgresql-unit.git

  2. cd postgresql-unit

  3. Change postgresql-server-dev-(10, 9.5 etc.) according to your installation configuration sudo apt-get install build-essential postgresql-server-dev-10 flex bison make PG_CONFIG=/usr/lib/postgresql/10/bin/pg_config sudo make install PG_CONFIG=/usr/lib/postgresql/10/bin/pg_config

  4. For more detail postgresql-unit https://github.com/ChristophBerg/postgresql-unit.

  5. Clone istsos3 testing repo. git clone https://github.com/rahulworld/Support-of-Unit-Of-Measure-conversion-in-istSOS3

  6. Install istsos3 Using main repo. documentation https://github.com/rahulworld/istsos3/blob/master/README.md .

  7. cd istsos3

  8. Start server using python examples/server_tornado.py

  9. Install Postman for Post request easily https://www.getpostman.com/.

  10. listen at http://localhost:8887/rest in Postman.

  11. Insert sensor with one observable property sensor in istsos3 using http://istsos.org/en/v3.0.0-Beta/index.html OR

    "action": "CREATE_SENSOR",
    "data": {
        "name": "belin",
        "fixed": true,
        "procedure": "belin",
        "procedure_description_format": ["http://www.opengis.net/sensorML/1.0.1"],
        "observable_properties": [
            {
                "name": "temperature",
                "definition": "urn:ogc:def:parameter:x-istsos:1.0:temperature",
                "uom": "°C",
                "type": "http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Measurement"
            }
        ],
        "observation_types": [
            "http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Measurement"
        ],
        "foi_type": "http://www.opengis.net/def/samplingFeatureType/OGC-OM/2.0/SF_SamplingPoint",
        "sampled_foi": {
            "identifier": "belin_foi",
            "name": "belin_foi",
            "type": "http://www.opengis.net/def/samplingFeatureType/OGC-OM/2.0/SF_SamplingPoint",
            "shape": {
                "type": "Point",
                "coordinates": [
                    0.0,
                    0.0,
                    0.0
                ]
            }
        }
    }
}
Insert Observation any valid data like bellinzona with one observable property
    "action": "INSERT_OBSERVATIONS",
    "data": [{
        "offering": "belin",
        "procedure": "belin",
        "type": "http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Measurement",
        "featureOfInterest": {
            "href": "beline_foi"
        },
        "phenomenonTime": {
            "timeInstant": {
                "instant": "2003-08-05T00:00:00+02:00"
            }
        },
        "resultTime": {
            "timeInstant": {
                "instant": "2003-08-05T00:00:00+02:00"
            }
        },
        "result": 28.3,
        "observedProperty": {
            "name": "temperature",
            "def": "urn:ogc:def:parameter:x-istsos:1.0:temperature",
            "uom": "°C",
            "type": "http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Measurement"
        }
    }]
}
  1. Fetch Observation of any offering from istsos3 and change in_unit variable according to specific unit below script
    "action": "UNIT_CONVERSION_USING_POSTGRESQL_UNIT",
    "data": {
        "offerings": ["belin","belin"],
        "observedProperties": [
            "urn:ogc:def:parameter:x-istsos:1.0:temperature"
        ],
        "temporal": {
            "reference": "om:phenomenonTime",
            "fes": "during",
            "period": [
                "2015-05-03T16:30:00.000000+0200",
                "2015-06-03T16:30:00.000000+0200"
            ]
        },
        "responseFormat": "application/json;subtype='array'"
    },
    "in_unit":"°F"
}

###Take Data as array, array2, vega and default data format as user specific unit after change subtype above script.

Using Pint

###Cons It is not good for unit conversion it takes lot of time. It is not extensible for user can't understand istsos units like °C unlike in postgresql-unit and gave error when we convert data from degC from degF in istsos3. It has ambiguity. It Can't convert unit of data without user's knowledge of pint libraries in istsos3.

###Work

  1. In this we also give value of from_unit obeservable property uom according to pint like °F as degF.
  2. also give value of user specific unit to_unit like °K as degK.
  3. It gave error unit conversion like °C as degC to any other temperature unit.

Use this post script for pint only for array type data.

    "action": "UNIT_CONVERSION_USING_POSTGRESQL_UNIT",
    "data": {
        "offerings": ["belin","belin"],
        "observedProperties": [
            "urn:ogc:def:parameter:x-istsos:1.0:temperature"
        ],
        "temporal": {
            "reference": "om:phenomenonTime",
            "fes": "during",
            "period": [
                "2015-05-03T16:30:00.000000+0200",
                "2015-06-03T16:30:00.000000+0200"
            ]
        },
        "responseFormat": "application/json;subtype='array'"
    },
    "from_unit":"degF"
    "to_unit":"degK"
}

Clone this wiki locally