Class Geo2TagRequests

Class Geo2TagRequests is located in the file src/static/js/geo2tag.js.

It has fields server and instance.

Class methods:

1)  getChannels:

  • Parameters: serviceName, callbacksuccess, callbackfail, substring, number, offset
  • Makes the query: /instance/service/serviceName/channel GET with parameters
  • In case of success calls callbacksuccess(result of the query)
  • On failure callbackfail(result of the query) will be called

2) getPoints:

  • Parameters: serviceName, callbacksuccess, callbackfail, channel_ids, number, geometry, altitude_from, altitude_to, substring, date_from, date_to, offset, radius
  • Makes the query:/instance/service/serviceName/point GET with parameters
  • In case of success calls callbacksuccess(result of the query)
  • On failure callbackfail(result of the query) will be called

To create a class object the next code is used:

var test_obj = new Geo2TagRequests('test', 'test');

The examples of script working with Geo2TagRequests:

<script type="text/javascript">
    var callbackSuccess = function (data) {//the declaration of a function that will be called if the guery getPoints or getChannels has been completed successfully
        console.log('Query executed successfully');
    };
    var callbackFail = function (data) {//the declaration of a function that will be called if the guery getPoints or getChannels was failed
        console.log('Query failure'); 
    }; 
    
    var g2t = new Geo2TagRequests('testservice', getInstancePrefix());//creating an instance of the class Geo2TagRequests

 

    g2t.getChannels('testservice', callbackSuccess, callbackFail, 'substring', 4, 5);//call of the method getChannels (in the console the message  'Query executed successfully' should appear)
    
    g2t.getPoints('testservice', callbackSuccess, callbackFail, ["556721a52a2e7febd2744201", "556721a52a2e7febd2744202"], 0, '{"coordinates": [-115.8, 37.2], "type": "Point"}', 22, 5, 'substring', '1970-06-15T18:00:00', '2015-06-15T17:00:00', 0, 5, true, false); //call of the method getPoints (in the console the message 'Query executed successfully' should appear)

</script>

As a result we get two queries:

  1. http://geomongo/instance/service/testservice/channel?substring=substring&number=4&offset=5
  2. http://geomongo/instance/service/testservice/point?channel_ids=556721a52a2e7febd2744201&channel_ids=556721a52a2e7febd2744202&number=0&geometry=%7B%22coordinates%22%3A+%5B-115.8%2C+37.2%5D%2C+%22type%22%3A+%22Point%22%7D&altitude_from=22&altitude_to=5&substring=substring&date_from=1970-06-15T18%3A00%3A00&date_to=2015-06-15T17%3A00%3A00&offset=0&radius=5

This example script illustrates the work of class Geo2TagRequests.

The next parameters are passed to the constructor:

Geo2TagRequests('testservice', getInstancePrefix());

They have text values in order to the URL that we have to follow was available. Function getInstancePrefix in our example returns ‘instance’, in common case: : ‘{{ instance_prefix }}’.

Tests for the methods are located in the file src/static/js/tests/geo2tag_requests_tests.js.

ShareShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on VKEmail this to someone

Leave a Reply

Your email address will not be published. Required fields are marked *