-[submodule "rapidjson"]
- path = rapidjson
- url = https://github.com/miloyip/rapidjson
+[submodule "inc/rapidjson"]
+ path = inc/rapidjson
+ url = https://github.com/miloyip/rapidjson.git
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fvisibility=hidden -fPIC -Wall -Werror")
SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -Wall -fPIC -std=c++0x -fvisibility=hidden")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -Wall -fPIC -std=c++11 -fvisibility=hidden")
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIBDIR}")
-# Main Include file
+# Includes
SET(INC_DIR
inc
+ src/mapzen
+ external/rapidjson/include
)
INCLUDE_DIRECTORIES(
- ${INC_DIR}
+ ${INC_DIR}
)
#This file must be corrected
# Source Lists
SET(SRCS
# Maps API
- src/mapzen_utils.cpp
- src/mapzen_plugin.cpp
- src/mapzen_api.cpp
+ src/mapzen_plugin.c
+ src/mapzen/mapzen_api.c
+ src/mapzen/mapzen_geocode.c
+ src/mapzen/mapzen_jsonparser.cpp
+ src/mapzen/mapzen_place.c
+ src/mapzen/mapzen_queue.c
+ src/mapzen/mapzen_restcurl.c
+ src/mapzen/mapzen_revgeocode.c
+ src/mapzen/mapzen_route.cpp
+ src/mapzen/mapzen_util.c
)
ADD_LIBRARY(${pkg_name} SHARED ${SRCS})
--- /dev/null
+#!/bin/bash
+
+tar pczf packaging/deps.tar.gz --anchored external/rapidjson/include
Group: Location/Libraries
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
+Source1: deps.tar.gz
ExclusiveArch: %ix86 x86_64 %arm aarch64
BuildRequires: cmake
BuildRequires: pkgconfig(libxml-2.0)
BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(libcurl)
BuildRequires: pkgconfig(capi-maps-service)
BuildRequires: capi-maps-service-plugin-devel
BuildRequires: pkgconfig(capi-network-connection)
%prep
%setup -q
+%setup -q -T -D -a 1
%build
%if 0%{?tizen_build_binary_release_type_eng}
+++ /dev/null
-Subproject commit 3d5848a7cd3367c5cb451c6493165b7745948308
* limitations under the License.
*/
+#include <maps_coordinates.h>
+
#include <stdlib.h>
#include "rapidjson/rapidjson.h"
-#include "mapzen_jsonparser.h"
+#include "mapzen_jsonparser.hpp"
#include "mapzen_queue.h"
#include "mapzen_debug.h"
#include "mapzen_util.h"
+#include <string>
+#include <vector>
+
#define ROUTE_UNIT_CONVERSION_MILE_TO_M(x) (1609.34 * (x))
#define ROUTE_UNIT_CONVERSION_MILE_TO_KM(x) (1.60934 * (x))
#define ROUTE_UNIT_CONVERSION_MILE_TO_FT(x) (5280 * (x))
#define ROUTE_UNIT_CONVERSION_MILE_TO_YD(x) (1760 * (x))
-static route_unit __route_unit = ROUTE_UNIT_M;
+static route_unit __route_unit = UNIT_M;
static int __maneuver_index = 0;
static coords_s __destination_point;
+constexpr double kPolylinePrecision = 1E6;
+constexpr double kInvPolylinePrecision = 1.0 / kPolylinePrecision;
+
+
+//TODO: port this to c? or port the whole project to c++ or add all the proper externs
+void decode_shape(const std::string& encoded,
+ std::vector<maps_coordinates_s>& output)
+{
+ // what byte are we looking at
+ size_t i = 0;
+
+ // Handy lambda to turn a few bytes of an encoded string into an integer
+ auto deserialize = [&encoded, &i](const int previous) {
+ // Grab each 5 bits and mask it in where it belongs using the shift
+ int byte, shift = 0, result = 0;
+ do {
+ byte = static_cast<int>(encoded[i++]) - 63;
+ result |= (byte & 0x1f) << shift;
+ shift += 5;
+ } while (byte >= 0x20);
+
+ // Undo the left shift from above or the bit flipping and add
+ // to previous since its an offset
+ return previous + (result & 1 ? ~(result >> 1) : (result >> 1));
+ };
+
+ // Iterate over all characters of the encoded shape string
+ int last_lon = 0, last_lat = 0;
+ while (i < encoded.length())
+ {
+ // Decode the coordinates, lat first
+ int lat = deserialize(last_lat);
+ int lon = deserialize(last_lon);
+
+ // Shift the decimal point 5 places to the left and add to the output
+ maps_coordinates_s ll;
+ ll.latitude = static_cast<double>(lat) * kInvPolylinePrecision;
+ ll.longitude = static_cast<double>(lon) * kInvPolylinePrecision;
+ output.emplace_back(std::move(ll));
+
+ // Remember the last one we encountered
+ last_lat = lat;
+ last_lon = lon;
+ }
+}
+
static mapzen_error_e __convert_status(int status)
{
#include "mapzen_queue.h"
#include "mapzen_geocode.h"
#include "mapzen_revgeocode.h"
-#include "mapzen_route.h"
+#include "mapzen_route.hpp"
#include "mapzen_place.h"
#include "mapzen_restcurl.h"
#include "mapzen_util.h"
#include "mapzen_debug.h"
-#include <json-glib/json-glib.h>
pthread_mutex_t __requestLock;
static GAsyncQueue *responseQueue = NULL;
#include <network/net_connection.h>
#include "mapzen_restcurl.h"
#include "mapzen_types.h"
-#include "mapzen_jsonparser.h"
+#include "mapzen_jsonparser.hpp"
#include "mapzen_debug.h"
#define RESTCURL_USE_MULTI_CURL
#include <stdio.h>
#include <glib.h>
#include <pthread.h>
-#include "mapzen_route.h"
+#include "mapzen_route.hpp"
#include "mapzen_types.h"
#include "mapzen_server_private.h"
#include "mapzen_debug.h"
#define ROUTE_URL "https://valhalla.mapzen.com/route?api_key=%s&json="
-int query_route(gchar *maps_key, coords_s startPoint, coords_s endPoint, costing costing, feature_penalties avoids, route_driving_style style, GList *waypoints, gpointer user_data)
+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)
{
char url[1024] = "";
char tmpStr[512];
STRCPY(url, tmpStr);
- STRCAT(url, '"directions_options":{"units":"mi"}'); /* Keeping default as miles and conversion will be done later */
+ /*STRCAT(url, '"directions_options":{"units":"mi"}'); Keeping default as miles and conversion will be done later
if (costing == COSTING_AUTO)
STRCAT(url, '"costing":"auto"');
} else {
snprintf(tmpStr, sizeof(tmpStr), '"locations":[{"lat":%f,"lon":%f},{"lat":%f,"lon":%f}]', startPoint.latitude, startPoint.longitude, endPoint.latitude, endPoint.longitude);
STRCAT(url, tmpStr);
- }
+ }*/
//TODO: url encode (curl_escape) the json part of the request
#include "mapzen_api.h"
#include "mapzen_types.h"
-int query_route(gchar *maps_key, coords_s startPoint, coords_s endPoint, costing costing, feature_penalties avoids, route_driving_style style, GList *waypoints, gpointer user_data);
+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);
#endif /* _MAPZEN_ROUTE_H_ */