Fixes geocode status 13/77713/1
authorKevin Kreiser <kevinkreiser@gmail.com>
Thu, 23 Jun 2016 12:30:00 +0000 (08:30 -0400)
committerBaldur Gudbjornsson <baldur@mapzen.com>
Thu, 30 Jun 2016 13:49:05 +0000 (09:49 -0400)
Change-Id: I88d42e11743eaf96d1eba328bf219d9a4a95f86e

inc/mapzen_api.h [deleted file]
inc/mapzen_constants.h [deleted file]
inc/mapzen_utils.h [deleted file]
src/mapzen/mapzen_geocode.c
src/mapzen/mapzen_geocode.h
src/mapzen/mapzen_jsonparser.cpp
src/mapzen/mapzen_queue.c
src/mapzen/mapzen_route.cpp
src/mapzen_api.cpp [deleted file]
src/mapzen_plugin.c

diff --git a/inc/mapzen_api.h b/inc/mapzen_api.h
deleted file mode 100644 (file)
index fe46189..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _MAPZEN_API_H_
-#define _MAPZEN_API_H_
-
-#include <maps_plugin.h>
-#include <maps_view.h>
-
-int MapzenPluginRoute(maps_coordinates_h origin, maps_coordinates_h destination,
-       maps_item_hashtable_h pref, maps_service_search_route_cb callback_function,
-       void* user_data, int* request_id);
-
-#endif // _MAPZEN_API_H_
diff --git a/inc/mapzen_constants.h b/inc/mapzen_constants.h
deleted file mode 100644 (file)
index 81f39c2..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _MAPZEN_CONSTANTS_H_
-#define _MAPZEN_CONSTANTS_H_
-
-// Error types
-enum ErrorType {
-       kNone = 0,                              // Success
-       kPermissionDenied,              // Permission denied
-       kOutOfMemory,                   // Out of memory
-       kInvalidParameter,              // Invalid parameter
-       kNotSupported,                  // Unsupported operation
-       kConnectionTimeout,             // Connection timeout
-       kNetworkUnreachable,    // Network unavailable
-       kInvalidOperation,              // Invalid operation
-       kInvalidKey,            // Invalid key
-       kResourceBusy,                  // Resource busy
-       kCancelled,                             // Service cancelled
-       kUnknown,                               // Unknown error
-       kServiceUnavailable,    // Service unavailable
-       kResultNotFound                 // Result not found
-};
-
-#endif // _MAPZEN_CONSTANTS_H_
diff --git a/inc/mapzen_utils.h b/inc/mapzen_utils.h
deleted file mode 100644 (file)
index e88abef..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <string>
-#include <vector>
-#include <maps_area.h>
-#include <maps_preference.h>
-#include <maps_route_maneuver.h>
-#include <maps_service.h>
-#include <maps_view.h>
-
-extern "C"
-{
-
-}
-constexpr double kPolylinePrecision = 1E6;
-constexpr double kInvPolylinePrecision = 1.0 / kPolylinePrecision;
-
-
-class MapzenUtils
-{
-public:
-       MapzenUtils();
-       ~MapzenUtils();
-
-       // Is the map coordinate valid (in valid latitude,longitude range)
-       static bool IsValid(maps_coordinates_s& coord);
-
-       // Decode the shape string returned in the route result
-       void DecodeShape(const std::string& encoded,
-                       std::vector<maps_coordinates_s>& output);
-
-private:
-};
-
index 799bf1578c9670113cb61b8306dc41054e1ea588..66fa098e6da0e7b2568054d745b58ae8046739b9 100644 (file)
@@ -27,7 +27,7 @@
 
 #define GEOCODE_URL    "https://search.mapzen.com/v1/search?api_key=%s"
 
