Package globus.glsearch
Class GLSearch
java.lang.Object
globus.glmap.GLNativeObject
globus.glsearch.GLSearch
- All Implemented Interfaces:
AutoCloseable
public class GLSearch
extends globus.glmap.GLNativeObject
Offline search APIs for objects stored in downloaded maps.
GLSearch can be used as a static utility (for example, "near point" queries) or as a
configurable search rule that you build and execute via search() / searchAsync(ResultsCallback).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfaceStyle of addressstatic interfaceCallbacks for custom objectsstatic @interfaceMatch typestatic interfaceCallback that provides information for custom objects for search.static @interfacePredefined set of tags -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFilter(GLSearchFilter filter) Adds filter to search.voidcancel()Cancels asynchronous search operations started for thisGLSearchinstance.static intCompare to string with collatorstatic longCreates ICU collator with strength set to Primary.static longCreates ICU collator with strength set to Primary and numeric collation is ON.static voidDestroyCollator(long collator) Destroys a collator handle created byCreateCollator()orCreateNumericCollator().static voidDestroyWords(long words) Destroy native object returned by GLSearch#PrepareWords(long, String[]).static voidFillSearchCategory(globus.glmap.GLMapVectorObjectList objects) Detects categories for the provided vector objects (in-place).static globus.glmap.GLMapValueSplit string into words.static globus.glmap.GLMapValueGetAddress(globus.glmap.GLMapVectorObject object, int style, globus.glmap.GLMapLocaleSettings localeSettings) Formats an address string for the given object.static GLSearchDisplayInfoGetDisplayInfo(globus.glmap.GLMapVectorObject object, globus.glmap.GLMapLocaleSettings localeSettings) Builds display data (title, secondary line, types, category) for a search result row.static GLSearchCategoryGetSearchCategory(globus.glmap.GLMapVectorObject object) Detects category for a vector object.static voidInitialize(android.content.Context context) Deprecated.static globus.glmap.GLMapVectorObjectLoadMergedRelationLines(globus.glmap.GLMapRelation relation, boolean isForward, globus.glmap.GLMapInfo map) Loads all line members from a relation and merges them into a multiline object.static globus.glmap.GLMapValue[]LocalizedAddressNames(globus.glmap.GLMapVectorObject object, globus.glmap.GLMapLocaleSettings localeSettings) Returns all localized address names associated with the object.static globus.glmap.GLMapVectorObjectMapObjectNearPoint(globus.glmap.GLMapViewState state, float screenX, float screenY, double maxDistance) Returns the offline map object associated with a visible POI label in a captured state.static android.util.SparseArray<globus.glmap.GLMapValue>MatchedCategoryTags(globus.glmap.GLMapVectorObject object) Returns tags that define the object's matched category.static Object[]merge(globus.glmap.MapPoint center, globus.glmap.GLMapVectorObjectList searchResults, List<Object> customObjects, GLSearch.CustomObjectInfoCallback infoCallback) Merge search results with custom objectsstatic globus.glmap.GLMapVectorObjectNearest(double lat, double lon, double maxDist, List<GLSearchFilter> filters) Finds the nearest object to the specified geographic location.static longPrepareWords(long collator, String[] words) Prepares words for collation.static globus.glmap.GLMapRelation[]RelationsNearPoint(globus.glmap.GLMapViewState state, globus.glmap.MapPoint point, double maxDistance, GLSearchFilter[] filters) Finds relations in offline map data using the captured camera and style.globus.glmap.GLMapVectorObjectListsearch()Performs search synchronouslyvoidsearchAsync(GLSearch.ResultsCallback callback) Starts an asynchronous search.voidsetBBox(globus.glmap.GLMapBBox bbox) Sets the bounding box where the search will be performed.voidsetCenter(globus.glmap.MapPoint center) Sets center of search.voidsetLimit(int limit) Sets maximum number of results to fetch from mapvoidsetLocaleSettings(globus.glmap.GLMapLocaleSettings localeSettings) Sets locale settings that used to sort results by importance.voidsetNeedEnclosingAreas(boolean needEnclosingAreas) Enables loading enclosing areas that are required for address formatting.voidsetObjectTypes(int objectTypes) Set object typesvoidsetTiles(long[] tiles) Adds tile hashes to narrow the search area.static String[]SplitByWords(String string) Splits a string into words using ICU root rules.Methods inherited from class globus.glmap.GLNativeObject
close, dispose
-
Constructor Details
-
GLSearch
public GLSearch()Default constructor
-
-
Method Details
-
Initialize
Deprecated.CallGLMapManager.Initialize(android.content.Context, java.lang.String, globus.glmap.GLMapManager.ProgressCallback)before using Search. This method does not load libraries or prepare resources and will be removed in a future release.Compatibility no-op. Search resources are initialized by GLMapManager.Initialize.- Parameters:
context- unused; retained for source and binary compatibility
-
MapObjectNearPoint
@Nullable public static globus.glmap.GLMapVectorObject MapObjectNearPoint(@NonNull globus.glmap.GLMapViewState state, float screenX, float screenY, double maxDistance) Returns the offline map object associated with a visible POI label in a captured state. Retains the captured camera and label container, even after the renderer is disposed. As on iOS, label visibility/layout can still change while the renderer is active; this is not an immutable snapshot of hit-test results. The underlying offline map data must still be available.- Parameters:
state- captured map state; keep it open until this call returnsscreenX- screen x-coordinate in pixelsscreenY- screen y-coordinate in pixelsmaxDistance- maximum hit distance in screen points (dp)- Returns:
- an independently owned object to close, or null for no hit, a closed state or an invalid distance
-
RelationsNearPoint
@Nullable public static globus.glmap.GLMapRelation[] RelationsNearPoint(@NonNull globus.glmap.GLMapViewState state, @NonNull globus.glmap.MapPoint point, double maxDistance, @Nullable GLSearchFilter[] filters) Finds relations in offline map data using the captured camera and style. The underlying offline map data must still be available.- Parameters:
state- captured map state; keep it open until this call returnspoint- reference point in internal map coordinatesmaxDistance- maximum distance in screen points (dp)filters- optional relation filters- Returns:
- independently owned relations to close, or null for no results, a closed state or an invalid distance
-
LoadMergedRelationLines
@Nullable public static globus.glmap.GLMapVectorObject LoadMergedRelationLines(globus.glmap.GLMapRelation relation, boolean isForward, @Nullable globus.glmap.GLMapInfo map) Loads all line members from a relation and merges them into a multiline object.- Parameters:
relation- relation to loadisForward-truefor forward route,falsefor backward routemap- map from where to load relation; ifnull, an arbitrary map will be used- Returns:
- vector object with multiline, or
nullon failure
-
GetSearchCategory
@Nullable public static GLSearchCategory GetSearchCategory(@NonNull globus.glmap.GLMapVectorObject object) Detects category for a vector object.- Parameters:
object- Vector object- Returns:
- Category that matches to object
-
GetDisplayInfo
@Nullable public static GLSearchDisplayInfo GetDisplayInfo(@NonNull globus.glmap.GLMapVectorObject object, @NonNull globus.glmap.GLMapLocaleSettings localeSettings) Builds display data (title, secondary line, types, category) for a search result row.Works identically for offline search results and parsed online results, so one code path can render rows from both sources.
- Parameters:
object- vector object returned from searchlocaleSettings- locale settings used to localize the texts- Returns:
- display info that must be closed after use, or
nullon failure
-
FillSearchCategory
public static void FillSearchCategory(@NonNull globus.glmap.GLMapVectorObjectList objects) Detects categories for the provided vector objects (in-place).- Parameters:
objects- vector objects to enrich with category information
-
MatchedCategoryTags
@Nullable public static android.util.SparseArray<globus.glmap.GLMapValue> MatchedCategoryTags(@NonNull globus.glmap.GLMapVectorObject object) Returns tags that define the object's matched category.- Parameters:
object- vector object- Returns:
- mapping from tag hash to tag value, or
nullif no category matches
-
GetAddress
@Nullable public static globus.glmap.GLMapValue GetAddress(@NonNull globus.glmap.GLMapVectorObject object, int style, @NonNull globus.glmap.GLMapLocaleSettings localeSettings) Formats an address string for the given object.- Parameters:
object- vector objectstyle- style of addresslocaleSettings- locale settings- Returns:
- address formatted with given style
-
LocalizedAddressNames
@Nullable public static globus.glmap.GLMapValue[] LocalizedAddressNames(@NonNull globus.glmap.GLMapVectorObject object, @NonNull globus.glmap.GLMapLocaleSettings localeSettings) Returns all localized address names associated with the object.- Parameters:
object- vector objectlocaleSettings- Locale settings used to find name- Returns:
- array of address names
-
SplitByWords
Splits a 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:
- opaque native handle; must be destroyed via
DestroyWords(long)when not needed
-
DestroyWords
public static void DestroyWords(long words) Destroy native object returned by GLSearch#PrepareWords(long, String[]).- Parameters:
words- native handle returned byPrepareWords(long, String[])
-
FindWords
@Nullable public static globus.glmap.GLMapValue FindWords(long collator, @NonNull String string, long words) 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:
- opaque native handle; must be destroyed via
DestroyCollator(long)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:
- opaque native handle; must be destroyed via
DestroyCollator(long)when not needed
-
DestroyCollator
public static void DestroyCollator(long collator) Destroys a collator handle created byCreateCollator()orCreateNumericCollator().- 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 globus.glmap.GLMapVectorObject Nearest(double lat, double lon, double maxDist, @Nullable List<GLSearchFilter> filters) Finds the nearest object to the specified geographic location.- 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 narrow the search area. Child tiles will be skipped.- Parameters:
tiles- array of tile hashes
-
setLocaleSettings
public void setLocaleSettings(@NonNull globus.glmap.GLMapLocaleSettings localeSettings) 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
public void setBBox(@NonNull globus.glmap.GLMapBBox bbox) Sets the bounding box where the search will be performed.- Parameters:
bbox- Search bounding box in internal map coordinates.
-
setCenter
public void setCenter(@NonNull globus.glmap.MapPoint center) 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 in internal map coordinates.
-
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) Enables loading enclosing areas that are required for address formatting.If you plan to call
GetAddress(GLMapVectorObject, int, GLMapLocaleSettings)for the results, enabling this can make address formatting faster by preloading enclosing areas. It may increase search time and memory usage.- Parameters:
needEnclosingAreas- iftrue, search will load enclosing areas
-
setObjectTypes
public void setObjectTypes(int objectTypes) Set object types- Parameters:
objectTypes- object types
-
searchAsync
Starts an asynchronous search.The callback is invoked on a background thread. If you update UI, post back to the main thread.
- Parameters:
callback- callback invoked when search is finished
-
search
@NonNull public globus.glmap.GLMapVectorObjectList search()Performs search synchronously- Returns:
- result of search
-
merge
public static Object[] merge(@Nullable globus.glmap.MapPoint center, @NonNull globus.glmap.GLMapVectorObjectList searchResults, @NonNull List<Object> customObjects, @NonNull GLSearch.CustomObjectInfoCallback infoCallback) Merge search results with custom objects- Parameters:
center- optional center of searchsearchResults- search resultscustomObjects- custom objectsinfoCallback- callback that will provide information about object- Returns:
- merged array, sorted by the same ranking rules as regular search results
-
cancel
public void cancel()Cancels asynchronous search operations started for thisGLSearchinstance.Cancellation is best-effort; already running work may still complete and invoke callbacks.
-
GLMapManager.Initialize(android.content.Context, java.lang.String, globus.glmap.GLMapManager.ProgressCallback)before using Search.