Package globus.glsearch
Class GLSearch
java.lang.Object
globus.glmap.GLNativeObject
globus.glsearch.GLSearch
GLSearchOffline
contains a set of parameters that defines search in offline maps-
Nested Class Summary
Modifier and TypeClassDescriptionstatic @interface
Style of addressstatic interface
Callbacks for custom objectsstatic @interface
Match typestatic interface
Callback that provides information for custom objects for search.static @interface
Predefined set of tags -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addFilter
(GLSearchFilter filter) Adds filter to search.void
cancel()
Cancels search operation.static int
Compare to string with collatorstatic long
Creates ICU collator with strength set to Primary.static long
Creates ICU collator with strength set to Primary and numeric collation is ON.static void
DestroyCollator
(long collator) Destroy collatorstatic void
DestroyWords
(long words) Destroy native object returned by GLSearch#PrepareWords(long, String[]).static GLMapValue
Split string into words.static GLMapValue
GetAddress
(GLMapVectorObject object, int style, GLMapLocaleSettings localeSettings) Returns address with given stylestatic GLSearchCategory
GetSearchCategory
(GLMapVectorObject object) Detects category for vector objectstatic void
Initialize
(android.content.Context context) Call this method before using any other method from `globus.glsearch`static GLMapVectorObject
LoadMergedRelationLines
(GLMapRelation relation, boolean isForward, GLMapInfo map) Load all lines from relation in onestatic GLMapValue[]
LocalizedAddressNames
(GLMapVectorObject object, GLMapLocaleSettings localeSettings) Returns all address names associated with objectstatic GLMapVectorObject
MapObjectNearPoint
(GLMapViewRenderer mapView, MapPoint point, double maxDistance) Returns object near point on mapstatic android.util.SparseArray<GLMapValue>
MatchedCategoryTags
(GLMapVectorObject object) Return array of tags that defines object's categoryObject[]
merge
(GLMapVectorObjectList searchResults, List<Object> customObjects, GLSearch.CustomObjectInfoCallback infoCallback) Merge search results with custom objectsstatic GLMapVectorObject
Nearest
(double lat, double lon, double maxDist, List<GLSearchFilter> filters) Search for nearest objectstatic long
PrepareWords
(long collator, String[] words) Prepares words for collationstatic GLMapRelation[]
RelationsNearPoint
(GLMapViewRenderer mapView, MapPoint point, double maxDistance, GLSearchFilter[] filters) Search for relations near point on mapsearch()
Performs search synchronouslyvoid
searchAsync
(GLSearch.ResultsCallback callback) Starts search.void
Sets bounding box where search will be performedvoid
Sets center of search.void
setLimit
(int limit) Sets maximum number of results to fetch from mapvoid
setLocaleSettings
(GLMapLocaleSettings localeSettings) Sets locale settings that used to sort results by importance.void
setNeedEnclosingAreas
(boolean needEnclosingAreas) Set this value to `YES` if you plan to get address of objects.void
setObjectTypes
(int objectTypes) Set object typesvoid
setTiles
(long[] tiles) Adds tile hashes to use for search (child tiles will be skipped)static String[]
SplitByWords
(String string) Split string into words using ICU root rulesMethods inherited from class globus.glmap.GLNativeObject
dispose
-
Constructor Details
-
GLSearch
public GLSearch()Default constructor
-
-
Method Details
-
Initialize
public static void Initialize(@NonNull android.content.Context context) Call this method before using any other method from `globus.glsearch`- Parameters:
context
- context needed to load icu and categories data
-
MapObjectNearPoint
public static GLMapVectorObject MapObjectNearPoint(@NonNull GLMapViewRenderer mapView, @NonNull MapPoint point, double maxDistance) Returns object near point on map- Parameters:
mapView
- Map viewpoint
- Point on mapmaxDistance
- Distance in points- Returns:
- Vector object on map
-
RelationsNearPoint
public static GLMapRelation[] RelationsNearPoint(@NonNull GLMapViewRenderer mapView, @NonNull MapPoint point, double maxDistance, @Nullable GLSearchFilter[] filters) Search for relations near point on map- Parameters:
mapView
- Map viewpoint
- Point on mapmaxDistance
- Distance in pointsfilters
- Filters for relations- Returns:
- relations near point
-
LoadMergedRelationLines
@Nullable public static GLMapVectorObject LoadMergedRelationLines(GLMapRelation relation, boolean isForward, @Nullable GLMapInfo map) Load all lines from relation in one- Parameters:
relation
- relation to loadisForward
- true for forward route, false for backward routemap
- map from where to load relation. if null - will load from random map- Returns:
- vector object with multiline
-
GetSearchCategory
Detects category for vector object- Parameters:
object
- Vector object- Returns:
- Category that matches to object
-
MatchedCategoryTags
@Nullable public static android.util.SparseArray<GLMapValue> MatchedCategoryTags(@NonNull GLMapVectorObject object) Return array of tags that defines object's category- Parameters:
object
- vector object- Returns:
- array of tags that defines object's category
-
GetAddress
@Nullable public static GLMapValue GetAddress(@NonNull GLMapVectorObject object, int style, @NonNull GLMapLocaleSettings localeSettings) Returns address with given style- Parameters:
object
- vector objectstyle
- style of addresslocaleSettings
- locale settings- Returns:
- address formatted with given style
-
LocalizedAddressNames
@Nullable public static GLMapValue[] LocalizedAddressNames(@NonNull GLMapVectorObject object, @NonNull GLMapLocaleSettings localeSettings) Returns all address names associated with object- Parameters:
object
- vector objectlocaleSettings
- Locale settings used to find name- Returns:
- array of address names
-
SplitByWords
Split string into words using ICU root rules- Parameters:
string
- string to split into words- Returns:
- words from string
-
PrepareWords
Prepares words for collation- Parameters:
collator
- collator that will be used in collationwords
- words to prepare- Returns:
- native object. Must be destroyed when not needed.
-
DestroyWords
public static void DestroyWords(long words) Destroy native object returned by GLSearch#PrepareWords(long, String[]).- Parameters:
words
- native object
-
FindWords
Split string into words. Then checks if all prepared words are equal to start of any word in string- Parameters:
collator
- collator to usestring
- string where prepared words will be checkedwords
- prepared words- Returns:
- value that contains same string, but with highlight information. Null if not all prepared words are in string
-
CreateCollator
public static long CreateCollator()Creates ICU collator with strength set to Primary. For example "Straße" equal to "sTrassE" with this collator- Returns:
- native collator object. Must be destroyed when not needed.
-
CreateNumericCollator
public static long CreateNumericCollator()Creates ICU collator with strength set to Primary and numeric collation is ON. For example "Straße 10" greater "sTrassE 2" with this collator- Returns:
- native collator object. Must be destroyed when not needed.
-
DestroyCollator
public static void DestroyCollator(long collator) Destroy collator- Parameters:
collator
- native collator object
-
Collate
Compare to string with collator- Parameters:
collator
- collator to usea
- the first object to be compared.b
- the second object to be compared.- Returns:
- a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
-
Nearest
@Nullable public static GLMapVectorObject Nearest(double lat, double lon, double maxDist, @Nullable List<GLSearchFilter> filters) Search for nearest object- Parameters:
lat
- latitudelon
- longitudemaxDist
- max search distance in metersfilters
- search filters- Returns:
- nearest object or null
-
setTiles
public void setTiles(@NonNull long[] tiles) Adds tile hashes to use for search (child tiles will be skipped)- Parameters:
tiles
- Array of tile hashes public native void setTiles(long tiles[]);
-
setLocaleSettings
Sets locale settings that used to sort results by importance. Results in user language displayed on top.- Parameters:
localeSettings
- Language priority settings.
-
setLimit
public void setLimit(int limit) Sets maximum number of results to fetch from map- Parameters:
limit
- Results limit
-
setBBox
Sets bounding box where search will be performed- Parameters:
bbox
- Search bounding box.
-
setCenter
Sets center of search. Distance from this center will define importance of object. Usually center is user location or center of the screen.- Parameters:
center
- Center point.
-
addFilter
Adds filter to search. Result of search will contain objects that matches all filters- Parameters:
filter
- filter to add.
-
setNeedEnclosingAreas
public void setNeedEnclosingAreas(boolean needEnclosingAreas) Set this value to `YES` if you plan to get address of objects. Loading address after search is much faster (cache reuse, bulk loading)- Parameters:
needEnclosingAreas
- if `YES` search will load enclosing areas.
-
setObjectTypes
public void setObjectTypes(int objectTypes) Set object types- Parameters:
objectTypes
- object types
-
searchAsync
Starts search.- Parameters:
callback
- will be called when search is finished or when search needs information about custom object.
-
search
Performs search synchronously- Returns:
- result of search
-
merge
public Object[] merge(@NonNull GLMapVectorObjectList searchResults, @NonNull List<Object> customObjects, @NonNull GLSearch.CustomObjectInfoCallback infoCallback) Merge search results with custom objects- Parameters:
searchResults
- search resultscustomObjects
- custom objectsinfoCallback
- callback that will provide information about object- Returns:
- merged array
-
cancel
public void cancel()Cancels search operation.
-