2.Fixed to convert distance values with the distance unit in preference.
3.Rearranged some apis for search_place.
4.Updated engine libraries to heremaps-engine_1.0.6_9
Change-Id: I2d772991d63be8f9d6c375faa9d75c1ceae45c1b
elm_exit();
}
+static void read_file(heremaps_uc_app_data *ad)
+{
+ LS_FUNC_ENTER
+ FILE *fp = fopen(UC_FILE, "r");
+ char buf[15] = {};
+ char *data = NULL, *save_token = NULL;
+ app_control_h reply;
+ int ret = 0;
+
+ if (fp == NULL)
+ LS_LOGE("UC_FILE open fail");
+ else {
+ ret = fread(buf, 15, 1, fp);
+ fclose(fp);
+
+ if (ret > 0)
+ {
+ data = strtok_r(buf, "=", &save_token);
+ data = strtok_r(NULL, "=", &save_token);
+ }
+ else
+ LS_LOGE("UC_FILE read fail");
+ }
+
+ app_control_create(&reply);
+ if (data == NULL)
+ app_control_add_extra_data(reply, "result", "No");
+ else if ((strcmp(data, "Yes") == 0) || (strcmp(data, "No") == 0))
+ app_control_add_extra_data(reply, "result", data);
+ else
+ app_control_add_extra_data(reply, "result", "No");
+ ret = app_control_reply_to_launch_request(reply, ad->app_control, APP_CONTROL_RESULT_SUCCEEDED);
+ if (ret != APP_CONTROL_ERROR_NONE)
+ LS_LOGE("app_control_reply_to_launch_request fail. err=%d", ret);
+ app_control_destroy(reply);
+}
+
static void save_file(char *data, heremaps_uc_app_data *ad)
{
FILE *fp = fopen(UC_FILE, "w+");
app_control_h reply;
int ret = 0;
- snprintf(buf, sizeof(buf)-1, "Agree=%s", data);
- fwrite(buf, strlen(buf), 1, fp);
+ app_control_create(&reply);
- fclose(fp);
+ if (fp == NULL) {
+ LS_LOGE("UC_FILE open fail");
+ app_control_add_extra_data(reply, "result", "No");
+ } else {
+ snprintf(buf, sizeof(buf)-1, "Agree=%s", data);
+ fwrite(buf, strlen(buf), 1, fp);
+ fclose(fp);
+ LS_LOGE("result of save_file() is %s", data);
+
+ app_control_add_extra_data(reply, "result", strdup(data));
+ }
- app_control_create(&reply);
ret = app_control_reply_to_launch_request(reply, ad->app_control, APP_CONTROL_RESULT_SUCCEEDED);
if (ret != APP_CONTROL_ERROR_NONE)
LS_LOGE("app_control_reply_to_launch_request fail. err=%d", ret);
elm_exit();
}
+static void back_btn_cb(void *data, Evas_Object * obj, void *event)
+{
+ LS_FUNC_ENTER
+ heremaps_uc_app_data *ad = (heremaps_uc_app_data *) data;
+
+ read_file(ad);
+ elm_exit();
+}
+
static Evas_Object *create_win(const char *name)
{
LS_FUNC_ENTER
/* popup */
popup = elm_popup_add(layout);
elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0);
- eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, win_del, layout);
+ eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, back_btn_cb, ad);
evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_object_part_text_set(popup, "title,text", P_("IDS_POSITIONING_CONSENT_TITLE"));
gboolean ret = FALSE;
heremaps_uc_app_data *ad = (heremaps_uc_app_data *) user_data;
+ char *action = NULL;
char *data = NULL;
LS_RETURN_IF_FAILED(ad);
- app_control_get_extra_data(app_control, "value", &data);
- LS_LOGE("DATA = %s", data);
-
ret = app_control_clone(&(ad->app_control), app_control);
if (ret == FALSE)
LS_LOGE("app_control_clone. err=%d", ret);
- if (data != NULL) {
- if ((strcmp(data, "Yes") == 0) || (strcmp(data, "No") == 0)) {
- save_file(data, ad);
+ app_control_get_extra_data(app_control, "action", &action);
+ if (action != NULL) {
+ if (strcmp(action, "Get") == 0) {
+ read_file(ad);
elm_exit();
+ } else if (strcmp(action, "Set") == 0) {
+ app_control_get_extra_data(app_control, "value", &data);
+ LS_LOGE("DATA = %s", data);
+
+ if (data != NULL) {
+ if ((strcmp(data, "Yes") == 0) || (strcmp(data, "No") == 0)) {
+ save_file(data, ad);
+ elm_exit();
+ }
+ }
}
}
* This enumeration defines identifiers for route MetricSystem specifiers.
*/
enum MetricSystem {
- DIST_imperial = 0x0000, ///< Indicates that MetricSystem is miles
- DIST_metric = 0x0001 ///< Indicates that MetricSystem is m & km
+ DIST_metric = 0x0000, ///< Indicates that MetricSystem is m & km
+ DIST_imperial = 0x0001 ///< Indicates that MetricSystem is miles
};
#endif
here_error_e PrepareDiscoveryFilter(maps_place_filter_h hFilter);
here_error_e StartDiscoveryPlace(maps_coordinates_h hCoord, int nDistance);
- here_error_e StartDiscoveryPlaceByArea(maps_area_h hArea);
- here_error_e StartDiscoveryPlaceByAddress(const char *szAddr, maps_area_h hArea);
+ here_error_e StartDiscoveryPlace(maps_area_h hArea, const char *szAddr = "");
here_error_e PreparePlaceDetailsQuery();
here_error_e PreparePlaceDetailsPreference(maps_preference_h hPref);
-
- here_error_e StartPlaceDetails(const char* szPlaceId);
+
+ here_error_e StartPlaceDetails(const char* szUrl);
here_error_e StartPlaceDetailsInternal(const char* szUrl);
virtual void OnDiscoverReply(const DiscoveryReply &Reply);
bool m_bReplyFlushed;
char *m_szSortBy;
bool m_bPlaceDetailsInternal;
+ maps_distance_unit_e m_eDistanceUnit;
PlaceList m_PlaceList;
private:
maps_error_e ProcessSegments(maps_route_h mapsRoute, const RouteSegmentList& hereSegmList);
maps_error_e ProcessManeuver(maps_route_segment_h mapsSegm, const ManeuverList& hereManeList);
+ const double __convertDistanceUnit(const double dValue);
+ maps_distance_unit_e m_eDistanceUnit;
GeoRouteQuery* m_pQuery;
};
#include <routes/GeoRouteQuery.h>
#include <routes/Maneuver.h>
#include <common/GeoCoordinates.h>
+#include <common/GeoBoundingBox.h>
+#include <common/GeoBoundingCircle.h>
#define HERE_PLUGIN_BEGIN_NAMESPACE namespace Here { namespace PlugIn {
#define HERE_PLUGIN_END_NAMESPACE }}
static maps_route_turn_type_e Convert(Maneuver::InstructionDirection nVal);
static GeoBoundingBox& Convert(maps_area_h hArea, GeoBoundingBox& Box);
static maps_area_h& Convert(GeoBoundingBox Box, maps_area_h& hArea);
+ static GeoBoundingCircle& Convert(maps_area_h hArea, GeoBoundingCircle& circle);
static void Convert(String strUtf8, WString& strUtf16);
static void Convert(WString strUtf16, String& strUtf8);
static GeoBoundingBox& Convert(const char *src, GeoBoundingBox &box);
static maps_error_e ConvertHttpCodeToMapsError(int nVal);
+ static const double ConvertDistance(const double originValue, maps_distance_unit_e destUnit);
+ static const double ConvertDistance(const double originValue, maps_distance_unit_e originUnit, maps_distance_unit_e destUnit);
static bool IsValid(GeoCoordinates geoCoord);
static bool IsValid(maps_coordinates_s geoCoord);
-libheremaps-engine.so.1.0.6_8
\ No newline at end of file
+libheremaps-engine.so.1.0.6_9
\ No newline at end of file
-libheremaps-engine.so.1.0.6_8
\ No newline at end of file
+libheremaps-engine.so.1.0.6_9
\ No newline at end of file
-libheremaps-engine.so.1.0.6_8
\ No newline at end of file
+libheremaps-engine.so.1.0.6_9
\ No newline at end of file
-libheremaps-engine.so.1.0.6_8
\ No newline at end of file
+libheremaps-engine.so.1.0.6_9
\ No newline at end of file
error = pPlace->PrepareDiscoveryFilter(hFilter);
if (error != HERE_ERROR_NONE) break;
- error = pPlace->StartDiscoveryPlaceByArea(hArea);
+ error = pPlace->StartDiscoveryPlace(hArea);
} while(0);
/* finishing task */
error = pPlace->PrepareDiscoveryFilter(hFilter);
if (error != HERE_ERROR_NONE) break;
- error = pPlace->StartDiscoveryPlaceByAddress(szAddr, hArea);
+ error = pPlace->StartDiscoveryPlace(hArea, szAddr);
} while(0);
/* finishing task */
m_bReplyFlushed = false;
m_szSortBy = NULL;
m_bPlaceDetailsInternal = false;
+ m_eDistanceUnit = MAPS_DISTANCE_UNIT_M;
}
HerePlace::~HerePlace()
if (ret == MAPS_ERROR_NONE)
m_pDiscoveryQuery->SetMaxResults((size_t)nMaxResults);
+ maps_distance_unit_e eUnit;
+ ret = maps_preference_get_distance_unit(hPref, &eUnit);
+ if (ret == MAPS_ERROR_NONE)
+ m_eDistanceUnit = eUnit;
+
char *szSortBy;
ret = maps_preference_get(hPref, MAPS_PLACE_FILTER_SORT_BY, &szSortBy);
if (ret == MAPS_ERROR_NONE)
here_error_e HerePlace::StartDiscoveryPlace(maps_coordinates_h hCoord, int nDistance)
{
+ if (!hCoord || nDistance < 0)
+ return HERE_ERROR_INVALID_PARAMETER;
+
+ maps_area_h area = NULL;
+ maps_area_create_circle(hCoord, nDistance, &area);
+ here_error_e error = StartDiscoveryPlace(area);
+ maps_area_destroy(area);
+ return error;
+}
+
+here_error_e HerePlace::StartDiscoveryPlace(maps_area_h hArea, const char *szAddr)
+{
+ if (!hArea)
+ return HERE_ERROR_INVALID_PARAMETER;
+
if (!m_pDiscoveryQuery)
return HERE_ERROR_OUT_OF_MEMORY;
- if (!hCoord)
- return HERE_ERROR_INVALID_PARAMETER;
- if (m_pDiscoveryQuery->GetSearchText().empty())
- {
- m_pDiscoveryQuery->SetType(DiscoveryQuery::QT_EXPLORE);
+ typedef enum {
+ PLACE_CMD_TEXT,
+ PLACE_CMD_CENTER,
+ PLACE_CMD_AREA,
+ } PlaceCmdType;
- double dLat, dLon;
- maps_coordinates_get_latitude(hCoord, &dLat);
- maps_coordinates_get_longitude(hCoord, &dLon);
- GeoCoordinates geoCoord(dLat, dLon);
+ PlaceCmdType cmdType;
+ maps_area_s *pArea = (maps_area_s*)hArea;
+ GeoCoordinates geoCoord;
+ GeoBoundingArea *geoArea = NULL;
+ GeoBoundingBox geoBox;
+ GeoBoundingCircle geoCircle;
- if (nDistance > 0)
- {
- GeoBoundingCircle geoCircle(geoCoord, nDistance);
- m_pDiscoveryQuery->SetArea(geoCircle);
- }
- else if (nDistance == 0)
- {
- m_pDiscoveryQuery->SetProximity(geoCoord);
- }
- else
- return HERE_ERROR_INVALID_PARAMETER;
+ /* Merge search text with other search text being in preference */
+ String szSearchText = szAddr;
+ if (m_pDiscoveryQuery->GetSearchText().size() > 0 &&
+ szSearchText != m_pDiscoveryQuery->GetSearchText())
+ {
+ szSearchText += " " + m_pDiscoveryQuery->GetSearchText();
+ }
+ m_pDiscoveryQuery->SetSearchText(szSearchText);
- m_nRestReqId = m_pDiscoveryQuery->Execute(*this, NULL);
- return (m_nRestReqId > 0 ? HERE_ERROR_NONE : HERE_ERROR_INVALID_OPERATION);
+ /* Decide command type */
+ if (!szSearchText.empty())
+ {
+ cmdType = PLACE_CMD_TEXT;
+ }
+ else if (pArea->type == MAPS_AREA_CIRCLE && pArea->circle.radius == 0)
+ {
+ cmdType = PLACE_CMD_CENTER;
}
else
{
- here_error_e error;
- maps_area_h hArea = NULL;
- maps_area_create_circle(hCoord, nDistance, &hArea);
- error = StartDiscoveryPlaceByAddress(m_pDiscoveryQuery->GetSearchText().data(), hArea);
- maps_area_destroy(hArea);
- return error;
+ cmdType = PLACE_CMD_AREA;
}
-}
-
-here_error_e HerePlace::StartDiscoveryPlaceByArea(maps_area_h hArea)
-{
- if (!m_pDiscoveryQuery)
- return HERE_ERROR_OUT_OF_MEMORY;
-
- if (!hArea)
- return HERE_ERROR_INVALID_PARAMETER;
- if (m_pDiscoveryQuery->GetSearchText().empty())
+ /* Get proximity with area */
+ if (cmdType == PLACE_CMD_TEXT || cmdType == PLACE_CMD_CENTER)
{
- m_pDiscoveryQuery->SetType(DiscoveryQuery::QT_EXPLORE);
-
- maps_area_s *pArea = (maps_area_s*)hArea;
if (pArea->type == MAPS_AREA_RECTANGLE)
{
- GeoBoundingBox box(pArea->rect.top_left.longitude, pArea->rect.bottom_right.longitude,
- pArea->rect.bottom_right.latitude, pArea->rect.top_left.latitude);
- m_pDiscoveryQuery->SetArea(box);
+ double dLat1 = pArea->rect.top_left.latitude;
+ double dLng1 = pArea->rect.top_left.longitude;
+ double dLat2 = pArea->rect.bottom_right.latitude;
+ double dLng2 = pArea->rect.bottom_right.longitude;
+ double dLat = (dLat1 + dLat2) / 2;
+ double dLng = (dLng1 + dLng2) / 2;
+
+ geoCoord.SetLatitude(dLat);
+ geoCoord.SetLongitude(dLng);
}
- else if (pArea->type == MAPS_AREA_CIRCLE)
+ else if(pArea->type == MAPS_AREA_CIRCLE)
{
- GeoCoordinates coord(pArea->circle.center.latitude, pArea->circle.center.longitude);
- GeoBoundingCircle circle(coord, pArea->circle.radius);
- m_pDiscoveryQuery->SetArea(circle);
+ double dLat = pArea->circle.center.latitude;
+ double dLng = pArea->circle.center.longitude;
+
+ geoCoord.SetLatitude(dLat);
+ geoCoord.SetLongitude(dLng);
}
else
return HERE_ERROR_INVALID_PARAMETER;
-
-
- m_nRestReqId = m_pDiscoveryQuery->Execute(*this, NULL);
-
- return (m_nRestReqId > 0 ? HERE_ERROR_NONE : HERE_ERROR_INVALID_OPERATION);
}
- else
+ else if (cmdType == PLACE_CMD_AREA)
{
- return StartDiscoveryPlaceByAddress(m_pDiscoveryQuery->GetSearchText().data(), hArea);
+ if (pArea->type == MAPS_AREA_RECTANGLE)
+ {
+ HereUtils::Convert(hArea, geoBox);
+ geoArea = &geoBox;
+ }
+ else if (pArea->type == MAPS_AREA_CIRCLE)
+ {
+ HereUtils::Convert(hArea, geoCircle);
+ geoArea = &geoCircle;
+ }
+ else
+ return HERE_ERROR_INVALID_PARAMETER;
}
-}
-
-here_error_e HerePlace::StartDiscoveryPlaceByAddress(const char *szAddr, maps_area_h hArea)
-{
- if (!m_pDiscoveryQuery)
- return HERE_ERROR_OUT_OF_MEMORY;
-
- if (!szAddr || (szAddr && strlen(szAddr) <= 0) || !hArea)
- return HERE_ERROR_INVALID_PARAMETER;
- m_pDiscoveryQuery->SetType(DiscoveryQuery::QT_SEARCH);
-
- String szSearchText = szAddr;
- if (m_pDiscoveryQuery->GetSearchText().size() > 0 &&
- szSearchText != m_pDiscoveryQuery->GetSearchText())
+ /* Set properties */
+ if (cmdType == PLACE_CMD_TEXT)
{
- szSearchText += " " + m_pDiscoveryQuery->GetSearchText();
+ m_pDiscoveryQuery->SetType(DiscoveryQuery::QT_SEARCH);
+ m_pDiscoveryQuery->SetProximity(geoCoord);
}
- m_pDiscoveryQuery->SetSearchText(szSearchText);
-
- maps_area_s *pArea = (maps_area_s*)hArea;
- if (pArea->type == MAPS_AREA_RECTANGLE)
+ else if (cmdType == PLACE_CMD_CENTER)
{
- double dLat1 = pArea->rect.top_left.latitude;
- double dLng1 = pArea->rect.top_left.longitude;
- double dLat2 = pArea->rect.bottom_right.latitude;
- double dLng2 = pArea->rect.bottom_right.longitude;
- double dLat = (dLat1 + dLat2) / 2;
- double dLng = (dLng1 + dLng2) / 2;
-
- GeoCoordinates geoCoord(dLat, dLng);
+ m_pDiscoveryQuery->SetType(DiscoveryQuery::QT_EXPLORE);
m_pDiscoveryQuery->SetProximity(geoCoord);
}
- else if(pArea->type == MAPS_AREA_CIRCLE)
+ else
{
- double dLat = pArea->circle.center.latitude;
- double dLng = pArea->circle.center.longitude;
- GeoCoordinates geoCoord(dLat, dLng);
- m_pDiscoveryQuery->SetProximity(geoCoord);
+ m_pDiscoveryQuery->SetType(DiscoveryQuery::QT_EXPLORE);
+ if (geoArea)
+ m_pDiscoveryQuery->SetArea(*geoArea);
}
-
+ /* Execute query */
m_nRestReqId = m_pDiscoveryQuery->Execute(*this, NULL);
return (m_nRestReqId > 0 ? HERE_ERROR_NONE : HERE_ERROR_INVALID_OPERATION);
m_pPlaceDetailsQuery->SetLanguage(szLanguage);
g_free(szLanguage);
+ maps_distance_unit_e eUnit;
+ ret = maps_preference_get_distance_unit(hPref, &eUnit);
+ if (ret == MAPS_ERROR_NONE)
+ m_eDistanceUnit = eUnit;
+
return HERE_ERROR_NONE;
}
-here_error_e HerePlace::StartPlaceDetails(const char *szPlaceId)
+here_error_e HerePlace::StartPlaceDetails(const char *szUrl)
{
if (!m_pPlaceDetailsQuery)
return HERE_ERROR_OUT_OF_MEMORY;
- if (!szPlaceId || (szPlaceId && strlen(szPlaceId) <= 0))
+ if (!szUrl || (szUrl && strlen(szUrl) <= 0))
return HERE_ERROR_INVALID_PARAMETER;
- m_pPlaceDetailsQuery->SetPlaceId(szPlaceId);
-
-
- m_nRestReqId = m_pPlaceDetailsQuery->Execute(*this, NULL);
+ m_nRestReqId = m_pPlaceDetailsQuery->Execute(*this, NULL, szUrl);
return (m_nRestReqId > 0 ? HERE_ERROR_NONE : HERE_ERROR_INVALID_OPERATION);
}
}
/* distance */
- maps_place_set_distance(mapsPlace, (int)herePlaceIt->GetDistance());
+ maps_place_set_distance(mapsPlace, HereUtils::ConvertDistance((int)herePlaceIt->GetDistance(), m_eDistanceUnit));
/* sponser */
/* herePlaceList.GetIsSponsored() */
}
void HerePlace::ProcessPlaceImage(PlaceDetails herePlace, maps_place_h mapsPlace)
-{
+{
ImageContentList hereImageList = herePlace.GetImageContent();
ImageContentList::iterator hereImage;
maps_item_list_h mapsImageList;
m_pCbFunc = pCbFunc;
m_pUserData = pUserData;
m_nReqId = nReqId;
+
+ m_eDistanceUnit = MAPS_DISTANCE_UNIT_M;
}
HereRoute::~HereRoute()
case MAPS_DISTANCE_UNIT_KM: eMetric = GeoRouteQuery::DIST_metric; break;
default: eMetric = GeoRouteQuery::DIST_imperial; break;
}
+ m_eDistanceUnit = eUnit;
m_pQuery->SetMetricSystem(eMetric);
}
maps_route_set_route_id(mapsRoute, (char*)hereRoute->GetRouteId().c_str());
/* distance */
- maps_route_set_total_distance(mapsRoute, hereRoute->GetDistance());
+ maps_route_set_total_distance(mapsRoute,
+ HereUtils::ConvertDistance(hereRoute->GetDistance(), m_eDistanceUnit));
+
+ /* distance unit */
+ maps_route_set_distance_unit(mapsRoute, m_eDistanceUnit);
/* duration */
maps_route_set_total_duration(mapsRoute, hereRoute->GetTravelTime());
if (maps_route_segment_create(&mapsSegm) != MAPS_ERROR_NONE) continue;
/* distance */
- maps_route_segment_set_distance(mapsSegm, hereSegm->GetDistance());
+ maps_route_segment_set_distance(mapsSegm,
+ HereUtils::ConvertDistance(hereSegm->GetDistance(), m_eDistanceUnit));
/* tranvel time */
maps_route_segment_set_duration(mapsSegm, hereSegm->GetTravelTime());
/* length */
maps_route_maneuver_set_distance_to_next_instruction(mapsManeuver,
- hereMane->GetDistanceToNextInstruction());
+ HereUtils::ConvertDistance(hereMane->GetDistanceToNextInstruction(), m_eDistanceUnit));
/* travel time */
maps_route_maneuver_set_time_to_next_instruction(mapsManeuver,
return hArea;
}
+GeoBoundingCircle& HereUtils::Convert(maps_area_h hArea, GeoBoundingCircle& circle)
+{
+ maps_area_s* area_s = (maps_area_s*)hArea;
+
+ if (!area_s || area_s->type != MAPS_AREA_CIRCLE) return circle;
+
+ GeoCoordinates hereCoord(area_s->circle.center.latitude, area_s->circle.center.longitude);
+
+ circle.SetCenter(hereCoord);
+ circle.SetRadius(area_s->circle.radius);
+
+ return circle;
+}
+
void HereUtils::Convert(String strUtf8, WString& strUtf16)
{
strUtf16.assign(strUtf8.begin(), strUtf8.end());
return false;
}
+const double HereUtils::ConvertDistance(const double originValue, maps_distance_unit_e destUnit)
+{
+ return ConvertDistance(originValue, MAPS_DISTANCE_UNIT_M, destUnit);
+}
+
+const double HereUtils::ConvertDistance(const double originValue, maps_distance_unit_e originUnit, maps_distance_unit_e destUnit)
+{
+ double meterConstant[MAPS_DISTANCE_UNIT_YD+1] = { 1.0, 0.001, 3.2808399, 1.0936133 };
+ return originValue / meterConstant[originUnit] * meterConstant[destUnit];
+}
HERE_PLUGIN_END_NAMESPACE