Location service is used to search and retrieve any address related to Airport or landmark information with multiple components like Countrycode, State, City, Postal Code, AddressLine, etc .

This service is created using the WCF framework and can be consumed by a variety of clients.

Location service architecture:

Integration of Location Services- location service  architecture

Location service features are exposed to the clients by means of Location interface. Within the service, this interface is implemented for business rules and parsing/validation in the business layer, which makes a call to database service for handling databases. Database service has been implemented using ADO.Net to communicate with the database and on receiving the data from the database, it will send this data as a response back to the business layer.

If the data is not there in response(as received from database), a request is sent to Google API and the response received by Google API is saved to the database and after parsing and validation, response is sent to the clients, else Google API call is skipped and the response from the database is sent to the clients.

Defining Location service Interface:

public interface ILocationService

   {

        [WsdlDocumentation("Get geocoding information based on the address search text.")]

  [return: WsdlParamOrReturnDocumentation("Returns DataTable containing specified address information.")]

       [OperationContract]

       DataTable GetAddressBySearchText

           (

           [WsdlParamOrReturnDocumentation("Expects search string to find the street address.")]

           string SearchText

           );

   }

Calling database layer methods from business logic:

//Invoking the Data layer service method to get the street address details

DatabaseClient dbClient= new DatabaseClient();
dtSearchBasedAddresses = dbClient.GetAddressBySearchText(SearchText);

//returning the data table containing address details
return dtSearchBasedAddresses;

Example of database layer method

public DataTable GetAddressBySearchText(string SearchText)
{

try
{
//Create Db Connection
Database DBConnection = DBConnectionCertificate.GetDatabase();
using(DbCommand dbCommand= DBConnection.GetStoredProcCommand(Location_Addresses_SP, SearchText))
{
//Execute query.
DataSet dsAddresses = DBConnection.ExecuteDataSet(dbCommand);
return dsAddresses.Tables[0];
}
}
catch (Exception ex)
{

Faults.DataLayerExceptionFault objFault=new Faults.DataLayerExceptionFault(ex.Message.ToString());
throw new FaultException<Faults.DataLayerExceptionFault>(objFault,new FaultReason(ex.Message.ToString()));
}

}

Calling Google API:

1. For calling Google API, developers have to instantiate the URL by providing the expected inputs(like latitude, longitude etc) and Google API key.

var url = String.Format("{0}geocode/xml?latlng={1},{2}&sensor=false&client={3}",
ConfigurationManager.AppSettings["GoogleAPIUrl"], Latitude, Longitude, ConfigurationManager.AppSettings["GoogleClientID"]);

2.Next step is to convert the default base64 encoding in order to implement a URL safe version

url=GGA.Common.Security.GoogleSignedUrl.Sign(url,ConfigurationManager.AppSettings["GoogleSignatureKey"]);

3.Read the response

var geoCodeResponseXml = System.Xml.Linq.XElement.Load(url);
var status = geoCodeResponseXml.Element("status").Value;

Features of Location Service

Addresses

  • Get geocoding information based on the address search text.
  • Get place id for the specified state and/or province for a given code.
  • Get addresses based on search text.
  • Get cities based on state,country or search text.
  • Get latitude and longitude for geocoded addresses.
  • Get addresses based on latitude and longitude.
  • Get a country name based on country code.
  • Get states and provinces based on country code and culture code
  • Address validation
  • Save/Get addresses to/from cache.
  • Get cached addresses based on street,city,state,country and/or postal code.
  • Get Train station addresses based on station code or search text.

Airport/Airline information

  • Get airport addresses information based on airport code or search text.
  • Get airline details based on search text, culture code or airline code.
  • Get recent airports for the specified user.
  • Validation of flight based on airline code and flight number.

Routes

Get travel distance and time for a matrix of origins and destinations.The information returned is based on the recommended route between the start and endpoints, as calculated by the Google Maps API.

Timezone and Phone formats

  • Conversion of the local date/time to universal date/time based on the latitude and longitude.
  • Get phone formats for countries based on culture code.

Advantage of using Location service:

  1. Cost-saving:Location service has been implemented in such a way that for any request, data is first checked in cache or database and sent back as response to the client.Only in cases where data is not available in memory or database, Google API is called.
  1. Performance: As Location service is created using WCF, it is very fast as compared to other ASMX web services.
  1. Location service: It is interoperable and supports a variety of protocols like TCP,https,msmq, etc.

Conclusion

This article explains the architecture of Location service with few examples and provides the details of its features and advantages. This service provides a lot of location-related features and thus is very useful in the applications related to the travel domain. 

Headquarter

4701 Patrick Henry Drive,
Bldg. 16, Suite 106, Santa Clara, California 95054
781-640-0588
sales@neovatechsolutions.com

Development Center

P3-603, Pentagon Tower,
Magarpatta City, Hadapsar, Pune, Maharashtra 411028
960-702-3233