-int query_geocode_within_bounds(gchar *maps_key, char *address, coords_s top_left, coords_s bottom_right, int num_results, gpointer user_data)
+int query_geocode_within_bounding_box(gchar *maps_key, char *address, coords_s top_left, coords_s bottom_right, int num_results, gpointer user_data)
 {
        char url[1024];
        char tmpStr[512];
@@ -38,15 +38,41 @@ int query_geocode_within_bounds(gchar *maps_key, char *address, coords_s top_lef
                snprintf(tmpStr, sizeof(tmpStr), GEOCODE_URL, "null");
 
        STRCPY(url, tmpStr);
-
        snprintf(tmpStr, sizeof(tmpStr), "&boundary.rect.min_lat=%f&boundary.rect.min_lon=%f&boundary.rect.max_lat=%f&boundary.rect.max_lon=%f",
-                       top_left.latitude, top_left.longitude, bottom_right.latitude, bottom_right.longitude);
+                       bottom_right.latitude, top_left.longitude, top_left.latitude, bottom_right.longitude);
+       STRCAT(url, tmpStr);
+
+       snprintf(tmpStr, sizeof(tmpStr), "&size=%d", num_results);
+       STRCAT(url, tmpStr);
+
+       snprintf(tmpStr, sizeof(tmpStr), "&text=%s", address);
+       STRCAT(url, tmpStr);
+
+       add_handle(url, REQ_TYPE_GEOCODE, user_data);
+
+       return 0;
+}
+
+int query_geocode_within_circle(gchar *maps_key, char *address, coords_s center, double radius, int num_results, gpointer user_data)
+{
+       char url[1024];
+       char tmpStr[512];
+
+       if (maps_key != NULL)
+               snprintf(tmpStr, sizeof(tmpStr), GEOCODE_URL, maps_key);
+       else
+               snprintf(tmpStr, sizeof(tmpStr), GEOCODE_URL, "null");
+
+       STRCPY(url, tmpStr);
+
+       snprintf(tmpStr, sizeof(tmpStr), "&boundary.circle.lon=%f&boundary.circle.lat=%f&boundary.circle.radius=%f",
+                       center.longitude, center.latitude, radius);
        STRCAT(url, tmpStr);
 
        snprintf(tmpStr, sizeof(tmpStr), "&size=%d", num_results);
        STRCAT(url, tmpStr);
 
-       snprintf(tmpStr, sizeof(tmpStr), "&layers=address&text=%s", address);
+       snprintf(tmpStr, sizeof(tmpStr), "&text=%s", address);
        STRCAT(url, tmpStr);
 
        add_handle(url, REQ_TYPE_GEOCODE, user_data);
@@ -70,7 +96,7 @@ int query_geocode(gchar *maps_key, char *address, int num_results, gpointer user
        snprintf(tmpStr, sizeof(tmpStr), "&size=%d", num_results);
        STRCAT(url, tmpStr);
 
-       snprintf(tmpStr, sizeof(tmpStr), "&layers=address&text=%s", address);
+       snprintf(tmpStr, sizeof(tmpStr), "&text=%s", address);
        STRCAT(url, tmpStr);
 
        add_handle(url, REQ_TYPE_GEOCODE, user_data);
index d4035ae3e50e9aa13ec844205f27f277deed2d7b..6c330ca0cc1e41c41d7e38c9772b7532b3edfa8b 100644 (file)
@@ -21,6 +21,7 @@
 #include "mapzen_types.h"
 
 int query_geocode(gchar *maps_key, char *address, int num_results, gpointer user_data);
-int query_geocode_within_bounds(gchar *maps_key, char *address, coords_s top_left, coords_s bottom_right, int num_results, gpointer user_data);
+int query_geocode_within_bounding_box(gchar *maps_key, char *address, coords_s top_left, coords_s bottom_right, int num_results, gpointer user_data);
+int query_geocode_within_circle(gchar *maps_key, char *address, coords_s center, double radius, int num_results, gpointer user_data);
 
 #endif /* MAPZEN_GEOCODE_H_ */
index b692ae3579bcf00935bff74d6e8d30c05a634148..02581d92b18a3192dda21a25abef28d5c355afd4 100644 (file)
@@ -133,8 +133,9 @@ bool __get_string(const rapidjson::Value& obj, const char* key, char** value)
        //if we have the key and its not an empty value
        rapidjson::Value::ConstMemberIterator itr = obj.FindMember(key);
        if(itr != obj.MemberEnd() && itr->value.GetStringLength()){
-               (*value) = (gchar *)g_malloc(itr->value.GetStringLength() + 1);
+               (*value) = (gchar *)g_malloc(itr->value.GetStringLength() + sizeof(rapidjson::Document::Ch));
                strncpy((*value), itr->value.GetString(), itr->value.GetStringLength());
+               memset((*value) + itr->value.GetStringLength(), 0, sizeof(rapidjson::Document::Ch));
        }//we had nothing
        else
                (*value) = NULL;
@@ -152,7 +153,9 @@ static void __parse_geocode_response(char *response, int size, int *status, GLis
 
        if (!response || !status || !coordsList) return;
 
+       //so far we have nothing
        *coordsList = NULL;
+       *status = 500;
 
        //crack open that json
        rapidjson::Document document;
@@ -175,14 +178,15 @@ static void __parse_geocode_response(char *response, int size, int *status, GLis
 
                                coords_s *coord = (coords_s *)g_malloc0(sizeof(coords_s));
                                if (coord != NULL) {
-                                       coord->latitude = coords->value[0].GetDouble();
-                                       coord->longitude = coords->value[1].GetDouble();
+                                       coord->longitude = coords->value[0].GetDouble();
+                                       coord->latitude = coords->value[1].GetDouble();
                                }
 
                                if (*coordsList == NULL)
                                        *coordsList = g_list_append(*coordsList, coord);
                                else
                                        *coordsList = g_list_insert_before(*coordsList, NULL, coord);
+                               *status = 0;
                        }
                }
        }
@@ -194,7 +198,9 @@ static void __parse_revgeocode_response(char *response, int size, int *status, m
 {
        if (!response || !status || !respAddr) return;
 
+       //so far we have nothing
        *respAddr = NULL;
+       *status = 500;
 
        //crack open that json
        rapidjson::Document document;
@@ -242,8 +248,10 @@ static void __parse_revgeocode_response(char *response, int size, int *status, m
                                                g_free(*respAddr);
                                                (*respAddr) = NULL;
                                        }//forget the rest, we have one with something in it
-                                       else
+                                       else {
+                                               *status = 0;
                                                break;
+                                       }
                                }
                        }
                }
