Developer Discussions

Discuss topics with other Hexagon Geospatial Power Portfolio developers and experts to get the most out of our products.
Showing results for 
Search instead for 
Do you mean 
Reply
Highlighted
Frequent Contributor
Posts: 119
Registered: ‎10-13-2015
Accepted Solution

Mobile SDK: Custom search

Hi,

 

I try to use the custom search in the release 15.1.50.

We implement a service that returns features in multiple CRS.

For example in this case EPSG:25831.

Exist some parameter in the geometry element to specify the coordinate system?

The callback function apply the transformation to the current map coordinate system if is necesary or we need to apply the transformation in the service?

 

Example:

 

geometry: {
      coordinates: [450658,47895566],
      type: "Point"
   },
   id: 1,
   properties: {
     name: "Barcelona",
     type: "Walker",
     location: "street",
     direction: "Nort"
   }
}]

 

function customSearchZombieHandle(query) {
   var upperCaseQuery = query.toUpperCase();

   return function(callback, errback) {
     var results = [];
     var zombieName = null;
     for (i in zombies) {
         zombieName = zombies[i].properties.name.toUpperCase()
         if (zombieName.indexOf(upperCaseQuery) > -1) {
         results.push(zombies[i])
     }
    }; 
    callback({ "results": results });
    return;
   };
}

Highlighted
Technical Evangelist
Posts: 184
Registered: ‎07-30-2015

Re: Mobile SDK: Custom search

As you said the callback function expects the geometry in current display crs. Your callback implementation should guarantee it.

How can it be achieved?

 

  1. (Recommended) the service returns data in the display crs. It minimizes the number for crs transformation on the client, which is good form the performance point of view.
  2. You do the transformation in your callback. Please take a look at $GP.crs module. There are 2 methods there: getCurrent and transform. You should put into the configuration file definitions of all the coordinate systems you plan to use. In your callback perform the necessary transformations

There are also some examples available Examples. Coordinate system section.