libosmscout  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups
osmscout::LocationService Class Reference

The LocationService offers a number of methods for location lookup ( search for a certain location by its name) and location reverse lookup (retrieve the name of a location). More...

#include <LocationService.h>

Classes

struct  ReverseLookupResult
 Result of a location reverse lookup. More...
 

Public Member Functions

bool DescribeLocation (const GeoCoord &location, LocationDescription &description, const double lookupDistance=100, const double sizeFilter=1.0)
 
bool DescribeLocationByAddress (const GeoCoord &location, LocationDescription &description, const double lookupDistance=100, const double sizeFilter=1.0)
 
bool DescribeLocationByCrossing (const GeoCoord &location, LocationDescription &description, const double lookupDistance=100)
 Returns crossings (of roads that can be driven by cars and which have a name feature) More...
 
bool DescribeLocationByName (const GeoCoord &location, LocationDescription &description, const double lookupDistance=100, const double sizeFilter=1.0)
 
bool DescribeLocationByPOI (const GeoCoord &location, LocationDescription &description, const double lookupDistance=100, const double sizeFilter=1.0)
 
bool InitializeLocationSearchEntries (const std::string &searchPattern, LocationSearch &search)
 This takes the given pattern, splits it into tokens, and generates a number of search entries based on the idea that the input follows one of the following patterns: More...
 
bool LoadNearAreas (const GeoCoord &location, const TypeInfoSet &types, std::vector< LocationDescriptionCandicate > &candidates, const double maxDistance=100)
 Load areas of given types near to location. More...
 
bool LoadNearNodes (const GeoCoord &location, const TypeInfoSet &types, std::vector< LocationDescriptionCandicate > &candidates, const double maxDistance=100)
 
bool LoadNearWays (const GeoCoord &location, const TypeInfoSet &types, std::vector< WayRef > &candidates, const double maxDistance=100)
 
 LocationService (const DatabaseRef &database)
 LocationService constructor. More...
 
bool ResolveAdminRegionHierachie (const AdminRegionRef &adminRegion, std::map< FileOffset, AdminRegionRef > &refs) const
 Resolve all parent regions of the given region (walk the region tree up to the root)Use AdminRegion::regionOffset and AdminRegion::parentRegionOffset to build the tree. More...
 
bool ReverseLookupObject (const ObjectFileRef &object, std::list< ReverseLookupResult > &result) const
 Lookup one object. More...
 
bool ReverseLookupObjects (const std::list< ObjectFileRef > &objects, std::list< ReverseLookupResult > &result) const
 Lookups location descriptions for the given objects. More...
 
bool SearchForLocations (const LocationSearch &search, LocationSearchResult &result) const
 Search for the given location patterns. More...
 
bool VisitAdminRegionLocations (const AdminRegion &region, const PostalArea &postalArea, LocationVisitor &visitor) const
 Visit the location at the given region and all its sub regions. More...
 
bool VisitAdminRegionPOIs (const AdminRegion &region, POIVisitor &visitor) const
 Visit the POIs at the given region and all its sub regions. More...
 
bool VisitAdminRegions (AdminRegionVisitor &visitor) const
 Call the given visitor for each region in the index (deep first) More...
 
bool VisitLocationAddresses (const AdminRegion &region, const PostalArea &postalArea, const Location &location, AddressVisitor &visitor) const
 Visit all addresses at the given location. More...
 

Detailed Description

The LocationService offers a number of methods for location lookup ( search for a certain location by its name) and location reverse lookup (retrieve the name of a location).

The support different type of requests for different interfaces the visitor pattern is used.

Currently the following functionalities are supported:

  • Visit all region (recursivly)
  • Visit all locations of a region and (optionally) all locations of all sub regions.
  • Visit all addresses of a location (non recursive)
  • Resolve all parent regions for a given region
  • General interface for location lookup, offering default visitors for the individual index traversals.
  • Retrieve the addresses of one or more objects.

Constructor & Destructor Documentation

osmscout::LocationService::LocationService ( const DatabaseRef database)

LocationService constructor.

Parameters
databaseValid reference to a database instance

Member Function Documentation

bool osmscout::LocationService::DescribeLocation ( const GeoCoord &  location,
LocationDescription description,
const double  lookupDistance = 100,
const double  sizeFilter = 1.0 
)
bool osmscout::LocationService::DescribeLocationByAddress ( const GeoCoord &  location,
LocationDescription description,
const double  lookupDistance = 100,
const double  sizeFilter = 1.0 
)
bool osmscout::LocationService::DescribeLocationByCrossing ( const GeoCoord &  location,
LocationDescription description,
const double  lookupDistance = 100 
)

Returns crossings (of roads that can be driven by cars and which have a name feature)

Parameters
locationLocation to search for the closest crossing
descriptionThe description returned
lookupDistanceThe range to look in
Returns

References osmscout::GetEllipsoidalDistance(), osmscout::FeatureLabelReader< F, V >::GetLabel(), osmscout::GetSphericalBearingInitial(), LoadNearWays(), osmscout::NameFeature::NAME, ReverseLookupObject(), and osmscout::LocationDescription::SetCrossingDescription().

