src/here_multirevgeocode.cpp
src/here_route.cpp
src/here_utils.cpp
+ src/here_view.cpp
+ src/here_view_objects.cpp
# UC-DBus
src/heremaps-uc-dbus.c
#define TIZEN_CUSTOMIZATION
/* sub-features */
+#define TIZEN_SUPPORT_LIMIT_RETRYING_FETCHING_TILES /* limit the number of retrying when failed fetching tiles */
+#define TIZEN_SUPPORT_TILE_FILE_CACHE
#define TIZEN_SUPPORT_POST_METHOD
#define TIZEN_SUPPORT_CRYPTO_LOCK /* mutex locking system for SSL */
+#define TIZEN_SUPPORT_OPTIMIZATION_OF_REDRAWING
/* configuration */
#define TIZEN_CFG_CURL_TIMEOUT 20 /* seconds */
int bytes_per_pixel;
BitmapPixelFormat pixel_format;
unsigned char* buffer;
+ pthread_mutex_t mutex;
void BitBlt(int xDest, int yDest, unsigned char *pSrcBuffer, int xSour, int ySour, int wSour, int hSour, int nPitch, unsigned long opacity = 255);
};
class Canvas : public Object
{
public:
+ typedef enum
+ {
+ LINESTYLE_SOLID,
+ LINESTYLE_DOTTED,
+ LINESTYLE_MAX,
+ } LineStyleType;
typedef std::vector<FloatPoint*> tPoint;
Canvas(void);
result FillPolygon(const Color& color, const tPoint& points);
result DrawPolyline(const tPoint& points);
result SetLineWidth(int width);
+ result SetLineStyle(LineStyleType lineStyle);
void SetForegroundColor(const Color& fgColor);
protected:
void* _pNativeGfxEngine;
private:
unsigned long __ComposeColor(unsigned long color32, int opacity);
void __SetColor(cairo_t* pCairo, unsigned long composedColor);
+ void __SetLineStyle(cairo_t* pCairo, LineStyleType lineStyle);
unsigned long* __pBuffer;
unsigned long __fgColor;
cairo_operator_t __cairo_operator;
Color __fgColorNative;
int __fgOpacity;
+ LineStyleType __lineStyle;
};
TIZEN_MAPS_END_NAMESPACE
#ifdef TIZEN_MIGRATION
#include "graphic/FloatRectangle.h"
#include "graphic/Color.h"
+#include "internal/DoublePoint3.h"
#else
#include <FGraphics.h>
#endif
unsigned int width,
unsigned int height);
+#ifdef TIZEN_MIGRATION
+ /**
+ * This method renders a square, using the rectangle and texture specified
+ * by the caller.
+ *
+ * @param aRect A constant reference to the double points to render.
+ *
+ * @param uTexture A value of the id of the texture object to apply.
+ *
+ * @param sx0 A value providing the x coordinate of the top left corner of
+ * the rectangle in the tile grid.
+ *
+ * @param sy0 A value providing the y coordinate of the top left corner of
+ * the rectangle in the tile grid.
+ *
+ * @param sx1 A value providing the x coordinate of the bottom right corner of
+ * the rectangle in the tile grid.
+ *
+ * @param sy1 A value providing the y coordinate of the bottom right corner of
+ * the rectangle in the tile grid.
+ */
+ bool RenderQuad(const std::vector<DoublePoint3>& aRect, unsigned int uTextureId, float sx0=0.f, float sy0=1.f, float sx1=1.f, float sy1=0.f);
+#endif
+
/**
* This method renders a square, using the rectangle and texture specified
* by the caller.
//classes allowed to access this internal instance
friend class RestItem;
friend class QueryListener;
+#ifdef TIZEN_SUPPORT_TILE_FILE_CACHE
+ friend class TileFetcherQuery;
+#endif
//members
class RestEngineImpl;
*/
virtual bool IsValid() const;
+#ifdef TIZEN_MIGRATION
+ /**
+ * This method retrieves the marker z-order.
+ *
+ * @return A value indicating z-order to the bitmap.
+ */
+ int GetZorder() const;
+
+ /**
+ * This method sets the marker z-order.
+ *
+ * @param nZorder A constant value of z-order.
+ */
+ void SetZorder(int nZorder);
+#endif
+
private:
HERE_MAPS_NO_COPY_NO_ASSIGN(GeoMapObjectMarker);
#ifdef TIZEN_MIGRATION
#include "graphic/Color.h"
+#include "graphic/Canvas.h"
#else
namespace Tizen { namespace Graphics { class Color; } }
#endif
*/
void SetStrokeThicknessChangedNotifier(StrokeThicknessChangedFunctor strokeThicknessChanged);
+#ifdef TIZEN_CUSTOMIZATION
+ /**
+ * This method retrieves a value indicating the polyline stroke type in
+ * pixels.
+ *
+ * @return A value indicating the stroke thickness in pixels.
+ */
+ Tizen::Maps::Canvas::LineStyleType GetStrokeType() const;
+
+ /**
+ * This method sets a value indicating the polyline stroke type in
+ * pixels.
+ *
+ * @strokeThickness A value indicating the stroke thickness in pixels.
+ */
+ void SetStrokeType(Tizen::Maps::Canvas::LineStyleType type);
+
+ /**
+ * This typedef defines a function object as a type. The function object can
+ * be called when the polyline stroke type has changed. A function
+ * object of this type returns <code>void</code> and receives a constant
+ * reference to a <code>GeoMapObject</code> as an argument.
+ */
+ typedef std::tr1::function<void (const GeoMapObject&)> StrokeTypeChangedFunctor;
+
+ /**
+ * This method sets a callback to be invoked when the polyline stroke
+ * type has changed.
+ *
+ * @param strokeTypeChanged A function object to be called when the polyline
+ * stroke type has changed.
+ */
+ void SetStrokeTypeChangedNotifier(StrokeTypeChangedFunctor strokeTypeChanged);
+#endif
+
/**
* This method retrieves the bounding box of the polyline.
- *
+ *
* @return An object encapsulating the bounding box of the given polyline
* object.
*/
/**
* This method retrieves the object type of the given polyline.
- *
+ *
* @return A member of the enumerated data type indicating the type of the
* given polyline object.
*/
Tizen::Maps::Dimension& GetScreenSize();
GeoCoordinates& GetGeoCenter();
double& GetLevel();
+#ifdef TIZEN_MIGRATION
+public:
+#endif
double& GetHeading();
private:
*/
void AbortLoading();
+#ifdef TIZEN_SUPPORT_LIMIT_RETRYING_FETCHING_TILES
+ int GetTryCount();
+
+ int SetTryCount(int cnt);
+#endif
+
private:
HERE_MAPS_NO_COPY_NO_ASSIGN(GeoTile);
MT_Terrain_Day, ///< Indicates a terrain day map.
MT_Hybrid_Day, ///< Indicates a hybrid day map
/// (satellite, with roads and labels).
+#ifdef TIZEN_MIGRATION
+ MT_Normal_Day_Grey,
+ MT_Normal_Day_Transit,
+ MT_Normal_Night_Transit,
+ MT_Normal_Traffic_Day,
+ MT_Normal_Traffic_Night,
+ MT_Normal_Day_Custom,
+ MT_Normal_Night,
+ MT_Normal_Night_Grey,
+ MT_Pedestrian_Day,
+ MT_Pedestrian_Day_Mobile,
+ MT_Pedestrian_Night,
+ MT_Pedestrian_Night_Mobile,
+ MT_Carnav_Day_Grey,
+ MT_Normal_Day_Mobile,
+ MT_Normal_Day_Grey_Mobile,
+ MT_Normal_Day_Transit_Mobile,
+ MT_Normal_Night_Transit_Mobile,
+ MT_Normal_Night_Mobile,
+ MT_Normal_Night_Grey_Mobile,
+ MT_Reduced_Day,
+ MT_Reduced_Night,
+ MT_Hybrid_Day_Transit,
+ MT_Hybrid_Grey_Day,
+ MT_Hybrid_Traffic_Day,
+ MT_Hybrid_Day_Mobile,
+ MT_Terrain_Day_Mobile,
+#endif
MT_Last_Entry_Undefined ///< Indicates that the map type is not
/// defined.
};
*
* @param zoomLevel A value indicating the new zoom level.
*/
+ #ifdef TIZEN_MIGRATION
+ void SetZoomLevel(double zoomLevel, bool bUpdate=true);
+ #else
void SetZoomLevel(double zoomLevel);
+ #endif
/**
* This method retrieves the map zoom level.
*/
void InvalidateMapObjects();
+#ifdef TIZEN_SUPPORT_OPTIMIZATION_OF_REDRAWING
+ /**
+ * This method invalidates (discards) all the map markers.
+ */
+ void InvalidateMapMarkers();
+#endif
+
/**
* This method invalidates (clears) the cache.
*/
* @param slot A function object to be called when the map has
* been updated.
*/
-#ifdef TIZEN_MIGRATION
- void SetUpdateMapSignal(UpdateMapSignalFunctor slot, void *data);
-#else
void SetUpdateMapSignal(UpdateMapSignalFunctor slot);
-#endif
/**
* This method sets the map type.
* @param __glapi A pointer to a structure of the Evas GL API object.
*/
void SetEvasGlApi(Evas_GL_API *__glapi);
+
+ /**
+ * This typedef defines a function object as a type. The function object can
+ * be called when the map has been ready after initialized. A function object of
+ * this type returns <code>void</code> and receives no arguments.
+ */
+ typedef void(*ReadyMapSignalFunctor)(void);
+
+ /**
+ * This method sets a callback to be invoked when the map has
+ * been ready after initialization.
+ *
+ * @param slot A function object to be called when the map has
+ * been ready after initialization.
+ */
+ void SetReadyMapSignal(ReadyMapSignalFunctor callback);
+
+ /**
+ * This method sets the angle of the map.
+ *
+ * @param angle The angle of the map [-360~360].
+ */
+ void SetAngle(double angle);
+
+ /**
+ * This method retrieves the angle of the map.
+ *
+ * @return A value indicating the angle of the map.
+ */
+ double GetAngle();
+
+ /**
+ * This method sets a Boolean value indicating if the scale bar is enabled or not.
+ *
+ * @param enable <code>true</code> if the given status is enabled,
+ * otherwise <code>false</code>.
+ */
+ void SetScalebar(bool enable);
+
+ /**
+ * This method retrieves a Boolean value indicating if the scale bar is enabled or not.
+ *
+ * @return <code>true</code> if the scale bar is enabled, otherwise <code>false</code>.
+ */
+ bool GetScalebar() const;
+#endif
+
+#ifdef TIZEN_SUPPORT_TILE_FILE_CACHE
+ /**
+ * This method invalidates (clears) the file cache for tiles.
+ */
+ void ClearTileFileCache();
#endif
private:
int GetDisplayDPI() const;
void ClearMarkers();
void SetRootPixmap(DrawableBitmapPtr rootPixmap);
+#ifdef TIZEN_MIGRATION
+ void ExtendLimitOfCachedTiles();
+ bool DrawScalebar(UInt uWidth, UInt uHeight, UInt aMapX = 0, UInt aMapY = 0);
+#endif
private:
friend class GeoMapObject;
--- /dev/null
+//
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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 TILEFETCHERCACHE_H
+#define TILEFETCHERCACHE_H
+
+#include <list>
+#include <time.h>
+#include <glib.h>
+#include "common/HereMaps_global.h"
+
+#include "tilefetcher/TileFetcherQueryListener.h"
+#include "common/RestItemHandle.h"
+#include "common/TileKey.h"
+
+
+
+TIZEN_MAPS_BEGIN_NAMESPACE
+
+class TileCache
+{
+public:
+ int hash;
+ long size;
+ long hit;
+ long timestamp;
+
+ TileCache(int _hash, long _size=0, long _hit=0)
+ {
+ hash = _hash;
+ size = _size;
+ hit = _hit;
+
+ time_t _time;
+ time(&_time);
+ timestamp = _time;
+ }
+};
+
+typedef std::list<TileCache> TileCacheList;
+
+class TileFetcherCache
+{
+public:
+ TileFetcherCache();
+
+ virtual ~TileFetcherCache();
+
+ static TileFetcherCache& GetInstance();
+
+ void shutdown();
+
+ bool remove(const int hash);
+
+ bool isFound(const int hash);
+
+ TileCacheList::iterator find(const int hash);
+
+ unsigned long read(const int hash, unsigned char *&buffer, unsigned long &size);
+
+ unsigned long write(const int hash, const unsigned char *buffer, const unsigned long size);
+
+ void clearCache();
+
+ Here::Maps::RestItemHandle::RequestId load(const Here::Maps::TileKey &rKey, Here::Maps::TileFetcherQueryListener &rListener);
+
+ void abort(void *pArg);
+
+ void fire(void *pArg);
+
+private:
+ HERE_MAPS_NO_COPY_NO_ASSIGN(TileFetcherCache);
+
+ void __initCache();
+
+ static bool __compareTileCache(const TileCache& first, const TileCache& second);
+
+ bool __checkCapacity(void);
+
+ bool __isAvailableSpace(void);
+
+ bool __isAvailableCount(void);
+
+ bool __getCachePath(char *path, int size);
+
+ bool __getFilePath(const int hash, char *path, int size);
+
+ bool __getFilePath(const char *fname, char *path, int size);
+
+ int __parseHash(const char *fname);
+
+ static gboolean __fireTimer(gpointer data);
+
+ static gboolean __fireIdler(gpointer data);
+
+ static void __timerDestroy(gpointer data);
+
+ static void __idlerDestroy(gpointer data);
+
+ //members
+ class TileFetcherCacheImpl;
+ TileFetcherCacheImpl* m_pImpl;
+
+ char __cachePath[256];
+};
+
+TIZEN_MAPS_END_NAMESPACE
+
+#endif
void OnReplySuccess(BaseReply& rReply);
+ #ifdef TIZEN_MIGRATION
+ void OnFailure(const BaseReply& rReply);
+ #endif
+
};
HERE_MAPS_END_NAMESPACE
#define _LOCATION_HERE_API_H_
#include <maps_plugin.h>
+#include <maps_view.h>
-int HerePluginInit(maps_plugin_h *hPlugin);
+int HerePluginInit(maps_plugin_h *hPlugin, const char *module = NULL);
int HerePluginShutdown(maps_plugin_h hPlugin);
int HerePluginCancelRequest(int nReqId);
+/* Mapping API */
+
+int HerePluginSetMapView(const maps_view_h hView, maps_plugin_map_view_ready_cb pCbFunc);
+
+int HerePluginRenderMap(const maps_coordinates_h mapsCoord, const double dZoom, const double dAngle,
+ maps_plugin_render_map_cb pCbFunc, void* pUserData, int* nReqId);
+
+int HerePluginRenderMapArea(const maps_area_h hArea, const double dZoom, const double dAngle,
+ maps_plugin_render_map_cb pCbFunc, void* pUserData, int* nReqId);
+
+int HerePluginMoveCenter(const int delta_x, const int delta_y,
+ maps_plugin_render_map_cb pCbFunc, void* pUserData, int* nReqId);
+
+int HerePluginSetScalebar(bool enable);
+
+int HerePluginGetScalebar(bool *enabled);
+
+int HerePluginDrawMap(Evas* pCanvas, const int x, const int y,
+ const int nWidth, const int nHeight);
+
+int HerePluginGetCenter(maps_coordinates_h *center);
+
+int HerePluginScreenToGeography(const int x, const int y, maps_coordinates_h *mapsCoord);
+
+int HerePluginGeographyToScreen(const maps_coordinates_h mapsCoord, int *x, int *y);
+
+int HerePluginGetMinZoomLevel(int *nMinZoomLevel);
+
+int HerePluginGetMaxZoomLevel(int *nMaxZoomLevel);
+
+int HerePluginOnViewObject(const maps_view_object_h object,
+ const maps_view_object_operation_e operation);
+
#endif //_LOCATION_HERE_API_H_
\ No newline at end of file
HERE_SVC_REV_GEOCODE,
HERE_SVC_PLACE,
HERE_SVC_ROUTE,
- HERE_SVC_MULTI_REV_GEOCODE
+ HERE_SVC_MULTI_REV_GEOCODE,
+ HERE_SVC_VIEW
};
void* CreateInstance(HereSvcType nHereSvc, void* pCbFunc = NULL, void* pUserData = NULL, int *nReqId = NULL);
#include <maps_preference.h>
#include <maps_route_maneuver.h>
#include <maps_service.h>
+#include <maps_view.h>
//plug-in header
#include "here_types.h"
#include <common/GeoCoordinates.h>
#include <common/GeoBoundingBox.h>
#include <common/GeoBoundingCircle.h>
+#include <maps/GeoTiledMap.h>
#define HERE_PLUGIN_BEGIN_NAMESPACE namespace Here { namespace PlugIn {
#define HERE_PLUGIN_END_NAMESPACE }}
static GeoRouteQuery::FeatureType Convert(maps_route_feature_e nVal);
static GeoRouteQuery::FeatureWeight Convert(maps_route_feature_weight_e nVal);
static Maneuver::InstructionDirection Convert(maps_route_turn_type_e nVal);
+ static GeoTiledMap::MapType Convert(maps_view_type_e nMapType, bool bBuildings, bool bTraffic, bool bPublicTransit);
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);
--- /dev/null
+/*
+ * 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 HERE_VIEW_H
+#define HERE_VIEW_H
+
+#include <deque>
+
+//plug-in header
+#include "here_manager.h"
+#include "here_base.h"
+#include "here_view_objects.h"
+
+//maps-service header
+#include <maps_service.h>
+#include <maps_view.h>
+
+//map engine header
+#include <maps/GeoTiledMap.h>
+#include <Ecore.h>
+#include <Ecore_Evas.h>
+#include <graphic/Grp_Util.h>
+#include <maps/GeoMapObjectMarker.h>
+#include <maps/GeoMapObjectPolygon.h>
+#include <maps/GeoMapObjectPolyline.h>
+
+HERE_PLUGIN_BEGIN_NAMESPACE
+
+using namespace HERE_MAPS_NAMESPACE_PREFIX;
+
+
+typedef struct _GLData
+{
+ Here::Maps::GeoTiledMap *map;
+
+ Evas_Object *img;
+ Evas_GL_Context *ctx;
+ Evas_GL_Surface *sfc;
+ Evas_GL_Config *cfg;
+ Evas_GL *gl;
+ Evas_GL_API *api;
+
+ bool isInitialized;
+
+ int x, y, w, h;
+ double lat, lng, zoom, angle;
+
+ maps_view_h hView;
+
+ // to remove // UpdatedObjects updatedObjects;
+ HereViewObjects visualObjects;
+ PendingObjects pendingObjects;
+ Ecore_Idler *idler;
+ bool redraw;
+
+ maps_plugin_map_view_ready_cb readyCb;
+} GLData;
+
+class HereView
+: public HereBase
+{
+public:
+ HereView(void *pCbFunc, void *pUserData, int nReqId);
+ ~HereView();
+
+ here_error_e Init(const maps_view_h hView, maps_plugin_map_view_ready_cb pCbFunc);
+ static here_error_e Close();
+ here_error_e RenderMap(const maps_coordinates_h mapsCoord, double dZoom, double dAngle);
+ here_error_e RenderMapByArea(const maps_area_h hArea, double dZoom, double dAngle);
+ static here_error_e DrawMap(Evas* pCanvas, int x, int y, int nWidth, int nHeight);
+ here_error_e MoveCenter(int delta_x, int delta_y);
+ here_error_e SetScalebar(bool enable);
+ here_error_e GetScalebar(bool *enabled);
+ here_error_e GetCenter(maps_coordinates_h *center);
+ here_error_e ScreenToGeolocation(int x, int y, maps_coordinates_h *mapsCoord);
+ here_error_e GeolocationToScreen(const maps_coordinates_h mapsCoord, int *x, int *y);
+
+ static here_error_e GetMinZoomLevel(int *nMinZoomLevel);
+ static here_error_e GetMaxZoomLevel(int *nMaxZoomLevel);
+ static here_error_e OnViewObject(const maps_view_object_h object, maps_view_object_operation_e operation);
+
+ static void RenderingCb(void *data);
+ static bool foreachObject(int index, int total, maps_view_object_h object, void *user_data);
+ static GLData* GetImplHandler();
+
+private:
+
+ here_error_e InitOpenGL(GLData *gld);
+ here_error_e InitOpenGLSurface(GLData *gld);
+ here_error_e InitMap(GLData *gld, maps_plugin_map_view_ready_cb pCbFunc);
+ static void __readyCb();
+ static Eina_Bool __idlerCb(void *data);
+ static void __renderingCb(void *data);
+ static void __pixelGetCb(void *data, Evas_Object *obj);
+ static void __processViewObject(const maps_view_object_h object, maps_view_object_operation_e operation);
+ void __setMapType();
+
+ static GLData *m_pImpl;
+
+};
+
+HERE_PLUGIN_END_NAMESPACE
+
+#endif
--- /dev/null
+/*
+ * 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 HERE_VIEW_OBJECTS_H
+#define HERE_VIEW_OBJECTS_H
+
+#include <deque>
+
+//plug-in header
+#include "here_manager.h"
+#include "here_base.h"
+
+//maps-service header
+#include <maps_service.h>
+#include <maps_view.h>
+#include <maps_view_object_plugin.h>
+
+//map engine header
+#include <maps/GeoTiledMap.h>
+#include <maps/GeoMapObjectMarker.h>
+#include <maps/GeoMapObjectPolygon.h>
+#include <maps/GeoMapObjectPolyline.h>
+
+
+HERE_PLUGIN_BEGIN_NAMESPACE
+
+using namespace HERE_MAPS_NAMESPACE_PREFIX;
+
+
+typedef std::map<maps_view_object_h, const GeoMapObject*> VisualObjects;
+typedef std::pair<maps_view_object_h, const maps_view_object_operation_e> PendingObject;
+typedef std::deque<PendingObject> PendingObjects;
+// to remove // typedef std::deque<maps_view_object_h> UpdatedObjects;
+
+class HereViewObjects
+{
+public:
+ HereViewObjects();
+ virtual ~HereViewObjects();
+
+ void set(GeoTiledMap *map, Evas *evas);
+ // to remove // void update(UpdatedObjects objects);
+
+ here_error_e add(maps_view_object_h hObj);
+ here_error_e move(maps_view_object_h hObj);
+ here_error_e update(maps_view_object_h hObj);
+ here_error_e setVisible(maps_view_object_h hObj);
+ here_error_e remove(maps_view_object_h hObj);
+ here_error_e removeAll();
+
+private:
+ here_error_e __add(maps_view_object_h hObj);
+ here_error_e __remove(maps_view_object_h hObj);
+ here_error_e __update(maps_view_object_h hObj, GeoMapObject *hereObject);
+ here_error_e __updateMarker(maps_view_object_h hMarker, GeoMapObjectMarker *hereMarker);
+ here_error_e __updatePolygon(maps_view_object_h hPolygon, GeoMapObjectPolygon *herePolygon);
+ here_error_e __updatePolyline(maps_view_object_h hPolyline, GeoMapObjectPolyline *herePolyline);
+ here_error_e __updateRoute(maps_view_object_h hRoute);
+ here_error_e __setVisible(maps_view_object_h hObj, bool bVisible);
+
+ static bool __foreachForCoordinates(int index, maps_coordinates_h coordinates, void *user_data);
+ static bool __foreachForAddingGroupObjects(int index, int total, maps_view_object_h object, void *user_data);
+ static bool __foreachForRemovingGroupObjects(int index, int total, maps_view_object_h object, void *user_data);
+ static bool __foreachForUpdatingGroupObjects(int index, int total, maps_view_object_h object, void *user_data);
+ static bool __foreachForSettingVisibleGroupObjects(int index, int total, maps_view_object_h object, void *user_data);
+
+ bool __resizeMarker(maps_view_object_h hMarker, const int originWidth, const int originHeight,
+ int *newWidth, int *newHeight, unsigned char **buffer);
+ bool __resizeBitmap(unsigned char **curBmp, int curWidth, int curHeight, int newWidth, int newHeight);
+
+ void __invalidate(maps_view_object_h hObj = NULL);
+
+ VisualObjects __currentObjects;
+ GeoTiledMap *__map;
+ Evas *__evas;
+ pthread_mutex_t __mutex;
+};
+
+HERE_PLUGIN_END_NAMESPACE
+
+#endif /* HERE_VIEW_OBJECTS_H */
+
-libheremaps-engine.so.1.0.6_9
\ No newline at end of file
+libheremaps-engine.so.1.0.6_11
\ 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_11
\ 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_11
\ 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_11
\ No newline at end of file
+[Version] maps-plugin-here_0.3.0
+[Date] 18 April 2016
+[Title] Added new Maps View APIs
+[Developer] Jongmun Woo <jongmun.woo@samsung.com>
+
+[Version] maps-plugin-here_0.2.0
+[Date] 11 Feb 2016
+[Title] Added new APIs for z-ordering and resizing.
+[Developer] Seechan Kim <cbible.kim@samsung.com>
+
[Version] maps-plugin-here_0.1.9
[Date] 21 Dec 2015
[Title] Fixed that some requests failed to be sent are not replied to the maps-service.
Name: maps-plugin-here
Summary: Tizen HERE Maps Plug-in Library
-Version: 0.2.0
+Version: 0.3.0
Release: 1
Group: Location/Libraries
License: Apache-2.0 and HERE
BuildRequires: pkgconfig(libpng)
BuildRequires: pkgconfig(cairo)
BuildRequires: boost-devel
+BuildRequires: capi-maps-service-devel
+BuildRequires: elementary-devel
+BuildRequires: pkgconfig(ecore-evas)
#
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
#include "here_multirevgeocode.h"
#include "here_place.h"
#include "here_route.h"
+#include "here_view.h"
#include <common/HereConfig.h>
using namespace HERE_PLUGIN_NAMESPACE_PREFIX;
-int HerePluginInit(maps_plugin_h *hPlugin)
+int HerePluginInit(maps_plugin_h *hPlugin, const char *module)
{
if (!hPlugin)
return HERE_ERROR_INVALID_PARAMETER;
return (HereManager::GetHandler()->CancelInstance(nReqId));
}
+
+int HerePluginSetMapView(const maps_view_h hView, maps_plugin_map_view_ready_cb pCbFunc)
+{
+ if (!HereManager::GetHandler())
+ return HERE_ERROR_INVALID_OPERATION;
+
+ /* creating instance */
+ HereView *pView =
+ (HereView*)(HereManager::GetHandler()->CreateInstance(HereManager::HERE_SVC_VIEW));
+
+ if(!pView)
+ return HERE_ERROR_SERVICE_NOT_AVAILABLE;
+
+ /* sending request */
+ here_error_e error = HERE_ERROR_NONE;
+
+ if (hView)
+ error = pView->Init(hView, pCbFunc);
+ else
+ error = pView->Close();
+
+ delete pView;
+
+ return error;
+}
+
+int HerePluginRenderMap(const maps_coordinates_h mapsCoord, const double dZoom, const double dAngle,
+ maps_plugin_render_map_cb pCbFunc, void* pUserData, int* nReqId)
+{
+ if (!mapsCoord || !pCbFunc || !nReqId)
+ return HERE_ERROR_INVALID_PARAMETER;
+
+ if (!HereManager::GetHandler())
+ return HERE_ERROR_INVALID_OPERATION;
+
+ HereView *pView =
+ (HereView*)(HereManager::GetHandler()->CreateInstance(HereManager::HERE_SVC_VIEW,
+ (void*)pCbFunc, pUserData, nReqId));
+
+ if(!pView)
+ return HERE_ERROR_SERVICE_NOT_AVAILABLE;
+
+ /* sending request */
+ here_error_e error = pView->RenderMap(mapsCoord, dZoom, dAngle);
+ delete pView;
+
+ return error;
+}
+
+int HerePluginRenderMapArea(const maps_area_h hArea, const double dZoom, const double dAngle,
+ maps_plugin_render_map_cb pCbFunc, void* pUserData, int* nReqId)
+{
+ if (!hArea || !pCbFunc || !nReqId)
+ return HERE_ERROR_INVALID_PARAMETER;
+
+ if (!HereManager::GetHandler())
+ return HERE_ERROR_INVALID_OPERATION;
+
+ HereView *pView =
+ (HereView*)(HereManager::GetHandler()->CreateInstance(HereManager::HERE_SVC_VIEW,
+ (void*)pCbFunc, pUserData, nReqId));
+
+ if(!pView)
+ return HERE_ERROR_SERVICE_NOT_AVAILABLE;
+
+ /* sending request */
+ here_error_e error = pView->RenderMapByArea(hArea, dZoom, dAngle);
+ delete pView;
+
+ return error;
+}
+
+int HerePluginMoveCenter(const int delta_x, const int delta_y,
+ maps_plugin_render_map_cb pCbFunc, void* pUserData, int* nReqId)
+{
+ if (!pCbFunc || !nReqId)
+ return HERE_ERROR_INVALID_PARAMETER;
+
+ if (!HereManager::GetHandler())
+ return HERE_ERROR_INVALID_OPERATION;
+
+ HereView *pView =
+ (HereView*)(HereManager::GetHandler()->CreateInstance(HereManager::HERE_SVC_VIEW,
+ (void*)pCbFunc, pUserData, nReqId));
+
+ if(!pView)
+ return HERE_ERROR_SERVICE_NOT_AVAILABLE;
+
+ /* sending request */
+ here_error_e error = pView->MoveCenter(delta_x, delta_y);
+ delete pView;
+
+ return error;
+}
+
+int HerePluginSetScalebar(bool enable)
+{
+ if (!HereManager::GetHandler())
+ return HERE_ERROR_INVALID_OPERATION;
+
+ HereView *pView =
+ (HereView*)(HereManager::GetHandler()->CreateInstance(HereManager::HERE_SVC_VIEW));
+
+ if(!pView)
+ return HERE_ERROR_SERVICE_NOT_AVAILABLE;
+
+ /* sending request */
+ here_error_e error = pView->SetScalebar(enable);
+ delete pView;
+
+ return error;
+}
+
+int HerePluginGetScalebar(bool *enabled)
+{
+ if (!enabled)
+ return HERE_ERROR_INVALID_PARAMETER;
+
+ if (!HereManager::GetHandler())
+ return HERE_ERROR_INVALID_OPERATION;
+
+ HereView *pView =
+ (HereView*)(HereManager::GetHandler()->CreateInstance(HereManager::HERE_SVC_VIEW));
+
+ if(!pView)
+ return HERE_ERROR_SERVICE_NOT_AVAILABLE;
+
+ here_error_e error = pView->GetScalebar(enabled);
+ delete pView;
+
+ return error;
+}
+
+int HerePluginDrawMap(Evas* pCanvas, const int x, const int y,
+ const int nWidth, const int nHeight)
+{
+ return HERE_ERROR_NONE;
+}
+
+int HerePluginGetCenter(maps_coordinates_h *center)
+{
+ if (!center)
+ return HERE_ERROR_INVALID_PARAMETER;
+
+ if (!HereManager::GetHandler())
+ return HERE_ERROR_INVALID_OPERATION;
+
+ /* creating instance */
+ HereView *pView =
+ (HereView*)(HereManager::GetHandler()->CreateInstance(HereManager::HERE_SVC_VIEW));
+
+ if(!pView)
+ return HERE_ERROR_SERVICE_NOT_AVAILABLE;
+
+ /* sending request */
+ here_error_e error = pView->GetCenter(center);
+ delete pView;
+
+ return error;
+}
+
+int HerePluginScreenToGeography(const int x, const int y, maps_coordinates_h *mapsCoord)
+{
+ if (!mapsCoord)
+ return HERE_ERROR_INVALID_PARAMETER;
+
+ if (!HereManager::GetHandler())
+ return HERE_ERROR_INVALID_OPERATION;
+
+ /* creating instance */
+ HereView *pView =
+ (HereView*)(HereManager::GetHandler()->CreateInstance(HereManager::HERE_SVC_VIEW));
+
+ if(!pView)
+ return HERE_ERROR_SERVICE_NOT_AVAILABLE;
+
+ /* sending request */
+ here_error_e error = pView->ScreenToGeolocation(x, y, mapsCoord);
+ delete pView;
+
+ return error;
+}
+
+int HerePluginGeographyToScreen(const maps_coordinates_h mapsCoord, int *x, int *y)
+{
+ if (!mapsCoord || !x || !y)
+ return HERE_ERROR_INVALID_PARAMETER;
+
+ if (!HereManager::GetHandler())
+ return HERE_ERROR_INVALID_OPERATION;
+
+ /* creating instance */
+ HereView *pView =
+ (HereView*)(HereManager::GetHandler()->CreateInstance(HereManager::HERE_SVC_VIEW));
+
+ if(!pView)
+ return HERE_ERROR_SERVICE_NOT_AVAILABLE;
+
+ /* sending request */
+ here_error_e error = pView->GeolocationToScreen(mapsCoord, x, y);
+ delete pView;
+
+ return error;
+}
+
+int HerePluginGetMinZoomLevel(int *nMinZoomLevel)
+{
+ return HereView::GetMinZoomLevel(nMinZoomLevel);
+}
+
+int HerePluginGetMaxZoomLevel(int *nMaxZoomLevel)
+{
+ return HereView::GetMaxZoomLevel(nMaxZoomLevel);
+}
+
+int HerePluginOnViewObject(const maps_view_object_h object,
+ const maps_view_object_operation_e operation)
+{
+ return HereView::OnViewObject(object, operation);
+}
#include "here_place.h"
#include "here_route.h"
#include "here_utils.h"
+#include "here_view.h"
#include "heremaps-uc-dbus.h"
+
#include <common/HereConfig.h>
#include <app.h>
#include <iostream>
pHere = (HereBase*)new (std::nothrow) HereMultiRevGeocode(pCbFunc, pUserData, reqId);
break;
+ case HERE_SVC_VIEW:
+ pHere = (HereBase*)new (std::nothrow) HereView(pCbFunc, pUserData, reqId);
+ break;
+
default:
return NULL;
}
}
}
}
+ m_bReplyFlushed = true;
}
bool HerePlace::__compareWithTitle(const maps_place_h &item1, const maps_place_h &item2)
return ConvertToMapsError(ret);
}
+EXPORT_API int maps_plugin_init_module(maps_plugin_h *plugin, const char *module)
+{
+ int ret = HerePluginInit(plugin, module);
+
+ MAPS_LOGD("here_error_e = %d", ret);
+
+ return ConvertToMapsError(ret);
+}
+
EXPORT_API int maps_plugin_shutdown(maps_plugin_h plugin)
{
int ret = HerePluginShutdown(plugin);
return ConvertToMapsError(ret);
}
+/* Mapping */
+EXPORT_API int maps_plugin_set_map_view(const maps_view_h view, maps_plugin_map_view_ready_cb pCbFunc)
+{
+ int ret = HerePluginSetMapView(view, pCbFunc);
+
+ MAPS_LOGD("here_error_e = %d", ret);
+
+ return ConvertToMapsError(ret);
+}
+
+EXPORT_API int maps_plugin_render_map(const maps_coordinates_h coordinates,
+ const double zoom_factor,
+ const double rotation_angle,
+ maps_plugin_render_map_cb callback,
+ void* user_data,
+ int* request_id)
+
+{
+ int ret = HerePluginRenderMap(coordinates, zoom_factor, rotation_angle,
+ callback, user_data, request_id);
+
+ if (ret != HERE_ERROR_NONE)
+ MAPS_LOGD("here_error_e = %d", ret);
+
+ return ConvertToMapsError(ret);
+}
+
+EXPORT_API int maps_plugin_render_map_area(const maps_area_h area,
+ const double zoom_factor,
+ const double rotation_angle,
+ maps_plugin_render_map_cb callback,
+ void* user_data,
+ int* request_id)
+{
+ int ret = HerePluginRenderMapArea(area, zoom_factor, rotation_angle,
+ callback, user_data, request_id);
+
+ if (ret != HERE_ERROR_NONE)
+ MAPS_LOGD("here_error_e = %d", ret);
+
+ return ConvertToMapsError(ret);
+}
+
+EXPORT_API int maps_plugin_move_center(const int delta_x, const int delta_y,
+ maps_plugin_render_map_cb callback,
+ void* user_data,
+ int* request_id)
+{
+ int ret = HerePluginMoveCenter(delta_x, delta_y,
+ callback, user_data, request_id);
+
+ if (ret != HERE_ERROR_NONE)
+ MAPS_LOGD("here_error_e = %d", ret);
+
+ return ConvertToMapsError(ret);
+}
+
+EXPORT_API int maps_plugin_set_scalebar(bool enable)
+{
+ int ret = HerePluginSetScalebar(enable);
+
+ if (ret != HERE_ERROR_NONE)
+ MAPS_LOGD("here_error_e = %d", ret);
+
+ return ConvertToMapsError(ret);
+}
+
+EXPORT_API int maps_plugin_get_scalebar(bool *enabled)
+{
+ int ret = HerePluginGetScalebar(enabled);
+ return ConvertToMapsError(ret);
+}
+
+EXPORT_API int maps_plugin_draw_map(Evas* canvas, const int x, const int y,
+ const int width, const int height)
+{
+ int ret = HerePluginDrawMap(canvas, x, y, width, height);
+
+ if (ret != HERE_ERROR_NONE)
+ MAPS_LOGD("here_error_e = %d", ret);
+
+ return ConvertToMapsError(ret);
+}
+
+EXPORT_API int maps_plugin_get_center(maps_coordinates_h *center)
+{
+ int ret = HerePluginGetCenter(center);
+ return ConvertToMapsError(ret);
+}
+
+EXPORT_API int maps_plugin_screen_to_geography(const int x, const int y,
+ maps_coordinates_h *mapsCoord)
+{
+ int ret = HerePluginScreenToGeography(x, y, mapsCoord);
+ return ConvertToMapsError(ret);
+}
+
+EXPORT_API int maps_plugin_geography_to_screen(const maps_coordinates_h mapsCoord,
+ int* x, int* y)
+{
+ int ret = HerePluginGeographyToScreen(mapsCoord, x, y);
+ return ConvertToMapsError(ret);
+}
+
+EXPORT_API int maps_plugin_get_min_zoom_level(int *min_zoom_level)
+{
+ int ret = HerePluginGetMinZoomLevel(min_zoom_level);
+ return ConvertToMapsError(ret);
+}
+
+EXPORT_API int maps_plugin_get_max_zoom_level(int *max_zoom_level)
+{
+ int ret = HerePluginGetMaxZoomLevel(max_zoom_level);
+ return ConvertToMapsError(ret);
+}
+
+EXPORT_API int maps_plugin_on_object(const maps_view_object_h object,
+ const maps_view_object_operation_e operation)
+{
+ int ret = HerePluginOnViewObject(object, operation);
+
+ if (ret != HERE_ERROR_NONE)
+ MAPS_LOGD("here_error_e = %d", ret);
+
+ return ConvertToMapsError(ret);
+}
+
+
} // end of extern "C"
return Maneuver::ID_NoDirection;
}
+GeoTiledMap::MapType HereUtils::Convert(maps_view_type_e nMapType, bool bBuildings, bool bTraffic, bool bPublicTransit)
+{
+ switch (nMapType)
+ {
+ case MAPS_VIEW_TYPE_NORMAL:
+ if (bPublicTransit) return GeoTiledMap::MT_Normal_Day_Transit;
+ if (bTraffic) return GeoTiledMap::MT_Normal_Traffic_Day;
+ return GeoTiledMap::MT_Normal_Day;
+ case MAPS_VIEW_TYPE_SATELLITE:
+ return GeoTiledMap::MT_Satellite_Day;
+ case MAPS_VIEW_TYPE_TERRAIN:
+ return GeoTiledMap::MT_Terrain_Day;
+ case MAPS_VIEW_TYPE_HYBRID:
+ if (bPublicTransit) return GeoTiledMap::MT_Hybrid_Day_Transit;
+ if (bTraffic) return GeoTiledMap::MT_Hybrid_Traffic_Day;
+ return GeoTiledMap::MT_Hybrid_Day;
+ default: break;
+ }
+ return GeoTiledMap::MT_Normal_Day;
+}
+
maps_error_e HereUtils::ConvertHttpCodeToMapsError(int nVal)
{
switch (nVal)
--- /dev/null
+/*
+ * 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 "here_view.h"
+#include <Elementary.h>
+
+using namespace HERE_PLUGIN_NAMESPACE_PREFIX;
+
+static const char SIG_LOADED[] = "loaded";
+
+
+HERE_PLUGIN_BEGIN_NAMESPACE
+
+GLData *HereView::m_pImpl = NULL;
+
+HereView::HereView(void *pCbFunc, void *pUserData, int nReqId)
+{
+ m_pCbFunc = pCbFunc;
+ m_pUserData = pUserData;
+ m_nReqId = nReqId;
+}
+
+HereView::~HereView()
+{
+}
+
+GLData* HereView::GetImplHandler()
+{
+ return m_pImpl;
+}
+
+here_error_e HereView::Init(maps_view_h hView, maps_plugin_map_view_ready_cb pCbFunc)
+{
+ if (!hView)
+ return HERE_ERROR_INVALID_PARAMETER;
+
+ if (m_pImpl)
+ return HERE_ERROR_INVALID_OPERATION;
+
+ if (!m_pImpl)
+ {
+ m_pImpl = new (std::nothrow) GLData();
+
+ if (!m_pImpl)
+ return HERE_ERROR_INVALID_PARAMETER;
+
+ m_pImpl->idler = ecore_idler_add(__idlerCb, (void*)m_pImpl);
+ m_pImpl->readyCb = NULL;
+ }
+
+ here_error_e error = HERE_ERROR_NONE;
+ int error2 = MAPS_ERROR_NONE;
+
+ do {
+ error2 = maps_view_get_viewport(hView, &m_pImpl->img);
+ if (error2 != MAPS_ERROR_NONE) break;
+
+ error2 = maps_view_get_screen_location(hView, &m_pImpl->x, &m_pImpl->y, &m_pImpl->w, &m_pImpl->h);
+ if (error2 != MAPS_ERROR_NONE) break;
+
+ m_pImpl->hView = hView;
+
+ error = InitOpenGL(m_pImpl);
+ if (error != HERE_ERROR_NONE) break;
+
+ error = InitOpenGLSurface(m_pImpl);
+ if (error != HERE_ERROR_NONE) break;
+
+ error = InitMap(m_pImpl, pCbFunc);
+ } while(0);
+
+ if (error == HERE_ERROR_NONE && error2 != MAPS_ERROR_NONE)
+ error = (here_error_e)ConvertToHereError(error2);
+
+ return error;
+}
+
+here_error_e HereView::InitOpenGL(GLData *gld)
+{
+ if (!gld)
+ return HERE_ERROR_INVALID_PARAMETER;
+
+
+ gld->cfg = evas_gl_config_new();
+ if (!gld->cfg)
+ {
+ MAPS_LOGE("evas_gl_config_new() failed");
+ return HERE_ERROR_SERVICE_NOT_AVAILABLE;
+ }
+
+ gld->cfg->color_format = EVAS_GL_RGBA_8888; // Surface Color Format
+ gld->cfg->depth_bits = EVAS_GL_DEPTH_NONE; // Surface Depth Format
+ gld->cfg->stencil_bits = EVAS_GL_STENCIL_NONE; // Surface Stencil Format
+ gld->cfg->options_bits = EVAS_GL_OPTIONS_DIRECT; // Configuration options (here, no extra options)
+
+ gld->gl = evas_gl_new(evas_object_evas_get(gld->img));
+ if (!gld->gl)
+ {
+ MAPS_LOGE("evas_gl_new() failed");
+ return HERE_ERROR_SERVICE_NOT_AVAILABLE;
+ }
+
+ gld->api = evas_gl_api_get(gld->gl);
+ if (!gld->api)
+ {
+ MAPS_LOGE("evas_gl_api_get() failed");
+ return HERE_ERROR_SERVICE_NOT_AVAILABLE;
+ }
+
+ gld->ctx = evas_gl_context_create(gld->gl, NULL);
+ if (!gld->ctx)
+ {
+ MAPS_LOGE("evas_gl_context_create() failed");
+ return HERE_ERROR_SERVICE_NOT_AVAILABLE;
+ }
+
+ return HERE_ERROR_NONE;
+}
+
+here_error_e HereView::InitOpenGLSurface(GLData *gld)
+{
+ if (!gld || !gld->gl || !gld->cfg || !gld->img || !gld->ctx)
+ return HERE_ERROR_INVALID_PARAMETER;
+
+
+ evas_object_image_pixels_get_callback_set(gld->img, NULL, NULL);
+
+ if (gld->sfc)
+ {
+ evas_object_image_native_surface_set(gld->img, NULL);
+ evas_gl_surface_destroy(gld->gl, gld->sfc);
+ }
+
+ m_pImpl->w = MAX(m_pImpl->w, 1);
+ m_pImpl->h = MAX(m_pImpl->h, 1);
+
+ evas_object_image_size_set(gld->img, gld->w, gld->h);
+
+ Evas_Native_Surface ns;
+ gld->sfc = evas_gl_surface_create(gld->gl, gld->cfg, gld->w, gld->h);
+ if (!gld->sfc)
+ {
+ MAPS_LOGE("evas_gl_surface_create() failed");
+ return HERE_ERROR_SERVICE_NOT_AVAILABLE;
+ }
+
+ if (!evas_gl_native_surface_get(gld->gl, gld->sfc, &ns))
+ {
+ evas_gl_make_current(gld->gl, NULL, NULL);
+ evas_gl_surface_destroy(gld->gl, gld->sfc);
+ gld->sfc = NULL;
+ MAPS_LOGE("evas_gl_native_surface_get() faile");
+ return HERE_ERROR_SERVICE_NOT_AVAILABLE;
+ }
+
+ evas_object_image_native_surface_set(gld->img, &ns);
+
+ evas_object_image_pixels_get_callback_set(gld->img, __pixelGetCb, this);
+
+ gld->isInitialized = true;
+ //MAPS_LOGD("initializing is Done!!!");
+
+ return HERE_ERROR_NONE;
+}
+
+here_error_e HereView::InitMap(GLData *gld, maps_plugin_map_view_ready_cb pCbFunc)
+{
+ if (!gld)
+ return HERE_ERROR_INVALID_PARAMETER;
+
+ gld->map = new (std::nothrow) GeoTiledMap();
+
+ if (!gld->map)
+ return HERE_ERROR_OUT_OF_MEMORY;
+
+ gld->readyCb = pCbFunc;
+
+ gld->map->SetReadyMapSignal((GeoTiledMap::ReadyMapSignalFunctor)__readyCb);
+
+ gld->map->SetEvasGlApi(gld->api);
+
+ MAPS_LOGD("gld->api=%p, m_pImpl->api=%p", gld->api, m_pImpl->api);
+
+ gld->map->SetMapSize(Dimension(gld->w,gld->h));
+
+ //gld->map->SetUpdateMapSignal(RenderingCb, this);
+
+ m_pImpl->visualObjects.set(gld->map, evas_object_evas_get(gld->img));
+
+ return HERE_ERROR_NONE;
+}
+
+here_error_e HereView::Close()
+{
+ if (m_pImpl)
+ {
+ m_pImpl->isInitialized = false;
+
+ if (m_pImpl->map)
+ {
+ m_pImpl->map->SetUpdateMapSignal(NULL);
+ }
+
+ m_pImpl->visualObjects.set(NULL, NULL);
+
+ if (m_pImpl->img)
+ {
+ evas_object_image_pixels_get_callback_set(m_pImpl->img, NULL, NULL);
+ }
+
+ if (m_pImpl->idler)
+ {
+ ecore_idler_del(m_pImpl->idler);
+ m_pImpl->idler = NULL;
+ }
+
+ if (m_pImpl->map)
+ {
+ m_pImpl->map->SetUpdateMapSignal(NULL);
+ delete m_pImpl->map;
+ m_pImpl->map = NULL;
+ }
+
+ if (m_pImpl->gl)
+ {
+ evas_gl_make_current(m_pImpl->gl, m_pImpl->sfc, m_pImpl->ctx);
+
+ if (m_pImpl->sfc)
+ {
+ evas_object_image_native_surface_set(m_pImpl->img, NULL);
+ evas_gl_surface_destroy(m_pImpl->gl, m_pImpl->sfc);
+ m_pImpl->sfc = NULL;
+ }
+
+ if (m_pImpl->ctx)
+ {
+ evas_gl_context_destroy(m_pImpl->gl, m_pImpl->ctx);
+ m_pImpl->ctx = NULL;
+ }
+
+ evas_gl_free(m_pImpl->gl);
+ m_pImpl->gl = NULL;
+ }
+
+ if (m_pImpl->cfg)
+ {
+ evas_gl_config_free(m_pImpl->cfg);
+ m_pImpl->cfg = NULL;
+ }
+
+ delete m_pImpl;
+ m_pImpl = NULL;
+ }
+
+ return HERE_ERROR_NONE;
+}
+
+void HereView::__readyCb()
+{
+ if (m_pImpl->readyCb)
+ m_pImpl->readyCb(m_pImpl->hView);
+}
+
+void HereView::__pixelGetCb(void *data, Evas_Object *obj)
+{
+ if (!m_pImpl || !m_pImpl->map) return;
+ if (!m_pImpl->gl || !m_pImpl->sfc || !m_pImpl->ctx) return;
+
+ evas_gl_make_current(m_pImpl->gl, m_pImpl->sfc, m_pImpl->ctx);
+ m_pImpl->map->PaintMap(m_pImpl->w, m_pImpl->h);
+}
+
+void HereView::__renderingCb(void *data)
+{
+ if (!data) return;
+ evas_object_image_pixels_dirty_set((Evas_Object*)data, EINA_TRUE);
+}
+
+void HereView::__setMapType()
+{
+ /* When the theme is changed, clear cache */
+ maps_view_type_e map_type;
+ maps_view_get_type(m_pImpl->hView, &map_type);
+
+ bool buildings_enabled = false;
+ maps_view_get_buildings_enabled(m_pImpl->hView, &buildings_enabled);
+
+ bool traffic_enabled = false;
+ maps_view_get_traffic_enabled(m_pImpl->hView, &traffic_enabled);
+
+ bool public_transit_enabled = false;
+
+ GeoTiledMap::MapType hereMapType = HereUtils::Convert(map_type, buildings_enabled,
+ traffic_enabled, public_transit_enabled);
+
+ if (hereMapType != m_pImpl->map->GetMapType())
+ {
+ MAPS_LOGD("Clear cache, because map type is changed.");
+ m_pImpl->map->ClearCache();
+#ifdef TIZEN_SUPPORT_TILE_FILE_CACHE
+ m_pImpl->map->ClearTileFileCache();
+#endif
+ m_pImpl->map->SetMapType(hereMapType);
+ }
+}
+
+here_error_e HereView::RenderMap(const maps_coordinates_h mapsCoord, double dZoom, double dAngle)
+{
+
+ if (!m_pImpl || !m_pImpl->isInitialized || !m_pImpl->map || !m_pImpl->api)
+ return HERE_ERROR_SERVICE_NOT_AVAILABLE;
+
+ if (!mapsCoord)
+ return HERE_ERROR_INVALID_PARAMETER;
+
+ /* set map type */
+ __setMapType();
+
+ /* resize window */
+ int x, y, w, h;
+ maps_view_get_screen_location(m_pImpl->hView, &x, &y, &w, &h);
+ m_pImpl->w = MAX(m_pImpl->w, 1);
+ m_pImpl->h = MAX(m_pImpl->h, 1);
+
+ if (x != m_pImpl->x || y != m_pImpl->y || w != m_pImpl->w || h != m_pImpl->h)
+ {
+ m_pImpl->x = x;
+ m_pImpl->y = y;
+ m_pImpl->w = w;
+ m_pImpl->h = h;
+
+ m_pImpl->api->glViewport(0, 0, m_pImpl->w, m_pImpl->h);
+ m_pImpl->map->SetMapSize(Dimension(m_pImpl->w,m_pImpl->h));
+ InitOpenGLSurface(m_pImpl);
+ }
+
+ /* callback */
+ GeoTiledMap::UpdateMapSignalFunctor callback = std::tr1::bind(&__renderingCb, m_pImpl->img);
+ m_pImpl->map->SetUpdateMapSignal(callback);
+
+ /* zoom level */
+ if (m_pImpl->map->GetZoomLevel() != dZoom)
+ {
+ m_pImpl->zoom = dZoom;
+ m_pImpl->map->SetZoomLevel(dZoom, false);
+ }
+
+ /* angle */
+ if (m_pImpl->angle != dAngle) {
+ m_pImpl->angle = dAngle;
+ m_pImpl->map->SetAngle(dAngle);
+ }
+
+ /* center */
+ double lat, lng;
+ maps_coordinates_get_latitude(mapsCoord, &lat);
+ maps_coordinates_get_longitude(mapsCoord, &lng);
+
+ GeoCoordinates geoCoord(lat, lng);
+ m_pImpl->lat = lat;
+ m_pImpl->lng = lng;
+ m_pImpl->map->SetCenter(geoCoord);
+
+ return HERE_ERROR_NONE;
+}
+
+here_error_e HereView::RenderMapByArea(const maps_area_h hArea, double dZoom, double dAngle)
+{
+ if (!m_pImpl || !m_pImpl->isInitialized || !m_pImpl->map || !m_pImpl->map->GetRootPixmap() || !m_pImpl->api)
+ return HERE_ERROR_SERVICE_NOT_AVAILABLE;
+
+ if (!hArea)
+ return HERE_ERROR_INVALID_PARAMETER;
+
+ return HERE_ERROR_NONE;
+}
+
+here_error_e HereView::MoveCenter(int delta_x, int delta_y)
+{
+ if (!m_pImpl || !m_pImpl->isInitialized || !m_pImpl->map || !m_pImpl->map->GetRootPixmap() || !m_pImpl->api)
+ return HERE_ERROR_SERVICE_NOT_AVAILABLE;
+
+ if (delta_x == 0 && delta_y == 0)
+ return HERE_ERROR_NONE;
+
+ m_pImpl->map->Pan(delta_x, delta_y);
+
+ return HERE_ERROR_NONE;
+}
+
+here_error_e HereView::SetScalebar(bool enable)
+{
+ if (!m_pImpl || !m_pImpl->isInitialized || !m_pImpl->map)
+ return HERE_ERROR_SERVICE_NOT_AVAILABLE;
+
+ m_pImpl->map->SetScalebar(enable);
+
+ return HERE_ERROR_NONE;
+}
+
+here_error_e HereView::GetScalebar(bool *enabled)
+{
+ if (!m_pImpl || !m_pImpl->isInitialized || !m_pImpl->map || !enabled)
+ return HERE_ERROR_SERVICE_NOT_AVAILABLE;
+
+ *enabled = m_pImpl->map->GetScalebar();
+ return HERE_ERROR_NONE;
+}
+
+here_error_e HereView::DrawMap(Evas* pCanvas, int x, int y, int nWidth, int nHeight)
+{
+ if (!m_pImpl || !m_pImpl->isInitialized || !m_pImpl->map || !m_pImpl->map->GetRootPixmap() || !m_pImpl->api)
+ return HERE_ERROR_SERVICE_NOT_AVAILABLE;
+
+ if (!pCanvas || nWidth <= 0 || nHeight <= 0)
+ return HERE_ERROR_INVALID_PARAMETER;
+
+ if (m_pImpl->w <= 0 || m_pImpl->h <= 0)
+ return HERE_ERROR_INVALID_PARAMETER;
+
+ unsigned char* srcimg_data = (unsigned char*)malloc(m_pImpl->w*m_pImpl->h*4);
+ if (!srcimg_data)
+ return HERE_ERROR_OUT_OF_MEMORY;
+
+ Evas_Object *dstimg = evas_object_image_filled_add(pCanvas);
+ if (!dstimg)
+ {
+ g_free(srcimg_data);
+ return HERE_ERROR_INVALID_OPERATION;
+ }
+
+ unsigned char *dstimg_data = (unsigned char *)evas_object_image_data_get(dstimg, EINA_TRUE);
+ if (!dstimg_data)
+ {
+ g_free(srcimg_data);
+ return HERE_ERROR_INVALID_OPERATION;
+ }
+
+ int w = nWidth;
+ int h = nHeight;
+
+ if (m_pImpl->w < w) w = m_pImpl->w;
+ if (m_pImpl->h < h) h = m_pImpl->h;
+
+ m_pImpl->api->glReadPixels(x, y, w, h, GL_RGBA, GL_UNSIGNED_BYTE, srcimg_data);
+
+ try {
+ for (int i = 0; i < h; i++)
+ {
+ memcpy(dstimg_data+(i*w), srcimg_data+(i*m_pImpl->w+x), w*4);
+ }
+ free(srcimg_data);
+ }
+ catch (std::exception &e)
+ {
+ MAPS_LOGD("Exception caught: %s", e.what());
+ }
+
+ g_free(srcimg_data);
+
+ return HERE_ERROR_NONE;
+}
+
+here_error_e HereView::GetCenter(maps_coordinates_h *center)
+{
+ if (!center)
+ return HERE_ERROR_INVALID_PARAMETER;
+
+ GeoCoordinates geoCoord = m_pImpl->map->GetCenter();
+
+ if (*center == NULL)
+ {
+ maps_coordinates_create(geoCoord.GetLatitude(), geoCoord.GetLongitude(), center);
+ }
+ else
+ {
+ maps_coordinates_set_latitude(*center, geoCoord.GetLatitude());
+ maps_coordinates_set_longitude(*center, geoCoord.GetLongitude());
+ }
+
+ return HERE_ERROR_NONE;
+}
+
+here_error_e HereView::ScreenToGeolocation(int x, int y, maps_coordinates_h *mapsCoord)
+{
+ if (!m_pImpl || !m_pImpl->isInitialized || !m_pImpl->map)
+ return HERE_ERROR_SERVICE_NOT_AVAILABLE;
+
+ if (!mapsCoord)
+ return HERE_ERROR_INVALID_PARAMETER;
+
+ Tizen::Maps::Point mapsPoint(x, y);
+ GeoCoordinates hereCoord = m_pImpl->map->ScreenPositionToCoordinate(mapsPoint);
+ double lat = hereCoord.GetLatitude();
+ double lng = hereCoord.GetLongitude();
+
+ maps_coordinates_h __mapsCoord;
+ int error = maps_coordinates_create(lat, lng, &__mapsCoord);
+ if (error != MAPS_ERROR_NONE)
+ return (here_error_e)ConvertToHereError(error);
+
+ if (*mapsCoord) {
+ /* maps_coord is already allocated in heap memory */
+ maps_coordinates_get_latitude(__mapsCoord, &lat);
+ maps_coordinates_get_longitude(__mapsCoord, &lng);
+ maps_coordinates_set_latitude(*mapsCoord, lat);
+ maps_coordinates_set_longitude(*mapsCoord, lng);
+ } else {
+ /* maps_coord is not allocated yet */
+ maps_coordinates_clone(__mapsCoord, mapsCoord);
+ }
+ maps_coordinates_destroy(__mapsCoord);
+
+ return HERE_ERROR_NONE;
+}
+
+here_error_e HereView::GeolocationToScreen(const maps_coordinates_h mapsCoord, int *x, int *y)
+{
+ if (!m_pImpl || !m_pImpl->isInitialized || !m_pImpl->map)
+ return HERE_ERROR_SERVICE_NOT_AVAILABLE;
+
+ if (!x || !y)
+ return HERE_ERROR_INVALID_PARAMETER;
+
+ double lat, lng;
+ maps_coordinates_get_latitude(mapsCoord, &lat);
+ maps_coordinates_get_longitude(mapsCoord, &lng);
+ GeoCoordinates hereCoord(lat, lng);
+ Tizen::Maps::Point mapsPoint = m_pImpl->map->CoordinateToScreenPosition(hereCoord);
+
+ *x = mapsPoint.x;
+ *y = mapsPoint.y;
+
+ return HERE_ERROR_NONE;
+}
+
+here_error_e HereView::GetMinZoomLevel(int *nMinZoomLevel)
+{
+ if (!m_pImpl || !m_pImpl->isInitialized || !m_pImpl->map)
+ return HERE_ERROR_SERVICE_NOT_AVAILABLE;
+
+ if (!nMinZoomLevel)
+ return HERE_ERROR_INVALID_PARAMETER;
+
+ *nMinZoomLevel = (int)m_pImpl->map->GetMinimumZoomLevel();
+
+ return HERE_ERROR_NONE;
+}
+
+here_error_e HereView::GetMaxZoomLevel(int *nMaxZoomLevel)
+{
+ if (!m_pImpl || !m_pImpl->isInitialized || !m_pImpl->map)
+ return HERE_ERROR_SERVICE_NOT_AVAILABLE;
+
+ if (!nMaxZoomLevel)
+ return HERE_ERROR_INVALID_PARAMETER;
+
+ *nMaxZoomLevel = (int)m_pImpl->map->GetMaximumZoomLevel();
+
+ return HERE_ERROR_NONE;
+}
+
+here_error_e HereView::OnViewObject(const maps_view_object_h object, maps_view_object_operation_e operation)
+{
+ if (!m_pImpl || !m_pImpl->isInitialized || !m_pImpl->map)
+ return HERE_ERROR_SERVICE_NOT_AVAILABLE;
+
+ if (!object || operation < MAPS_VIEW_OBJECT_ADD || operation > MAPS_VIEW_OBJECT_REMOVE)
+ return HERE_ERROR_INVALID_PARAMETER;
+
+ if (m_pImpl->map->GetRootPixmap())
+ __processViewObject(object, operation);
+ else
+ m_pImpl->pendingObjects.push_back(std::make_pair(object, operation));
+
+ return HERE_ERROR_NONE;
+}
+
+Eina_Bool HereView::__idlerCb(void *data)
+{
+ GLData *pImpl = (GLData*)data;
+
+ if (!pImpl || !pImpl->map || !pImpl->map->GetRootPixmap()) return true;
+
+ while (pImpl->pendingObjects.size())
+ {
+ PendingObject pending = pImpl->pendingObjects.front();
+ pImpl->pendingObjects.pop_front();
+ maps_view_object_h object = pending.first;
+ maps_view_object_operation_e operation = pending.second;
+
+ __processViewObject(object, operation);
+ }
+
+ return true;
+}
+
+void HereView::__processViewObject(const maps_view_object_h object, maps_view_object_operation_e operation)
+{
+ maps_view_object_type_e type;
+ maps_view_object_get_type(object, &type);
+
+ if (type < MAPS_VIEW_OBJECT_POLYLINE || type > MAPS_VIEW_OBJECT_MARKER) return;
+ if (operation < MAPS_VIEW_OBJECT_ADD || operation > MAPS_VIEW_OBJECT_REMOVE) return;
+
+ const char *oper_str[20] = { "ADD", "SET_VISIBLE", "MOVE", "CHANGE", "REMOVE"};
+ const char *type_str[20] = { "POLYLINE", "POLYGON", "MARKER", "ROUTE", "UNKNOWN"};
+
+ MAPS_LOGD("type=%s, operation=%s, object=%p",
+ (type >= MAPS_VIEW_OBJECT_POLYLINE && type <= MAPS_VIEW_OBJECT_MARKER) ? type_str[type] : "?",
+ (operation >= MAPS_VIEW_OBJECT_ADD && operation <= MAPS_VIEW_OBJECT_REMOVE) ? oper_str[operation] : "?",
+ object);
+
+ switch(operation)
+ {
+ case MAPS_VIEW_OBJECT_ADD: m_pImpl->visualObjects.add(object); break;
+ case MAPS_VIEW_OBJECT_SET_VISIBLE: m_pImpl->visualObjects.setVisible(object); break;
+ case MAPS_VIEW_OBJECT_MOVE: m_pImpl->visualObjects.move(object); break;
+ case MAPS_VIEW_OBJECT_CHANGE: m_pImpl->visualObjects.update(object); break;
+ case MAPS_VIEW_OBJECT_REMOVE: m_pImpl->visualObjects.remove(object); break;
+ default: break;
+ }
+}
+
+HERE_PLUGIN_END_NAMESPACE
--- /dev/null
+/*
+ * 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 "here_view_objects.h"
+#include "here_utils.h"
+
+#include <graphic/Grp_Util.h>
+#include <maps/GeoMapObjectMarker.h>
+#include <maps/GeoMapObjectPolygon.h>
+#include <maps/GeoMapObjectPolyline.h>
+
+
+using namespace HERE_PLUGIN_NAMESPACE_PREFIX;
+
+HERE_PLUGIN_BEGIN_NAMESPACE
+
+HereViewObjects::HereViewObjects()
+{
+ pthread_mutex_init(&__mutex, NULL);
+}
+
+HereViewObjects::~HereViewObjects()
+{
+ pthread_mutex_destroy(&__mutex);
+}
+
+void HereViewObjects::set(GeoTiledMap *map, Evas *evas)
+{
+ if (!map && !evas) removeAll();
+ __map = map;
+ __evas = evas;
+}
+
+here_error_e HereViewObjects::add(maps_view_object_h hObj)
+{
+ if (!hObj) return HERE_ERROR_INVALID_PARAMETER;
+
+ here_error_e error = HERE_ERROR_INVALID_PARAMETER;
+ if (__currentObjects.find(hObj) == __currentObjects.end())
+ error = __add(hObj);
+
+ if (error == HERE_ERROR_NONE) __invalidate(hObj);
+ return error;
+}
+
+here_error_e HereViewObjects::__add(maps_view_object_h hObj)
+{
+ if (!hObj) return HERE_ERROR_INVALID_PARAMETER;
+ if (!__map) return HERE_ERROR_INVALID_OPERATION;
+
+ here_error_e error = HERE_ERROR_NONE;
+ GeoMapObject *hereObject = NULL;
+ maps_view_object_type_e type;
+ maps_view_object_get_type(hObj, &type);
+
+ switch(type)
+ {
+ case MAPS_VIEW_OBJECT_MARKER:
+ hereObject = new (std::nothrow) GeoMapObjectMarker;
+ error = __updateMarker(hObj, (GeoMapObjectMarker*)hereObject);
+ break;
+
+ case MAPS_VIEW_OBJECT_POLYGON:
+ hereObject = new (std::nothrow) GeoMapObjectPolygon;
+ error = __updatePolygon(hObj, (GeoMapObjectPolygon*)hereObject);
+ break;
+
+ case MAPS_VIEW_OBJECT_POLYLINE:
+ hereObject = new (std::nothrow) GeoMapObjectPolyline;
+ error = __updatePolyline(hObj, (GeoMapObjectPolyline*)hereObject);
+ break;
+#ifdef TIZEN_3_0_NEXT_MS
+ case MAPS_VIEW_OBJECT_ROUTE:
+ for (int i=0; i < 2; i++)
+ {
+ hereObject = new (std::nothrow) GeoMapObjectPolyline;
+ if (hereObject)
+ {
+ __map->AddObject(hereObject);
+ error = __updateRoute(hObj);
+ if (error != HERE_ERROR_NONE) break;
+ pthread_mutex_lock(&__mutex);
+ __currentObjects.insert(std::make_pair(hObj, (GeoMapObjectPolyline*)hereObject));
+ pthread_mutex_unlock(&__mutex);
+ }
+
+ hereObject = new (std::nothrow) GeoMapObjectMarker;
+ if (hereObject)
+ {
+ __map->AddObject(hereObject);
+ error = __updateRoute(hObj);
+ if (error != HERE_ERROR_NONE) break;
+ pthread_mutex_lock(&__mutex);
+ __currentObjects.insert(std::make_pair(hObj, (GeoMapObjectMarker*)hereObject));
+ pthread_mutex_unlock(&__mutex);
+ }
+ }
+ break;
+#endif /* TIZEN_3_0_NEXT_MS */
+ default:
+ error = HERE_ERROR_INVALID_PARAMETER;
+ break;
+ }
+
+ if (error != HERE_ERROR_NONE)
+ {
+ if (hereObject) delete hereObject;
+ hereObject = NULL;
+ }
+
+#ifdef TIZEN_3_0_NEXT_MS
+ if (hereObject && type != MAPS_VIEW_OBJECT_ROUTE)
+#else
+ if (hereObject)
+#endif /* TIZEN_3_0_NEXT_MS */
+ {
+ __map->AddObject(hereObject);
+ pthread_mutex_lock(&__mutex);
+ __currentObjects.insert(std::make_pair(hObj, hereObject));
+ pthread_mutex_unlock(&__mutex);
+ }
+
+ return error;
+}
+
+here_error_e HereViewObjects::remove(maps_view_object_h hObj)
+{
+ here_error_e error = __remove(hObj);
+ if (error == HERE_ERROR_NONE) __invalidate(hObj);
+ return error;
+}
+
+here_error_e HereViewObjects::__remove(maps_view_object_h hObj)
+{
+ if (!hObj) return HERE_ERROR_INVALID_PARAMETER;
+ if (!__map) return HERE_ERROR_INVALID_OPERATION;
+
+ here_error_e error = HERE_ERROR_NOT_FOUND;
+
+ VisualObjects::iterator it;
+ pthread_mutex_lock(&__mutex);
+ while ((it = __currentObjects.find(hObj)) != __currentObjects.end())
+ {
+ __map->RemoveObject((GeoMapObject*)it->second);
+ it = __currentObjects.erase(it);
+ error = HERE_ERROR_NONE;
+ }
+ pthread_mutex_unlock(&__mutex);
+
+ return error;
+}
+
+here_error_e HereViewObjects::removeAll()
+{
+ pthread_mutex_lock(&__mutex);
+ __currentObjects.clear();
+ __map->ClearMapObjects();
+ pthread_mutex_unlock(&__mutex);
+ __invalidate();
+
+ return HERE_ERROR_NONE;
+}
+
+here_error_e HereViewObjects::move(maps_view_object_h hObj)
+{
+ if (!hObj) return HERE_ERROR_INVALID_PARAMETER;
+
+ VisualObjects::iterator it;
+ while ((it = __currentObjects.find(hObj)) != __currentObjects.end())
+ {
+ MAPS_LOGD("TODO: implement moving");
+ }
+
+ return HERE_ERROR_NONE;
+}
+
+here_error_e HereViewObjects::update(maps_view_object_h hObj)
+{
+ if (!hObj) return HERE_ERROR_INVALID_PARAMETER;
+
+ here_error_e error = HERE_ERROR_NOT_FOUND;
+
+ VisualObjects::iterator it = __currentObjects.find(hObj);
+ if (it != __currentObjects.end())
+ error = __update(hObj, (GeoMapObject*)(it->second));
+
+ if (error == HERE_ERROR_NONE) __invalidate(hObj);
+ return error;
+}
+
+here_error_e HereViewObjects::__update(maps_view_object_h hObj, GeoMapObject *hereObject)
+{
+ if (!hObj) return HERE_ERROR_INVALID_PARAMETER;
+
+ here_error_e error = HERE_ERROR_UNKNOWN;
+
+ do {
+ maps_view_object_type_e type;
+ maps_view_object_get_type(hObj, &type);
+
+ switch(type)
+ {
+ case MAPS_VIEW_OBJECT_MARKER:
+ error = __updateMarker(hObj, (GeoMapObjectMarker*)hereObject);
+ break;
+
+ case MAPS_VIEW_OBJECT_POLYGON:
+ error = __updatePolygon(hObj, (GeoMapObjectPolygon*)hereObject);
+ break;
+
+ case MAPS_VIEW_OBJECT_POLYLINE:
+ error = __updatePolyline(hObj, (GeoMapObjectPolyline*)hereObject);
+ break;
+
+#ifdef TIZEN_3_0_NEXT_MS
+ case MAPS_VIEW_OBJECT_ROUTE:
+ error = __updateRoute(hObj);
+ break;
+#endif /* TIZEN_3_0_NEXT_MS */
+
+ default:
+ break;
+ }
+ } while(0);
+
+ return error;
+}
+
+here_error_e HereViewObjects::__updateMarker(maps_view_object_h hMarker, GeoMapObjectMarker *hereMarker)
+{
+ if (!hMarker || !hereMarker)
+ return HERE_ERROR_INVALID_PARAMETER;
+
+ if (!__evas || !__map)
+ return HERE_ERROR_INVALID_OPERATION;
+
+
+ int error = MAPS_ERROR_NONE;
+ maps_view_marker_type_e type;
+ int nSize = 0, w, h;
+ char *szPath = NULL;
+ double lat, lng;
+ maps_coordinates_h mapsCoord;
+ Evas_Object *img = NULL;
+
+
+ do {
+ /* image */
+ error = maps_view_object_marker_get_type(hMarker, &type);
+ if (error != MAPS_ERROR_NONE || type < MAPS_VIEW_MARKER_PIN || type > MAPS_VIEW_MARKER_STICKER) break;
+
+ error = maps_view_object_marker_get_image_file(hMarker, &szPath);
+ if (error != MAPS_ERROR_NONE || !szPath) break;
+
+ img = evas_object_image_add(__evas);
+ evas_object_image_file_set(img, szPath, NULL);
+ int err = evas_object_image_load_error_get(img);
+
+ if (err != EVAS_LOAD_ERROR_NONE)
+ {
+ MAPS_LOGE("Failed to load the image file for new marker. '%s'",
+ (szPath ? szPath : "null"));
+ g_free(szPath);
+ break;
+ }
+ g_free(szPath);
+
+ evas_object_image_size_get(img, &w, &h);
+ nSize = w * h * 4;
+
+ unsigned char *src = (unsigned char*)evas_object_image_data_get(img, EINA_FALSE);
+ if (!src || nSize <= 0) {
+ MAPS_LOGE("Failed to get the image buffer of new marker");
+ error = MAPS_ERROR_OUT_OF_MEMORY;
+ break;
+ }
+
+ unsigned char *dst = (unsigned char*)malloc(nSize);
+ if (!dst) {
+ error = MAPS_ERROR_OUT_OF_MEMORY;
+ break;
+ }
+ memcpy(dst, src, nSize);
+
+ /* resize the marker image */
+ int nw = 0, nh = 0;
+ if (__resizeMarker(hMarker, w, h, &nw, &nh, &dst))
+ {
+ w = nw;
+ h = nh;
+ nSize = w * h * 4;
+ maps_view_object_marker_set_size(hMarker, w, h);
+ }
+
+ /* convert RGBA to BGRA for GL */
+ _Util::ConvertRGBA2BGRA(dst, (unsigned)w, (unsigned)h);
+
+ Bitmap bmp;
+ bmp.Construct((const unsigned char*)dst, nSize, Dimension(w, h));
+ hereMarker->SetBitmap(bmp);
+ g_free(dst);
+
+
+ /* position */
+ maps_view_object_marker_get_coordinates(hMarker, &mapsCoord);
+ maps_coordinates_get_latitude(mapsCoord, &lat);
+ maps_coordinates_get_longitude(mapsCoord, &lng);
+ maps_coordinates_destroy(mapsCoord);
+
+ if (!HereUtils::IsValidCoord(lat, lng))
+ {
+ error = MAPS_ERROR_INVALID_PARAMETER;
+ break;
+ }
+
+ hereMarker->SetPosition(GeoCoordinates(lat, lng));
+
+ /* origin */
+ Tizen::Maps::FloatPoint fpntOrigin(0.5, 1);
+ hereMarker->SetMarkerOrigin(fpntOrigin);
+
+ /* z-order */
+ int z_order = 0;
+ maps_view_object_marker_get_z_order(hMarker, &z_order);
+ hereMarker->SetZorder(z_order);
+ } while(0);
+
+ if (img) evas_object_del(img);
+ return (here_error_e)ConvertToHereError(error);
+}
+
+here_error_e HereViewObjects::__updatePolyline(maps_view_object_h hPolyline, GeoMapObjectPolyline *herePolyline)
+{
+ if (!hPolyline || !herePolyline)
+ return HERE_ERROR_INVALID_PARAMETER;
+
+ int error = MAPS_ERROR_NONE;
+ GeoCoordinateList coordList;
+ unsigned char r, g, b, a;
+ int nThickness;
+
+ do {
+ error = maps_view_object_polyline_foreach_point(hPolyline, __foreachForCoordinates, &coordList);
+ if (error != MAPS_ERROR_NONE) break;
+ herePolyline->SetPath(coordList);
+
+ error = maps_view_object_polyline_get_color(hPolyline, &r, &g, &b, &a);
+ if (error != MAPS_ERROR_NONE) break;
+ herePolyline->SetStrokeColor(Color(r, g, b, a));
+
+ error = maps_view_object_polyline_get_width(hPolyline, &nThickness);
+ if (error != MAPS_ERROR_NONE) break;
+ herePolyline->SetStrokeThickness(nThickness);
+ } while(0);
+
+ return (here_error_e)ConvertToHereError(error);
+}
+
+here_error_e HereViewObjects::__updatePolygon(maps_view_object_h hPolygon, GeoMapObjectPolygon *herePolygon)
+{
+ if (!hPolygon || !herePolygon)
+ return HERE_ERROR_INVALID_PARAMETER;
+
+ int error = MAPS_ERROR_NONE;
+ GeoCoordinateList coordList;
+ unsigned char r, g, b, a;
+
+ do {
+ error = maps_view_object_polygon_foreach_point(hPolygon, __foreachForCoordinates, &coordList);
+ if (error != MAPS_ERROR_NONE) break;
+ herePolygon->SetPath(coordList);
+
+ error = maps_view_object_polygon_get_fill_color(hPolygon, &r, &g, &b, &a);
+ if (error != MAPS_ERROR_NONE) break;
+ herePolygon->SetFillColor(Color(r, g, b, a));
+ } while(0);
+
+ return (here_error_e)ConvertToHereError(error);
+}
+
+here_error_e HereViewObjects::__updateRoute(maps_view_object_h hRoute)
+{
+#ifdef TIZEN_3_0_NEXT_MS
+ if (!hRoute) return HERE_ERROR_INVALID_PARAMETER;
+
+ VisualObjects::iterator it;
+
+ if ((it = __currentObjects.find(hRoute)) != __currentObjects.end())
+ {
+ maps_route_h route = NULL;
+ int ret = maps_view_object_route_get_content(hRoute, &route);
+ if (ret != MAPS_ERROR_NONE || !route)
+ return HERE_ERROR_NONE;
+
+ GeoCoordinateList coordList;
+ GeoMapObjectPolyline *polyline_path = NULL, *polyline_seg = NULL;
+
+ if (it->second->GetType() == GeoMapObject::GMO_Polyline)
+ {
+ if (!polyline_path)
+ {
+ MAPS_LOGD("Route Path");
+ polyline_path = (GeoMapObjectPolyline*)it->second;
+ maps_route_foreach_path(route, __foreachForCoordinates, &coordList);
+ polyline_path->SetPath(coordList);
+ polyline_path->SetStrokeColor(Tizen::Maps::Color(255, 0, 0, 255));
+ polyline_path->SetStrokeThickness(3);
+ }
+ else if (!polyline_seg)
+ {
+ MAPS_LOGD("Route Segments");
+ polyline_seg = (GeoMapObjectPolyline*)it->second;
+ maps_route_foreach_path(route, __foreachForCoordinates, &coordList);
+ polyline_seg->SetPath(coordList);
+ polyline_seg->SetStrokeColor(Tizen::Maps::Color(0, 255, 0, 255));
+ polyline_seg->SetStrokeThickness(3);
+ }
+ }
+ else if (it->second->GetType() == GeoMapObject::GMO_Marker)
+ {
+ // to implement
+ }
+ maps_route_destroy(route);
+ }
+
+#endif /* TIZEN_3_0_NEXT_MS */
+ return HERE_ERROR_NONE;
+}
+
+here_error_e HereViewObjects::setVisible(maps_view_object_h hObj)
+{
+ if (!hObj) return HERE_ERROR_INVALID_PARAMETER;
+
+ bool visible;
+ maps_view_object_get_visible(hObj, &visible);
+ return __setVisible(hObj, visible);
+}
+
+here_error_e HereViewObjects::__setVisible(maps_view_object_h hObj, bool bVisible)
+{
+ if (!hObj) return HERE_ERROR_INVALID_PARAMETER;
+
+ here_error_e error = HERE_ERROR_NOT_FOUND;
+
+ VisualObjects::iterator it;
+ for (it = __currentObjects.begin(); it != __currentObjects.end(); it++)
+ {
+ if (it->first == hObj)
+ {
+ ((GeoMapObject*)it->second)->SetVisible(bVisible);
+ error = HERE_ERROR_NONE;
+ }
+ }
+
+ if (error == HERE_ERROR_NONE) __invalidate(hObj);
+ return error;
+}
+
+bool HereViewObjects::__foreachForCoordinates(int index, maps_coordinates_h point, void *user_data)
+{
+ if (!point || !user_data)
+ return false;
+
+ if (!HereUtils::IsValid(*(maps_coordinates_s*)point))
+ {
+ return false;
+ }
+
+ int error;
+ double lat = 0.0, lng = 0.0;
+
+ do {
+ error = maps_coordinates_get_latitude(point, &lat);
+ if (error != MAPS_ERROR_NONE) break;
+
+ error = maps_coordinates_get_longitude(point, &lng);
+ if (error != MAPS_ERROR_NONE) break;
+ } while(0);
+
+ MAPS_LOGD("[%d] %f,%f", index+1, lat, lng);
+
+ GeoCoordinateList *coordList = (GeoCoordinateList*)user_data;
+ coordList->push_back(GeoCoordinates(lat, lng));
+ return true;
+}
+
+bool HereViewObjects::__foreachForAddingGroupObjects(int index, int total, maps_view_object_h object, void *user_data)
+{
+ if (!user_data) return false;
+
+ HereViewObjects *hereViewObjects = (HereViewObjects*)user_data;
+ here_error_e error = hereViewObjects->add(object);
+ return (error == HERE_ERROR_NONE);
+}
+
+bool HereViewObjects::__foreachForRemovingGroupObjects(int index, int total, maps_view_object_h object, void *user_data)
+{
+ if (!user_data) return false;
+
+ HereViewObjects *hereViewObjects = (HereViewObjects*)user_data;
+ here_error_e error = hereViewObjects->remove(object);
+ return (error == HERE_ERROR_NONE);
+}
+
+bool HereViewObjects::__foreachForUpdatingGroupObjects(int index, int total, maps_view_object_h object, void *user_data)
+{
+ if (!user_data) return false;
+
+ HereViewObjects *hereViewObjects = (HereViewObjects*)user_data;
+ here_error_e error = hereViewObjects->update(object);
+ return (error == HERE_ERROR_NONE);
+}
+
+bool HereViewObjects::__foreachForSettingVisibleGroupObjects(int index, int total, maps_view_object_h object, void *user_data)
+{
+ if (!user_data) return false;
+
+ HereViewObjects *hereViewObjects = (HereViewObjects*)user_data;
+ here_error_e error = hereViewObjects->setVisible(object);
+ return (error == HERE_ERROR_NONE);
+}
+
+bool HereViewObjects::__resizeMarker(maps_view_object_h hMarker,
+ const int originWidth, const int originHeight,
+ int *newWidth, int *newHeight, unsigned char **bitmap)
+{
+ if (!hMarker || !newWidth || !newHeight || !bitmap || !*bitmap)
+ return false;
+
+ int resizedWidth = 0, resizedHeight = 0;
+ maps_view_object_marker_get_size(hMarker, &resizedWidth, &resizedHeight);
+
+ if (__resizeBitmap(bitmap, originWidth, originHeight, resizedWidth, resizedHeight))
+ {
+ *newWidth = resizedWidth;
+ *newHeight = resizedHeight;
+ return true;
+ }
+ return false;
+}
+
+bool HereViewObjects::__resizeBitmap(unsigned char **curBmp, int curWidth, int curHeight, int newWidth, int newHeight)
+{
+ if (!curBmp || curWidth <= 0 || curHeight <= 0 || newWidth <= 0 || newHeight <= 0) return false;
+ if (curWidth == newWidth && curHeight == newHeight) return false;
+
+ unsigned char* newBmp = new unsigned char[newWidth * newHeight * 4];
+
+ double scaleWidth = (double)newWidth / (double)curWidth;
+ double scaleHeight = (double)newHeight / (double)curHeight;
+
+ int newPixel, curPixel;
+
+ for(int y = 0; y < newHeight; y++)
+ {
+ for(int x = 0; x < newWidth; x++)
+ {
+ newPixel = (y * (newWidth *4)) + (x * 4);
+ curPixel = (((int)(y / scaleHeight) * (curWidth * 4)) + ((int)(x / scaleWidth) * 4));
+
+ newBmp[newPixel ] = (*curBmp)[curPixel ];
+ newBmp[newPixel + 1] = (*curBmp)[curPixel + 1];
+ newBmp[newPixel + 2] = (*curBmp)[curPixel + 2];
+ newBmp[newPixel + 3] = (*curBmp)[curPixel + 3];
+ }
+ }
+
+ delete [] *curBmp;
+ *curBmp = newBmp;
+ return true;
+}
+
+void HereViewObjects::__invalidate(maps_view_object_h hObj)
+{
+ maps_view_object_type_e type;
+ maps_view_object_get_type(hObj, &type);
+
+ if (!hObj || type != MAPS_VIEW_OBJECT_MARKER)
+ __map->InvalidateMapObjects();
+ else
+ __map->InvalidateMapMarkers();
+}
+
+HERE_PLUGIN_END_NAMESPACE