index 99a681dd7f0689ff5a2da15e169997d85ce9697e..db1a3d7f6818c33cc638ddcc2b3f2ece9f8805ca 100644 (file)
@@ -1072,34 +1072,13 @@ int start_geocode_service(mapzen_geocode_req_s *req_details, mapzen_geocode_cb c
                                        MAP_DEBUG("TOP LEFT >>><<< LATITUDE : %f, LONGITUDE : %f", req_details->boundary->rect.top_left.latitude, req_details->boundary->rect.top_left.longitude);
                                        MAP_DEBUG("BOTTOM RIGHT >>><<< LATITUDE : %f, LONGITUDE : %f", req_details->boundary->rect.bottom_right.latitude, req_details->boundary->rect.bottom_right.longitude);
 
-                                       query_geocode_within_bounds(req_details->maps_key, req_details->address, req_details->boundary->rect.top_left, req_details->boundary->rect.bottom_right, req_details->num_res, queryData);
+                                       query_geocode_within_bounding_box(req_details->maps_key, req_details->address, req_details->boundary->rect.top_left, req_details->boundary->rect.bottom_right, req_details->num_res, queryData);
 
                                } else if (req_details->boundary->type == MAPZEN_BOUNDARY_CIRCLE) {
 
-                                       coords_s *top_left = NULL, *bottom_right = NULL;
                                        coords_s circle = req_details->boundary->circle.center;
-                                       gdouble radius = (req_details->boundary->circle.radius) * 0.001;
-
                                        MAP_DEBUG("User input LATITUDE : %f, LONGITUDE : %f", circle.latitude, circle.longitude);
-
-                                       /* Calculate the top left coordinate of bounding box. */
-                                       calculate_point(circle.latitude, circle.longitude, 315, radius, &top_left);
-
-                                       /* Calculate the bottom right coordinate of bounding box. */
-                                       calculate_point(circle.latitude, circle.longitude, 135, radius, &bottom_right);
-
-                                       if ((top_left != NULL) && (bottom_right != NULL)) {
-                                               MAP_DEBUG("Top Left LATITUDE : %f, LONGITUDE : %f", top_left->latitude, top_left->longitude);
-                                               MAP_DEBUG("Bottom Right LATITUDE : %f, LONGITUDE : %f", bottom_right->latitude, bottom_right->longitude);
-
-                                               query_geocode_within_bounds(req_details->maps_key, req_details->address, *top_left, *bottom_right, req_details->num_res, queryData);
-
-                                               g_free(top_left);
-                                               top_left = NULL;
-
-                                               g_free(bottom_right);
-                                               bottom_right = NULL;
-                                       }
+                                       query_geocode_within_circle(req_details->maps_key, req_details->address, circle, req_details->boundary->circle.radius, req_details->num_res, queryData);
 
                                } else {
                                        query_geocode(req_details->maps_key, req_details->address, req_details->num_res, queryData);
index a7a33810920eca9f8b7810cba5060379801ccd52..9f5e2f2e2541d467515d66f829e64b9c1e8041f2 100644 (file)
 #include <pthread.h>
 #include <dlog.h>
 #include "mapzen_route.hpp"
+
+extern "C" {
 #include "mapzen_types.h"
 #include "mapzen_server_private.h"
 #include "mapzen_debug.h"
 #include "mapzen_queue.h"
 #include "mapzen_restcurl.h"
 #include "mapzen_util.h"
+}
 
 #include "rapidjson/rapidjson.h"
 #include "rapidjson/allocators.h"
@@ -42,7 +45,7 @@ extern "C" {
 
 std::string url_encode(const std::string& unencoded) {
    char* encoded = curl_escape(unencoded.c_str(), static_cast<int>(unencoded.size()));
-   dlog_print(DLOG_DEBUG, "URL:*","json after url encoding: " + *encoded);
+   MAP_DEBUG("route json after url encoding: " + *encoded);
    std::string encoded_str(encoded);
    curl_free(encoded);
    return encoded_str;
@@ -50,13 +53,36 @@ std::string url_encode(const std::string& unencoded) {
 
 int query_route(gchar *maps_key, coords_s startPoint, coords_s endPoint, route_type type, route_feature_avoids avoids, route_driving_style style, GList *waypoints, gpointer user_data)
 {
+       MAP_DEBUG("**********IN QUERY ROUTE!!**************");
        rapidjson::Document document;
        rapidjson::Document::AllocatorType& allocator = document.GetAllocator();
 
+       rapidjson::Value& costing = document.AddMember(rapidjson::Value("costing", allocator).Move(),
+                       rapidjson::Value(rapidjson::kStringType).Move(), allocator);
+       switch (type) {
+       case COSTING_AUTO:
+               costing.SetString("auto");
+               break;
+       case COSTING_AUTO_SHORTER:
+               costing.SetString("auto_shorter");
+               break;
+       case COSTING_PEDESTRIAN:
+               costing.SetString("pedestrian");
+               break;
+       case COSTING_MULTIMODAL:
+               costing.SetString("multimodal");
+               break;
+       case COSTING_BICYCLE:
+               costing.SetString("bicycle");
+               break;
+       default:
+               costing.SetString("auto");
+       }
+
        rapidjson::Value& locations = document.AddMember(rapidjson::Value("locations", allocator).Move(),
                        rapidjson::Value(rapidjson::kArrayType).Move(), allocator);
        rapidjson::Value& location = locations.AddMember(rapidjson::Value("", allocator).Move(),
-                                       rapidjson::Value(rapidjson::kObjectType).Move(), allocator);
+                       rapidjson::Value(rapidjson::kObjectType).Move(), allocator);
 
        int length = g_list_length(waypoints);
        if (length != 0) {
@@ -80,28 +106,6 @@ int query_route(gchar *maps_key, coords_s startPoint, coords_s endPoint, route_t
                location.AddMember<double>("lon", endPoint.longitude, allocator);
        }
 
-       rapidjson::Value& costing = document.AddMember(rapidjson::Value("costing", allocator).Move(),
-                       rapidjson::Value(rapidjson::kStringType).Move(), allocator);
-       switch (type) {
-       case COSTING_AUTO:
-               costing.SetString("auto");
-               break;
-       case COSTING_AUTO_SHORTER:
-               costing.SetString("auto_shorter");
-               break;
-       case COSTING_PEDESTRIAN:
-               costing.SetString("pedestrian");
-               break;
-       case COSTING_MULTIMODAL:
-               costing.SetString("multimodal");
-               break;
-       case COSTING_BICYCLE:
-               costing.SetString("bicycle");
-               break;
-       default:
-               costing.SetString("auto");
-       }
-
        rapidjson::Value& directions_options = document.AddMember(rapidjson::Value("directions_options", allocator).Move(),
                        rapidjson::Value(rapidjson::kObjectType).Move(), allocator);
        directions_options.AddMember("unit","mi",allocator);
diff --git a/src/mapzen_api.cpp b/src/mapzen_api.cpp
deleted file mode 100644 (file)
index 4455f96..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "mapzen_api.h"
-#include "mapzen_constants.h"
-#include "mapzen_utils.h"
-
-int MapzenPluginRoute(maps_coordinates_h origin, maps_coordinates_h destination,
-       maps_item_hashtable_h pref, maps_service_search_route_cb callback_func,
-       void* user_data, int* request_id)
-{
-       // Make sure pointers are valid
-       if (!origin || !destination || !callback_func || !request_id)
-               return ErrorType::kInvalidParameter;
-
-       // Check if origin and destination coordinates are valid
-       if (!MapzenUtils::IsValid(*(maps_coordinates_s*)origin) ||
-           !MapzenUtils::IsValid(*(maps_coordinates_s*)destination))
-               return ErrorType::kInvalidParameter;
-
-       int error = 0;
-       return error;
-}
index a87258b281c947a7cdbd47f0a678775f31262bf8..4184ea5362572e445d85347f84dd87ea876fa09d 100644 (file)
@@ -664,7 +664,7 @@ static void __mapzen_route_cb(mapzen_error_e result, int request_id, mapzen_rout
        callback_info_route *calldata_route = (callback_info_route *) user_data;
 
        if (route_info) {
-/*             maps_route_h route;
+               maps_route_h route;
                maps_route_create(&route);
 
                maps_coordinates_h top_left;
@@ -684,30 +684,30 @@ static void __mapzen_route_cb(mapzen_error_e result, int request_id, mapzen_rout
                maps_distance_unit_e unit = MAPS_DISTANCE_UNIT_M;
 
                switch (route_info->distance_unit) {
-               case ROUTE_UNIT_M:
+               case UNIT_M:
                        unit = MAPS_DISTANCE_UNIT_M;
                        break;
-               case ROUTE_UNIT_KM:
+               case UNIT_KM:
                        unit = MAPS_DISTANCE_UNIT_KM;
                        break;
-               case ROUTE_UNIT_FT:
+               /*case ROUTE_UNIT_FT:
                        unit = MAPS_DISTANCE_UNIT_FT;
                        break;
                case ROUTE_UNIT_YD:
                        unit = MAPS_DISTANCE_UNIT_YD;
-                       break;
+                       break;*/
                }
 
                maps_route_set_distance_unit(route, unit);
                maps_route_set_total_distance(route, route_info->distance);
                maps_route_set_total_duration(route, (long) route_info->time);
-               if (route_info->type == ROUTE_TYPE_FASTEST)
+               if (route_info->type == COSTING_AUTO)
                        maps_route_set_transport_mode(route, MAPS_ROUTE_TRANSPORT_MODE_CAR);
-               else if (route_info->type == ROUTE_TYPE_PEDESTRIAN)
+               else if (route_info->type == COSTING_PEDESTRIAN)
                        maps_route_set_transport_mode(route, MAPS_ROUTE_TRANSPORT_MODE_PEDESTRIAN);
-               else if (route_info->type == ROUTE_TYPE_BICYCLE)
+               else if (route_info->type == COSTING_BICYCLE)
                        maps_route_set_transport_mode(route, MAPS_ROUTE_TRANSPORT_MODE_BICYCLE);
-               else if (route_info->type == ROUTE_TYPE_MULTIMODAL)
+               else if (route_info->type == COSTING_MULTIMODAL)
                        maps_route_set_transport_mode(route, MAPS_ROUTE_TRANSPORT_MODE_PUBLICTRANSIT);
                else
                        maps_route_set_transport_mode(route, MAPS_ROUTE_TRANSPORT_MODE_CAR);
@@ -749,7 +749,7 @@ static void __mapzen_route_cb(mapzen_error_e result, int request_id, mapzen_rout
                        maps_route_maneuver_set_distance_to_next_instruction(man, maneuver->distance);
                        maps_route_maneuver_set_time_to_next_instruction(man, maneuver->time);
 
-                       maps_route_maneuver_set_turn_type(man, __convert_route_turn_type(maneuver->turn_type));
+                       //maps_route_maneuver_set_turn_type(man, __convert_route_turn_type(maneuver->turn_type));
 
                        // maneuver_set_traffic_direction(man, (traffic_direction_e)action_id);
 
@@ -814,7 +814,6 @@ static void __mapzen_route_cb(mapzen_error_e result, int request_id, mapzen_rout
                bool b = calldata_route->callback((maps_error_e)__convert_to_maps_error(result), calldata_route->reqID, 0, 1, route, calldata_route->data);
                if (!b)
                        return;
-                       */
        } else {
                calldata_route->callback((maps_error_e)__convert_to_maps_error(result), calldata_route->reqID, 0, 0, NULL, calldata_route->data);
        }
@@ -855,21 +854,21 @@ EXPORT_API int maps_plugin_search_route(const maps_coordinates_h origin, const m
 
        route_req->to.latitude = dest_lat;
        route_req->to.longitude = dest_lon;
-/*
+
        MAPS_LOGD("getting transport mode..");
        maps_route_transport_mode_e transport_mode;
        maps_preference_get_route_transport_mode(preference, &transport_mode);
 
        if (transport_mode == MAPS_ROUTE_TRANSPORT_MODE_CAR)
-               route_req->type = ROUTE_TYPE_FASTEST;
+               route_req->type = COSTING_AUTO;
        else if (transport_mode == MAPS_ROUTE_TRANSPORT_MODE_PEDESTRIAN)
-               route_req->type = ROUTE_TYPE_PEDESTRIAN;
+               route_req->type = COSTING_PEDESTRIAN;
        else if (transport_mode == MAPS_ROUTE_TRANSPORT_MODE_BICYCLE)
-               route_req->type = ROUTE_TYPE_BICYCLE;
+               route_req->type = COSTING_BICYCLE;
        else if (transport_mode == MAPS_ROUTE_TRANSPORT_MODE_PUBLICTRANSIT)
-               route_req->type = ROUTE_TYPE_MULTIMODAL;
+               route_req->type = COSTING_MULTIMODAL;
        else
-               route_req->type = ROUTE_TYPE_FASTEST;   // Keeping it as default
+               route_req->type = COSTING_AUTO; // Keeping it as default
 
        route_req->driving_style = DRIVING_STYLE_NORMAL;        // Keeping it as default
 
@@ -879,20 +878,20 @@ EXPORT_API int maps_plugin_search_route(const maps_coordinates_h origin, const m
 
        switch (unit) {
        case MAPS_DISTANCE_UNIT_M:
-               route_req->unit = ROUTE_UNIT_M;
+               route_req->unit = UNIT_M; //miles, not meters
                break;
        case MAPS_DISTANCE_UNIT_KM:
-               route_req->unit = ROUTE_UNIT_KM;
+               route_req->unit =       UNIT_KM;
                break;
        case MAPS_DISTANCE_UNIT_FT:
-               route_req->unit = ROUTE_UNIT_FT;
+               //route_req->unit = ROUTE_UNIT_FT;
                break;
        case MAPS_DISTANCE_UNIT_YD:
-               route_req->unit = ROUTE_UNIT_YD;
+               //route_req->unit = ROUTE_UNIT_YD;
                break;
        }
 
-       route_req->avoids = ROUTE_AVOID_NONE;
+       route_req->avoids = PENALTY_NONE;
        maps_route_feature_weight_e routeWeight;
        maps_preference_get_route_feature_weight(preference, &routeWeight);
 
@@ -901,22 +900,22 @@ EXPORT_API int maps_plugin_search_route(const maps_coordinates_h origin, const m
                maps_preference_get_route_feature(preference, &routeFeature);
 
                if (routeFeature == MAPS_ROUTE_FEATURE_TOLL)
-                       route_req->avoids = ROUTE_AVOID_TOLL_ROAD;
+                       route_req->avoids = PENALTY_TOLL_ROADS;
                else if (routeFeature == MAPS_ROUTE_FEATURE_MOTORWAY)
-                       route_req->avoids = ROUTE_AVOID_LIMITED_ACCESS;
+                       route_req->avoids = PENALTY_LIMITED_ACCESS;
                else if ((routeFeature == MAPS_ROUTE_FEATURE_BOATFERRY) || (routeFeature == MAPS_ROUTE_FEATURE_RAILFERRY))
-                       route_req->avoids = ROUTE_AVOID_FERRY;
+                       route_req->avoids = PENALTY_USE_FERRY;
                else if (routeFeature == MAPS_ROUTE_FEATURE_DIRTROAD)
-                       route_req->avoids = ROUTE_AVOID_UNPAVED;
+                       route_req->avoids =     PENALTY_USE_UNPAVED;
                else
-                       route_req->avoids = ROUTE_AVOID_NONE;
+                       route_req->avoids = PENALTY_NONE;
        }
 
        route_req->way_points = NULL;
 
        *request_id = ++__request_id;
        calldata_route->reqID = __request_id;
-*/
+
        int ret = mapzen_start_route(route_req, __mapzen_route_cb, __request_id, (void *)calldata_route);
 
        return __convert_to_maps_error(ret);
@@ -948,21 +947,21 @@ EXPORT_API int maps_plugin_search_route_waypoints(const maps_coordinates_h *wayp
 
        route_req->to.latitude = 0.0;
        route_req->to.longitude = 0.0;
-/*
+
        MAPS_LOGD("getting transport mode..");
        maps_route_transport_mode_e transport_mode;
        maps_preference_get_route_transport_mode(preference, &transport_mode);
 
        if (transport_mode == MAPS_ROUTE_TRANSPORT_MODE_CAR)
-               route_req->type = ROUTE_TYPE_FASTEST;
+               route_req->type = COSTING_AUTO;
        else if (transport_mode == MAPS_ROUTE_TRANSPORT_MODE_PEDESTRIAN)
-               route_req->type = ROUTE_TYPE_PEDESTRIAN;
+               route_req->type = COSTING_PEDESTRIAN;
        else if (transport_mode == MAPS_ROUTE_TRANSPORT_MODE_BICYCLE)
-               route_req->type = ROUTE_TYPE_BICYCLE;
+               route_req->type = COSTING_BICYCLE;
        else if (transport_mode == MAPS_ROUTE_TRANSPORT_MODE_PUBLICTRANSIT)
-               route_req->type = ROUTE_TYPE_MULTIMODAL;
+               route_req->type = COSTING_MULTIMODAL;
        else
-               route_req->type = ROUTE_TYPE_FASTEST;   // Keeping it as default
+               route_req->type = COSTING_AUTO; // Keeping it as default
 
        route_req->driving_style = DRIVING_STYLE_NORMAL;        // Keeping it as default
 
@@ -972,20 +971,20 @@ EXPORT_API int maps_plugin_search_route_waypoints(const maps_coordinates_h *wayp
 
        switch (unit) {
        case MAPS_DISTANCE_UNIT_M:
-               route_req->unit = ROUTE_UNIT_M;
+               route_req->unit = UNIT_M;  //miles, not meters
                break;
        case MAPS_DISTANCE_UNIT_KM:
-               route_req->unit = ROUTE_UNIT_KM;
+               route_req->unit = UNIT_KM;
                break;
        case MAPS_DISTANCE_UNIT_FT:
-               route_req->unit = ROUTE_UNIT_FT;
+       //      route_req->unit = ROUTE_UNIT_FT;
                break;
        case MAPS_DISTANCE_UNIT_YD:
-               route_req->unit = ROUTE_UNIT_YD;
+       //      route_req->unit = ROUTE_UNIT_YD;
                break;
        }
 
-       route_req->avoids = ROUTE_AVOID_NONE;
+       route_req->avoids = PENALTY_NONE;
        maps_route_feature_weight_e routeWeight;
        maps_preference_get_route_feature_weight(preference, &routeWeight);
 
@@ -994,15 +993,15 @@ EXPORT_API int maps_plugin_search_route_waypoints(const maps_coordinates_h *wayp
                maps_preference_get_route_feature(preference, &routeFeature);
 
                if (routeFeature == MAPS_ROUTE_FEATURE_TOLL)
-                       route_req->avoids = ROUTE_AVOID_TOLL_ROAD;
+                       route_req->avoids = PENALTY_TOLL_ROADS;
                else if (routeFeature == MAPS_ROUTE_FEATURE_MOTORWAY)
-                       route_req->avoids = ROUTE_AVOID_LIMITED_ACCESS;
+                       route_req->avoids = PENALTY_LIMITED_ACCESS;
                else if ((routeFeature == MAPS_ROUTE_FEATURE_BOATFERRY) || (routeFeature == MAPS_ROUTE_FEATURE_RAILFERRY))
-                       route_req->avoids = ROUTE_AVOID_FERRY;
+                       route_req->avoids = PENALTY_USE_FERRY;
                else if (routeFeature == MAPS_ROUTE_FEATURE_DIRTROAD)
-                       route_req->avoids = ROUTE_AVOID_UNPAVED;
+                       route_req->avoids = PENALTY_USE_UNPAVED;
                else
-                       route_req->avoids = ROUTE_AVOID_NONE;
+                       route_req->avoids = PENALTY_NONE;
        }
 
        // Waypoints
@@ -1031,7 +1030,7 @@ EXPORT_API int maps_plugin_search_route_waypoints(const maps_coordinates_h *wayp
 
        *request_id = ++__request_id;
        calldata_route->reqID = __request_id;
-*/
+
        int ret = mapzen_start_route(route_req, __mapzen_route_cb, __request_id, (void *)calldata_route);
 
        return __convert_to_maps_error(ret);