/// <summary> /// Searches the content by taking given location as a base and retrieves the contents that located given distance far away. /// </summary> /// <param name="startLocation">Base location to search near it.</param> /// <param name="distance">Distance used to create circle by taking the startLocation as a center.</param> /// <param name="locationSearchField">Name of the field that holds location data.</param> /// <returns>The list of <see cref="NetmeraContent"/> object.</returns> public List <NetmeraContent> circleSearch(NetmeraGeoLocation startLocation, double distance, String locationSearchField) { RequestItem item = new RequestItem(); item.path = NetmeraConstants.Default_ParentPath; item.contentType = NetmeraConstants.Default_ContentType; item.max = max; item.page = page; item.sortBy = sortBy; item.sortOrder = sortOrder.ToString(); item.customCondition = getCustomCondition(); if (searchText != null) { item.searchText = searchText; } item.locationSearchType = NetmeraConstants.LocationSearchType_Circle; item.distance = distance; item.latitudes = startLocation.getLatitude().ToString(); item.longitudes = startLocation.getLongitude().ToString(); item.locationSearchField = locationSearchField; JArray jsonArray = new JArray(NetmeraHttpUtils.locationSearch(item)); return(convertJsonArrayToNetmeraContent(jsonArray)); }
/// <summary> /// Creates box using the given two location (latitude,longitude) data and searches inside that box. /// </summary> /// <param name="firstPoint"><see cref="NetmeraGeoLocation"/> object</param> /// <param name="secondPoint"><see cref="NetmeraGeoLocation"/> object</param> /// <param name="locationSearchField">Name of the field that holds location data.</param> /// <returns>The list of <see cref="NetmeraContent"/> object.</returns> public List <NetmeraContent> boxSearch(NetmeraGeoLocation firstPoint, NetmeraGeoLocation secondPoint, String locationSearchField) { RequestItem item = new RequestItem(); item.path = NetmeraConstants.Default_ParentPath; item.contentType = NetmeraConstants.Default_ContentType; item.max = max; item.page = page; item.sortBy = sortBy; item.sortOrder = sortOrder.ToString(); item.customCondition = getCustomCondition(); if (searchText != null) { item.searchText = searchText; } item.locationSearchType = NetmeraConstants.LocationSearchType_Box; StringBuilder latitudes = new StringBuilder(); StringBuilder longitudes = new StringBuilder(); if (firstPoint.getLatitude() < secondPoint.getLatitude()) { latitudes.Append(firstPoint.getLatitude().ToString()).Append(",").Append(secondPoint.getLatitude().ToString()); } else { latitudes.Append(secondPoint.getLatitude().ToString()).Append(",").Append(firstPoint.getLatitude().ToString()); } if (firstPoint.getLongitude() < secondPoint.getLongitude()) { longitudes.Append(firstPoint.getLongitude().ToString()).Append(",").Append(secondPoint.getLongitude().ToString()); } else { longitudes.Append(secondPoint.getLongitude().ToString()).Append(",").Append(firstPoint.getLongitude().ToString()); } item.latitudes = latitudes.ToString(); item.longitudes = longitudes.ToString(); item.locationSearchField = locationSearchField; JArray jsonArray = new JArray(NetmeraHttpUtils.locationSearch(item)); return(convertJsonArrayToNetmeraContent(jsonArray)); }
/// <summary> /// Searches the content by taking given location as a base and retrieves the contents that located given distance far away. /// </summary> /// <param name="startLocation">Base location to search near it.</param> /// <param name="distance">Distance used to create circle by taking the startLocation as a center.</param> /// <param name="locationSearchField">Name of the field that holds location data.</param> /// <param name="callback">Method called when circle search operation finishes</param> public void circleSearch(NetmeraGeoLocation startLocation, double distance, String locationSearchField, Action <List <NetmeraContent>, Exception> callback) { RequestItem item = new RequestItem(); item.path = NetmeraConstants.Default_ParentPath; item.contentType = NetmeraConstants.Default_ContentType; item.max = max; item.page = page; item.sortBy = sortBy; item.sortOrder = sortOrder.ToString(); item.customCondition = getCustomCondition(); if (searchText != null) { item.searchText = searchText; } item.locationSearchType = NetmeraConstants.LocationSearchType_Circle; item.distance = distance; item.latitudes = startLocation.getLatitude().ToString(); item.longitudes = startLocation.getLongitude().ToString(); item.locationSearchField = locationSearchField; NetmeraHttpUtils.locationSearch(item, (lno, ex) => { if (ex != null) { if (callback != null) { callback(null, ex); } } else if (lno != null) { try { List <NetmeraContent> contentList = convertJsonArrayToNetmeraContent(new JArray(lno)); if (callback != null) { callback(contentList, null); } } catch (JsonException e) { if (callback != null) { callback(null, new NetmeraException(NetmeraException.ErrorCode.EC_INVALID_JSON, "Json in the response of search method is invalid.", e.Message)); } } catch (IOException e) { if (callback != null) { callback(null, new NetmeraException(NetmeraException.ErrorCode.EC_IO_EXCEPTION, "IO Exception occurred in search method.", e.Message)); } } catch (Exception e) { if (callback != null) { callback(null, new NetmeraException(NetmeraException.ErrorCode.EC_INVALID_REQUEST, "Request exception occurred in search method.", e.Message)); } } NetmeraClient.finish(); } }); }