Referenced by DescribeLocation().

bool osmscout::LocationService::DescribeLocationByName ( const GeoCoord &  location,
LocationDescription description,
const double  lookupDistance = 100,
const double  sizeFilter = 1.0 
)
bool osmscout::LocationService::DescribeLocationByPOI ( const GeoCoord &  location,
LocationDescription description,
const double  lookupDistance = 100,
const double  sizeFilter = 1.0 
)
bool osmscout::LocationService::InitializeLocationSearchEntries ( const std::string &  searchPattern,
LocationSearch locationSearch 
)
bool osmscout::LocationService::LoadNearAreas ( const GeoCoord &  location,
const TypeInfoSet &  types,
std::vector< LocationDescriptionCandicate > &  candidates,
const double  maxDistance = 100 
)

Load areas of given types near to location.

Parameters
location
types
candidates- unsorted result buffer
maxDistance- lookup distance in meters
Returns
true if no error (it don't indicate non-empty result)

References osmscout::CalculateDistancePointToLineSegment(), osmscout::Log::Debug(), osmscout::GetEllipsoidalDistance(), osmscout::FeatureLabelReader< F, V >::GetLabel(), osmscout::GetSphericalBearingInitial(), osmscout::IsCoordInArea(), osmscout::log, and osmscout::refArea.

Referenced by DescribeLocationByAddress(), DescribeLocationByName(), and DescribeLocationByPOI().

bool osmscout::LocationService::LoadNearNodes ( const GeoCoord &  location,
const TypeInfoSet &  types,
std::vector< LocationDescriptionCandicate > &  candidates,
const double  maxDistance = 100 
)
bool osmscout::LocationService::LoadNearWays ( const GeoCoord &  location,
const TypeInfoSet &  types,
std::vector< WayRef > &  candidates,
const double  maxDistance = 100 
)
bool osmscout::LocationService::ResolveAdminRegionHierachie ( const AdminRegionRef adminRegion,
std::map< FileOffset, AdminRegionRef > &  refs 
) const

Resolve all parent regions of the given region (walk the region tree up to the root)Use AdminRegion::regionOffset and AdminRegion::parentRegionOffset to build the tree.

Parameters
adminRegionThe region to start at
refsA map of all parent regions
Returns
True, if there was no error

Referenced by SearchForLocations().

bool osmscout::LocationService::ReverseLookupObject ( const ObjectFileRef &  object,
std::list< ReverseLookupResult > &  result 
) const

Lookup one object.

Parameters
objectThe object to lookup
resultList of results. The list may hold none, one or more entries for the object
Returns
True, if there was no error

References ReverseLookupObjects().

Referenced by DescribeLocationByAddress(), DescribeLocationByCrossing(), DescribeLocationByName(), and DescribeLocationByPOI().

bool osmscout::LocationService::ReverseLookupObjects ( const std::list< ObjectFileRef > &  objects,
std::list< ReverseLookupResult > &  result 
) const

Lookups location descriptions for the given objects.

Parameters
objectsList of objects
resultList of results. The list may hold none, one or more entries for each object.
Returns
True, if there was no error

References osmscout::refArea, osmscout::refNode, osmscout::refWay, and VisitAdminRegions().

Referenced by ReverseLookupObject().

bool osmscout::LocationService::SearchForLocations ( const LocationSearch search,
LocationSearchResult result 
) const

Search for the given location patterns.

Parameters
searchData structure holding the search requests
resultData structure holding the search result
Returns
True, if there was no error

References osmscout::LocationService::AdminRegionMatchVisitor::AdminRegionResult::adminRegion, osmscout::Log::Error(), osmscout::LocationSearch::limit, osmscout::LocationSearchResult::limitReached, osmscout::log, ResolveAdminRegionHierachie(), osmscout::LocationSearchResult::results, osmscout::LocationSearch::searches, and VisitAdminRegions().

bool osmscout::LocationService::VisitAdminRegionLocations ( const AdminRegion region,
const PostalArea postalArea,
LocationVisitor visitor 
) const

Visit the location at the given region and all its sub regions.

Parameters
regionRegion to start at
visitorVisitor
Returns
True, if there was no error
bool osmscout::LocationService::VisitAdminRegionPOIs ( const AdminRegion region,
POIVisitor visitor 
) const

Visit the POIs at the given region and all its sub regions.

Parameters
regionRegion to start at
visitorVisitor
Returns
True, if there was no error
bool osmscout::LocationService::VisitAdminRegions ( AdminRegionVisitor visitor) const

Call the given visitor for each region in the index (deep first)

Parameters
visitorThe visitor
Returns
True if the traversal finished and the visitor did not signal an error, else false

Referenced by ReverseLookupObjects(), and SearchForLocations().

bool osmscout::LocationService::VisitLocationAddresses ( const AdminRegion region,
const PostalArea postalArea,
const Location location,
AddressVisitor visitor 
) const

Visit all addresses at the given location.

Parameters
regionRegion the location belongs to
locationThe location itself
visitorThe Visitor
Returns
True, if there was no error

The documentation for this class was generated from the following files: