diff --git a/ground/src/libs/libs.pro b/ground/src/libs/libs.pro
index e899a07df..bcb230f45 100644
--- a/ground/src/libs/libs.pro
+++ b/ground/src/libs/libs.pro
@@ -11,5 +11,6 @@ SUBDIRS = \
utils \
glc_lib\
qymodem \
- libqxt
+ libqxt# \
+ # opmapcontrol
diff --git a/ground/src/libs/opmapcontrol/opmapcontrol.h b/ground/src/libs/opmapcontrol/opmapcontrol.h
new file mode 100644
index 000000000..4add132fd
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/opmapcontrol.h
@@ -0,0 +1 @@
+#include "src/mapwidget/opmapwidget.h"
diff --git a/ground/src/libs/opmapcontrol/opmapcontrol.pri b/ground/src/libs/opmapcontrol/opmapcontrol.pri
new file mode 100644
index 000000000..5726bf11c
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/opmapcontrol.pri
@@ -0,0 +1 @@
+LIBS *= -l$$qtLibraryTarget(OPMapWidget)
diff --git a/ground/src/libs/opmapcontrol/opmapcontrol.pro b/ground/src/libs/opmapcontrol/opmapcontrol.pro
new file mode 100644
index 000000000..6a3ccf724
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/opmapcontrol.pro
@@ -0,0 +1,3 @@
+TEMPLATE = subdirs
+
+SUBDIRS = src \
diff --git a/ground/src/libs/opmapcontrol/src/common.pri b/ground/src/libs/opmapcontrol/src/common.pri
new file mode 100644
index 000000000..fa9b16603
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/common.pri
@@ -0,0 +1,8 @@
+DESTDIR = ../build
+QT += network
+QT += sql
+CONFIG += staticlib
+TEMPLATE = lib
+UI_DIR = uics
+MOC_DIR = mocs
+OBJECTS_DIR = objs
diff --git a/ground/src/libs/opmapcontrol/src/core/Makefile b/ground/src/libs/opmapcontrol/src/core/Makefile
new file mode 100644
index 000000000..431d8bb38
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/Makefile
@@ -0,0 +1,143 @@
+#############################################################################
+# Makefile for building: libcore
+# Generated by qmake (2.01a) (Qt 4.6.2) on: seg 14. Jun 17:55:34 2010
+# Project: core.pro
+# Template: lib
+# Command: c:\qt\2010.02.1\qt\bin\qmake.exe -spec c:\Qt\2010.02.1\qt\mkspecs\win32-g++ -win32 -o Makefile core.pro
+#############################################################################
+
+first: debug
+install: debug-install
+uninstall: debug-uninstall
+MAKEFILE = Makefile
+QMAKE = c:\qt\2010.02.1\qt\bin\qmake.exe
+DEL_FILE = del
+CHK_DIR_EXISTS= if not exist
+MKDIR = mkdir
+COPY = copy /y
+COPY_FILE = $(COPY)
+COPY_DIR = xcopy /s /q /y /i
+INSTALL_FILE = $(COPY_FILE)
+INSTALL_PROGRAM = $(COPY_FILE)
+INSTALL_DIR = $(COPY_DIR)
+DEL_FILE = del
+SYMLINK =
+DEL_DIR = rmdir
+MOVE = move
+CHK_DIR_EXISTS= if not exist
+MKDIR = mkdir
+SUBTARGETS = \
+ debug \
+ release
+
+debug: $(MAKEFILE).Debug FORCE
+ $(MAKE) -f $(MAKEFILE).Debug
+debug-make_default: $(MAKEFILE).Debug FORCE
+ $(MAKE) -f $(MAKEFILE).Debug
+debug-make_first: $(MAKEFILE).Debug FORCE
+ $(MAKE) -f $(MAKEFILE).Debug first
+debug-all: $(MAKEFILE).Debug FORCE
+ $(MAKE) -f $(MAKEFILE).Debug all
+debug-clean: $(MAKEFILE).Debug FORCE
+ $(MAKE) -f $(MAKEFILE).Debug clean
+debug-distclean: $(MAKEFILE).Debug FORCE
+ $(MAKE) -f $(MAKEFILE).Debug distclean
+debug-install: $(MAKEFILE).Debug FORCE
+ $(MAKE) -f $(MAKEFILE).Debug install
+debug-uninstall: $(MAKEFILE).Debug FORCE
+ $(MAKE) -f $(MAKEFILE).Debug uninstall
+release: $(MAKEFILE).Release FORCE
+ $(MAKE) -f $(MAKEFILE).Release
+release-make_default: $(MAKEFILE).Release FORCE
+ $(MAKE) -f $(MAKEFILE).Release
+release-make_first: $(MAKEFILE).Release FORCE
+ $(MAKE) -f $(MAKEFILE).Release first
+release-all: $(MAKEFILE).Release FORCE
+ $(MAKE) -f $(MAKEFILE).Release all
+release-clean: $(MAKEFILE).Release FORCE
+ $(MAKE) -f $(MAKEFILE).Release clean
+release-distclean: $(MAKEFILE).Release FORCE
+ $(MAKE) -f $(MAKEFILE).Release distclean
+release-install: $(MAKEFILE).Release FORCE
+ $(MAKE) -f $(MAKEFILE).Release install
+release-uninstall: $(MAKEFILE).Release FORCE
+ $(MAKE) -f $(MAKEFILE).Release uninstall
+
+Makefile: core.pro c:/Qt/2010.02.1/qt/mkspecs/win32-g++/qmake.conf c:/Qt/2010.02.1/qt/mkspecs/qconfig.pri \
+ c:/Qt/2010.02.1/qt/mkspecs/features/qt_functions.prf \
+ c:/Qt/2010.02.1/qt/mkspecs/features/qt_config.prf \
+ c:/Qt/2010.02.1/qt/mkspecs/features/exclusive_builds.prf \
+ c:/Qt/2010.02.1/qt/mkspecs/features/default_pre.prf \
+ c:/Qt/2010.02.1/qt/mkspecs/features/win32/default_pre.prf \
+ ../common.pri \
+ c:/Qt/2010.02.1/qt/mkspecs/features/debug.prf \
+ c:/Qt/2010.02.1/qt/mkspecs/features/debug_and_release.prf \
+ c:/Qt/2010.02.1/qt/mkspecs/features/default_post.prf \
+ c:/Qt/2010.02.1/qt/mkspecs/features/win32/default_post.prf \
+ c:/Qt/2010.02.1/qt/mkspecs/features/staticlib.prf \
+ c:/Qt/2010.02.1/qt/mkspecs/features/static.prf \
+ c:/Qt/2010.02.1/qt/mkspecs/features/win32/rtti.prf \
+ c:/Qt/2010.02.1/qt/mkspecs/features/win32/exceptions.prf \
+ c:/Qt/2010.02.1/qt/mkspecs/features/win32/stl.prf \
+ c:/Qt/2010.02.1/qt/mkspecs/features/warn_on.prf \
+ c:/Qt/2010.02.1/qt/mkspecs/features/qt.prf \
+ c:/Qt/2010.02.1/qt/mkspecs/features/win32/thread.prf \
+ c:/Qt/2010.02.1/qt/mkspecs/features/moc.prf \
+ c:/Qt/2010.02.1/qt/mkspecs/features/win32/windows.prf \
+ c:/Qt/2010.02.1/qt/mkspecs/features/resources.prf \
+ c:/Qt/2010.02.1/qt/mkspecs/features/uic.prf \
+ c:/Qt/2010.02.1/qt/mkspecs/features/yacc.prf \
+ c:/Qt/2010.02.1/qt/mkspecs/features/lex.prf
+ $(QMAKE) -spec c:\Qt\2010.02.1\qt\mkspecs\win32-g++ -win32 -o Makefile core.pro
+c:\Qt\2010.02.1\qt\mkspecs\qconfig.pri:
+c:\Qt\2010.02.1\qt\mkspecs\features\qt_functions.prf:
+c:\Qt\2010.02.1\qt\mkspecs\features\qt_config.prf:
+c:\Qt\2010.02.1\qt\mkspecs\features\exclusive_builds.prf:
+c:\Qt\2010.02.1\qt\mkspecs\features\default_pre.prf:
+c:\Qt\2010.02.1\qt\mkspecs\features\win32\default_pre.prf:
+..\common.pri:
+c:\Qt\2010.02.1\qt\mkspecs\features\debug.prf:
+c:\Qt\2010.02.1\qt\mkspecs\features\debug_and_release.prf:
+c:\Qt\2010.02.1\qt\mkspecs\features\default_post.prf:
+c:\Qt\2010.02.1\qt\mkspecs\features\win32\default_post.prf:
+c:\Qt\2010.02.1\qt\mkspecs\features\staticlib.prf:
+c:\Qt\2010.02.1\qt\mkspecs\features\static.prf:
+c:\Qt\2010.02.1\qt\mkspecs\features\win32\rtti.prf:
+c:\Qt\2010.02.1\qt\mkspecs\features\win32\exceptions.prf:
+c:\Qt\2010.02.1\qt\mkspecs\features\win32\stl.prf:
+c:\Qt\2010.02.1\qt\mkspecs\features\warn_on.prf:
+c:\Qt\2010.02.1\qt\mkspecs\features\qt.prf:
+c:\Qt\2010.02.1\qt\mkspecs\features\win32\thread.prf:
+c:\Qt\2010.02.1\qt\mkspecs\features\moc.prf:
+c:\Qt\2010.02.1\qt\mkspecs\features\win32\windows.prf:
+c:\Qt\2010.02.1\qt\mkspecs\features\resources.prf:
+c:\Qt\2010.02.1\qt\mkspecs\features\uic.prf:
+c:\Qt\2010.02.1\qt\mkspecs\features\yacc.prf:
+c:\Qt\2010.02.1\qt\mkspecs\features\lex.prf:
+qmake: qmake_all FORCE
+ @$(QMAKE) -spec c:\Qt\2010.02.1\qt\mkspecs\win32-g++ -win32 -o Makefile core.pro
+
+qmake_all: FORCE
+
+make_default: debug-make_default release-make_default FORCE
+make_first: debug-make_first release-make_first FORCE
+all: debug-all release-all FORCE
+clean: debug-clean release-clean FORCE
+distclean: debug-distclean release-distclean FORCE
+ -$(DEL_FILE) Makefile
+
+debug-mocclean: $(MAKEFILE).Debug
+ $(MAKE) -f $(MAKEFILE).Debug mocclean
+release-mocclean: $(MAKEFILE).Release
+ $(MAKE) -f $(MAKEFILE).Release mocclean
+mocclean: debug-mocclean release-mocclean
+
+debug-mocables: $(MAKEFILE).Debug
+ $(MAKE) -f $(MAKEFILE).Debug mocables
+release-mocables: $(MAKEFILE).Release
+ $(MAKE) -f $(MAKEFILE).Release mocables
+mocables: debug-mocables release-mocables
+FORCE:
+
+$(MAKEFILE).Debug: Makefile
+$(MAKEFILE).Release: Makefile
diff --git a/ground/src/libs/opmapcontrol/src/core/Makefile.Debug b/ground/src/libs/opmapcontrol/src/core/Makefile.Debug
new file mode 100644
index 000000000..b0deb27bf
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/Makefile.Debug
@@ -0,0 +1,311 @@
+#############################################################################
+# Makefile for building: libcore
+# Generated by qmake (2.01a) (Qt 4.6.2) on: seg 14. Jun 17:55:34 2010
+# Project: core.pro
+# Template: lib
+#############################################################################
+
+####### Compiler, tools and options
+
+CC = gcc
+CXX = g++
+DEFINES = -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_SQL_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT
+CFLAGS = -g -Wall $(DEFINES)
+CXXFLAGS = -g -frtti -fexceptions -mthreads -Wall $(DEFINES)
+INCPATH = -I"c:\Qt\2010.02.1\qt\include\QtCore" -I"c:\Qt\2010.02.1\qt\include\QtNetwork" -I"c:\Qt\2010.02.1\qt\include\QtGui" -I"c:\Qt\2010.02.1\qt\include\QtSql" -I"c:\Qt\2010.02.1\qt\include" -I"c:\Qt\2010.02.1\qt\include\ActiveQt" -I"mocs" -I"c:\Qt\2010.02.1\qt\mkspecs\win32-g++"
+LIB = ar -ru
+QMAKE = c:\qt\2010.02.1\qt\bin\qmake.exe
+IDC = c:\Qt\2010.02.1\qt\bin\idc.exe
+IDL = midl
+ZIP = zip -r -9
+DEF_FILE =
+RES_FILE =
+COPY = copy /y
+COPY_FILE = $(COPY)
+COPY_DIR = xcopy /s /q /y /i
+DEL_FILE = del
+DEL_DIR = rmdir
+MOVE = move
+CHK_DIR_EXISTS= if not exist
+MKDIR = mkdir
+INSTALL_FILE = $(COPY_FILE)
+INSTALL_PROGRAM = $(COPY_FILE)
+INSTALL_DIR = $(COPY_DIR)
+
+####### Output directory
+
+OBJECTS_DIR = objs
+
+####### Files
+
+SOURCES = opmaps.cpp \
+ pureimagecache.cpp \
+ pureimage.cpp \
+ rawtile.cpp \
+ memorycache.cpp \
+ cache.cpp \
+ languagetype.cpp \
+ providerstrings.cpp \
+ cacheitemqueue.cpp \
+ tilecachequeue.cpp \
+ alllayersoftype.cpp \
+ urlfactory.cpp \
+ placemark.cpp \
+ point.cpp \
+ size.cpp \
+ kibertilecache.cpp mocs\moc_maptype.cpp \
+ mocs\moc_tilecachequeue.cpp \
+ mocs\moc_urlfactory.cpp \
+ mocs\moc_geodecoderstatus.cpp
+OBJECTS = objs/opmaps.o \
+ objs/pureimagecache.o \
+ objs/pureimage.o \
+ objs/rawtile.o \
+ objs/memorycache.o \
+ objs/cache.o \
+ objs/languagetype.o \
+ objs/providerstrings.o \
+ objs/cacheitemqueue.o \
+ objs/tilecachequeue.o \
+ objs/alllayersoftype.o \
+ objs/urlfactory.o \
+ objs/placemark.o \
+ objs/point.o \
+ objs/size.o \
+ objs/kibertilecache.o \
+ objs/moc_maptype.o \
+ objs/moc_tilecachequeue.o \
+ objs/moc_urlfactory.o \
+ objs/moc_geodecoderstatus.o
+DIST =
+QMAKE_TARGET = core
+DESTDIR = ..\build\ #avoid trailing-slash linebreak
+TARGET = libcore.a
+DESTDIR_TARGET = ..\build\libcore.a
+
+####### Implicit rules
+
+.SUFFIXES: .cpp .cc .cxx .c
+
+.cpp.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.cc.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.cxx.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.c.o:
+ $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
+
+####### Build rules
+
+first: all
+all: Makefile.Debug $(DESTDIR_TARGET)
+
+$(DESTDIR_TARGET): $(OBJECTS)
+ ar -M < object_script.libcore.Debug
+
+
+qmake: FORCE
+ @$(QMAKE) -spec c:\Qt\2010.02.1\qt\mkspecs\win32-g++ -win32 -o Makefile.Debug core.pro
+
+dist:
+ $(ZIP) core.zip $(SOURCES) $(DIST) c:\Users\Xapo\Documents\QT\OpenPilot\openpilotgcs.pro c:\Qt\2010.02.1\qt\mkspecs\qconfig.pri c:\Qt\2010.02.1\qt\mkspecs\features\qt_functions.prf c:\Qt\2010.02.1\qt\mkspecs\features\qt_config.prf c:\Qt\2010.02.1\qt\mkspecs\features\exclusive_builds.prf c:\Qt\2010.02.1\qt\mkspecs\features\default_pre.prf c:\Qt\2010.02.1\qt\mkspecs\features\win32\default_pre.prf ..\common.pri c:\Qt\2010.02.1\qt\mkspecs\features\debug.prf c:\Qt\2010.02.1\qt\mkspecs\features\debug_and_release.prf c:\Qt\2010.02.1\qt\mkspecs\features\default_post.prf c:\Qt\2010.02.1\qt\mkspecs\features\win32\default_post.prf c:\Qt\2010.02.1\qt\mkspecs\features\build_pass.prf c:\Qt\2010.02.1\qt\mkspecs\features\staticlib.prf c:\Qt\2010.02.1\qt\mkspecs\features\static.prf c:\Qt\2010.02.1\qt\mkspecs\features\win32\rtti.prf c:\Qt\2010.02.1\qt\mkspecs\features\win32\exceptions.prf c:\Qt\2010.02.1\qt\mkspecs\features\win32\stl.prf c:\Qt\2010.02.1\qt\mkspecs\features\warn_on.prf c:\Qt\2010.02.1\qt\mkspecs\features\qt.prf c:\Qt\2010.02.1\qt\mkspecs\features\win32\thread.prf c:\Qt\2010.02.1\qt\mkspecs\features\moc.prf c:\Qt\2010.02.1\qt\mkspecs\features\win32\windows.prf c:\Qt\2010.02.1\qt\mkspecs\features\resources.prf c:\Qt\2010.02.1\qt\mkspecs\features\uic.prf c:\Qt\2010.02.1\qt\mkspecs\features\yacc.prf c:\Qt\2010.02.1\qt\mkspecs\features\lex.prf HEADERS RESOURCES IMAGES SOURCES OBJECTIVE_SOURCES FORMS YACCSOURCES YACCSOURCES LEXSOURCES
+
+clean: compiler_clean
+ -$(DEL_FILE) objs\opmaps.o objs\pureimagecache.o objs\pureimage.o objs\rawtile.o objs\memorycache.o objs\cache.o objs\languagetype.o objs\providerstrings.o objs\cacheitemqueue.o objs\tilecachequeue.o objs\alllayersoftype.o objs\urlfactory.o objs\placemark.o objs\point.o objs\size.o objs\kibertilecache.o objs\moc_maptype.o objs\moc_tilecachequeue.o objs\moc_urlfactory.o objs\moc_geodecoderstatus.o
+
+distclean: clean
+ -$(DEL_FILE) $(DESTDIR_TARGET)
+ -$(DEL_FILE) Makefile.Debug
+
+mocclean: compiler_moc_header_clean compiler_moc_source_clean
+
+mocables: compiler_moc_header_make_all compiler_moc_source_make_all
+
+compiler_moc_header_make_all: mocs/moc_maptype.cpp mocs/moc_tilecachequeue.cpp mocs/moc_urlfactory.cpp mocs/moc_geodecoderstatus.cpp
+compiler_moc_header_clean:
+ -$(DEL_FILE) mocs\moc_maptype.cpp mocs\moc_tilecachequeue.cpp mocs\moc_urlfactory.cpp mocs\moc_geodecoderstatus.cpp
+mocs/moc_maptype.cpp: maptype.h
+ C:/Qt/2010.02.1/qt/bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 maptype.h -o mocs\moc_maptype.cpp
+
+mocs/moc_tilecachequeue.cpp: cacheitemqueue.h \
+ maptype.h \
+ point.h \
+ pureimagecache.h \
+ pureimage.h \
+ cache.h \
+ debugheader.h \
+ tilecachequeue.h
+ C:/Qt/2010.02.1/qt/bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 tilecachequeue.h -o mocs\moc_tilecachequeue.cpp
+
+mocs/moc_urlfactory.cpp: providerstrings.h \
+ pureimagecache.h \
+ maptype.h \
+ point.h \
+ pureimage.h \
+ ../internals/pointlatlng.h \
+ ../internals/sizelatlng.h \
+ geodecoderstatus.h \
+ cache.h \
+ debugheader.h \
+ placemark.h \
+ urlfactory.h
+ C:/Qt/2010.02.1/qt/bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 urlfactory.h -o mocs\moc_urlfactory.cpp
+
+mocs/moc_geodecoderstatus.cpp: geodecoderstatus.h
+ C:/Qt/2010.02.1/qt/bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 geodecoderstatus.h -o mocs\moc_geodecoderstatus.cpp
+
+compiler_rcc_make_all:
+compiler_rcc_clean:
+compiler_image_collection_make_all: qmake_image_collection.cpp
+compiler_image_collection_clean:
+ -$(DEL_FILE) qmake_image_collection.cpp
+compiler_moc_source_make_all:
+compiler_moc_source_clean:
+compiler_uic_make_all:
+compiler_uic_clean:
+compiler_yacc_decl_make_all:
+compiler_yacc_decl_clean:
+compiler_yacc_impl_make_all:
+compiler_yacc_impl_clean:
+compiler_lex_make_all:
+compiler_lex_clean:
+compiler_clean: compiler_moc_header_clean
+
+
+
+####### Compile
+
+objs/opmaps.o: opmaps.cpp opmaps.h \
+ debugheader.h \
+ memorycache.h \
+ rawtile.h \
+ maptype.h \
+ point.h \
+ kibertilecache.h \
+ cache.h \
+ pureimagecache.h \
+ pureimage.h \
+ accessmode.h \
+ languagetype.h \
+ cacheitemqueue.h \
+ tilecachequeue.h \
+ alllayersoftype.h \
+ urlfactory.h \
+ providerstrings.h \
+ ../internals/pointlatlng.h \
+ ../internals/sizelatlng.h \
+ geodecoderstatus.h \
+ placemark.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\opmaps.o opmaps.cpp
+
+objs/pureimagecache.o: pureimagecache.cpp pureimagecache.h \
+ maptype.h \
+ point.h \
+ pureimage.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\pureimagecache.o pureimagecache.cpp
+
+objs/pureimage.o: pureimage.cpp pureimage.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\pureimage.o pureimage.cpp
+
+objs/rawtile.o: rawtile.cpp rawtile.h \
+ maptype.h \
+ point.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\rawtile.o rawtile.cpp
+
+objs/memorycache.o: memorycache.cpp memorycache.h \
+ rawtile.h \
+ maptype.h \
+ point.h \
+ kibertilecache.h \
+ debugheader.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\memorycache.o memorycache.cpp
+
+objs/cache.o: cache.cpp cache.h \
+ pureimagecache.h \
+ maptype.h \
+ point.h \
+ pureimage.h \
+ debugheader.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\cache.o cache.cpp
+
+objs/languagetype.o: languagetype.cpp languagetype.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\languagetype.o languagetype.cpp
+
+objs/providerstrings.o: providerstrings.cpp providerstrings.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\providerstrings.o providerstrings.cpp
+
+objs/cacheitemqueue.o: cacheitemqueue.cpp cacheitemqueue.h \
+ maptype.h \
+ point.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\cacheitemqueue.o cacheitemqueue.cpp
+
+objs/tilecachequeue.o: tilecachequeue.cpp tilecachequeue.h \
+ cacheitemqueue.h \
+ maptype.h \
+ point.h \
+ pureimagecache.h \
+ pureimage.h \
+ cache.h \
+ debugheader.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\tilecachequeue.o tilecachequeue.cpp
+
+objs/alllayersoftype.o: alllayersoftype.cpp alllayersoftype.h \
+ maptype.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\alllayersoftype.o alllayersoftype.cpp
+
+objs/urlfactory.o: urlfactory.cpp urlfactory.h \
+ providerstrings.h \
+ pureimagecache.h \
+ maptype.h \
+ point.h \
+ pureimage.h \
+ ../internals/pointlatlng.h \
+ ../internals/sizelatlng.h \
+ geodecoderstatus.h \
+ cache.h \
+ debugheader.h \
+ placemark.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\urlfactory.o urlfactory.cpp
+
+objs/placemark.o: placemark.cpp placemark.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\placemark.o placemark.cpp
+
+objs/point.o: point.cpp point.h \
+ size.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\point.o point.cpp
+
+objs/size.o: size.cpp size.h \
+ point.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\size.o size.cpp
+
+objs/kibertilecache.o: kibertilecache.cpp kibertilecache.h \
+ rawtile.h \
+ maptype.h \
+ point.h \
+ debugheader.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\kibertilecache.o kibertilecache.cpp
+
+objs/moc_maptype.o: mocs/moc_maptype.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\moc_maptype.o mocs\moc_maptype.cpp
+
+objs/moc_tilecachequeue.o: mocs/moc_tilecachequeue.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\moc_tilecachequeue.o mocs\moc_tilecachequeue.cpp
+
+objs/moc_urlfactory.o: mocs/moc_urlfactory.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\moc_urlfactory.o mocs\moc_urlfactory.cpp
+
+objs/moc_geodecoderstatus.o: mocs/moc_geodecoderstatus.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\moc_geodecoderstatus.o mocs\moc_geodecoderstatus.cpp
+
+####### Install
+
+install: FORCE
+
+uninstall: FORCE
+
+FORCE:
+
diff --git a/ground/src/libs/opmapcontrol/src/core/Makefile.Release b/ground/src/libs/opmapcontrol/src/core/Makefile.Release
new file mode 100644
index 000000000..e5a1fe2a9
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/Makefile.Release
@@ -0,0 +1,311 @@
+#############################################################################
+# Makefile for building: libcore
+# Generated by qmake (2.01a) (Qt 4.6.2) on: seg 14. Jun 17:55:34 2010
+# Project: core.pro
+# Template: lib
+#############################################################################
+
+####### Compiler, tools and options
+
+CC = gcc
+CXX = g++
+DEFINES = -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_SQL_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT
+CFLAGS = -O2 -Wall $(DEFINES)
+CXXFLAGS = -O2 -frtti -fexceptions -mthreads -Wall $(DEFINES)
+INCPATH = -I"c:\Qt\2010.02.1\qt\include\QtCore" -I"c:\Qt\2010.02.1\qt\include\QtNetwork" -I"c:\Qt\2010.02.1\qt\include\QtGui" -I"c:\Qt\2010.02.1\qt\include\QtSql" -I"c:\Qt\2010.02.1\qt\include" -I"c:\Qt\2010.02.1\qt\include\ActiveQt" -I"mocs" -I"c:\Qt\2010.02.1\qt\mkspecs\win32-g++"
+LIB = ar -ru
+QMAKE = c:\qt\2010.02.1\qt\bin\qmake.exe
+IDC = c:\Qt\2010.02.1\qt\bin\idc.exe
+IDL = midl
+ZIP = zip -r -9
+DEF_FILE =
+RES_FILE =
+COPY = copy /y
+COPY_FILE = $(COPY)
+COPY_DIR = xcopy /s /q /y /i
+DEL_FILE = del
+DEL_DIR = rmdir
+MOVE = move
+CHK_DIR_EXISTS= if not exist
+MKDIR = mkdir
+INSTALL_FILE = $(COPY_FILE)
+INSTALL_PROGRAM = $(COPY_FILE)
+INSTALL_DIR = $(COPY_DIR)
+
+####### Output directory
+
+OBJECTS_DIR = objs
+
+####### Files
+
+SOURCES = opmaps.cpp \
+ pureimagecache.cpp \
+ pureimage.cpp \
+ rawtile.cpp \
+ memorycache.cpp \
+ cache.cpp \
+ languagetype.cpp \
+ providerstrings.cpp \
+ cacheitemqueue.cpp \
+ tilecachequeue.cpp \
+ alllayersoftype.cpp \
+ urlfactory.cpp \
+ placemark.cpp \
+ point.cpp \
+ size.cpp \
+ kibertilecache.cpp mocs\moc_maptype.cpp \
+ mocs\moc_tilecachequeue.cpp \
+ mocs\moc_urlfactory.cpp \
+ mocs\moc_geodecoderstatus.cpp
+OBJECTS = objs/opmaps.o \
+ objs/pureimagecache.o \
+ objs/pureimage.o \
+ objs/rawtile.o \
+ objs/memorycache.o \
+ objs/cache.o \
+ objs/languagetype.o \
+ objs/providerstrings.o \
+ objs/cacheitemqueue.o \
+ objs/tilecachequeue.o \
+ objs/alllayersoftype.o \
+ objs/urlfactory.o \
+ objs/placemark.o \
+ objs/point.o \
+ objs/size.o \
+ objs/kibertilecache.o \
+ objs/moc_maptype.o \
+ objs/moc_tilecachequeue.o \
+ objs/moc_urlfactory.o \
+ objs/moc_geodecoderstatus.o
+DIST =
+QMAKE_TARGET = core
+DESTDIR = ..\build\ #avoid trailing-slash linebreak
+TARGET = libcore.a
+DESTDIR_TARGET = ..\build\libcore.a
+
+####### Implicit rules
+
+.SUFFIXES: .cpp .cc .cxx .c
+
+.cpp.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.cc.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.cxx.o:
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
+
+.c.o:
+ $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
+
+####### Build rules
+
+first: all
+all: Makefile.Release $(DESTDIR_TARGET)
+
+$(DESTDIR_TARGET): $(OBJECTS)
+ ar -M < object_script.libcore.Release
+
+
+qmake: FORCE
+ @$(QMAKE) -spec c:\Qt\2010.02.1\qt\mkspecs\win32-g++ -win32 -o Makefile.Release core.pro
+
+dist:
+ $(ZIP) core.zip $(SOURCES) $(DIST) c:\Users\Xapo\Documents\QT\OpenPilot\openpilotgcs.pro c:\Qt\2010.02.1\qt\mkspecs\qconfig.pri c:\Qt\2010.02.1\qt\mkspecs\features\qt_functions.prf c:\Qt\2010.02.1\qt\mkspecs\features\qt_config.prf c:\Qt\2010.02.1\qt\mkspecs\features\exclusive_builds.prf c:\Qt\2010.02.1\qt\mkspecs\features\default_pre.prf c:\Qt\2010.02.1\qt\mkspecs\features\win32\default_pre.prf ..\common.pri c:\Qt\2010.02.1\qt\mkspecs\features\release.prf c:\Qt\2010.02.1\qt\mkspecs\features\debug_and_release.prf c:\Qt\2010.02.1\qt\mkspecs\features\default_post.prf c:\Qt\2010.02.1\qt\mkspecs\features\win32\default_post.prf c:\Qt\2010.02.1\qt\mkspecs\features\build_pass.prf c:\Qt\2010.02.1\qt\mkspecs\features\staticlib.prf c:\Qt\2010.02.1\qt\mkspecs\features\static.prf c:\Qt\2010.02.1\qt\mkspecs\features\win32\rtti.prf c:\Qt\2010.02.1\qt\mkspecs\features\win32\exceptions.prf c:\Qt\2010.02.1\qt\mkspecs\features\win32\stl.prf c:\Qt\2010.02.1\qt\mkspecs\features\warn_on.prf c:\Qt\2010.02.1\qt\mkspecs\features\qt.prf c:\Qt\2010.02.1\qt\mkspecs\features\win32\thread.prf c:\Qt\2010.02.1\qt\mkspecs\features\moc.prf c:\Qt\2010.02.1\qt\mkspecs\features\win32\windows.prf c:\Qt\2010.02.1\qt\mkspecs\features\resources.prf c:\Qt\2010.02.1\qt\mkspecs\features\uic.prf c:\Qt\2010.02.1\qt\mkspecs\features\yacc.prf c:\Qt\2010.02.1\qt\mkspecs\features\lex.prf HEADERS RESOURCES IMAGES SOURCES OBJECTIVE_SOURCES FORMS YACCSOURCES YACCSOURCES LEXSOURCES
+
+clean: compiler_clean
+ -$(DEL_FILE) objs\opmaps.o objs\pureimagecache.o objs\pureimage.o objs\rawtile.o objs\memorycache.o objs\cache.o objs\languagetype.o objs\providerstrings.o objs\cacheitemqueue.o objs\tilecachequeue.o objs\alllayersoftype.o objs\urlfactory.o objs\placemark.o objs\point.o objs\size.o objs\kibertilecache.o objs\moc_maptype.o objs\moc_tilecachequeue.o objs\moc_urlfactory.o objs\moc_geodecoderstatus.o
+
+distclean: clean
+ -$(DEL_FILE) $(DESTDIR_TARGET)
+ -$(DEL_FILE) Makefile.Release
+
+mocclean: compiler_moc_header_clean compiler_moc_source_clean
+
+mocables: compiler_moc_header_make_all compiler_moc_source_make_all
+
+compiler_moc_header_make_all: mocs/moc_maptype.cpp mocs/moc_tilecachequeue.cpp mocs/moc_urlfactory.cpp mocs/moc_geodecoderstatus.cpp
+compiler_moc_header_clean:
+ -$(DEL_FILE) mocs\moc_maptype.cpp mocs\moc_tilecachequeue.cpp mocs\moc_urlfactory.cpp mocs\moc_geodecoderstatus.cpp
+mocs/moc_maptype.cpp: maptype.h
+ C:/Qt/2010.02.1/qt/bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 maptype.h -o mocs\moc_maptype.cpp
+
+mocs/moc_tilecachequeue.cpp: cacheitemqueue.h \
+ maptype.h \
+ point.h \
+ pureimagecache.h \
+ pureimage.h \
+ cache.h \
+ debugheader.h \
+ tilecachequeue.h
+ C:/Qt/2010.02.1/qt/bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 tilecachequeue.h -o mocs\moc_tilecachequeue.cpp
+
+mocs/moc_urlfactory.cpp: providerstrings.h \
+ pureimagecache.h \
+ maptype.h \
+ point.h \
+ pureimage.h \
+ ../internals/pointlatlng.h \
+ ../internals/sizelatlng.h \
+ geodecoderstatus.h \
+ cache.h \
+ debugheader.h \
+ placemark.h \
+ urlfactory.h
+ C:/Qt/2010.02.1/qt/bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 urlfactory.h -o mocs\moc_urlfactory.cpp
+
+mocs/moc_geodecoderstatus.cpp: geodecoderstatus.h
+ C:/Qt/2010.02.1/qt/bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 geodecoderstatus.h -o mocs\moc_geodecoderstatus.cpp
+
+compiler_rcc_make_all:
+compiler_rcc_clean:
+compiler_image_collection_make_all: qmake_image_collection.cpp
+compiler_image_collection_clean:
+ -$(DEL_FILE) qmake_image_collection.cpp
+compiler_moc_source_make_all:
+compiler_moc_source_clean:
+compiler_uic_make_all:
+compiler_uic_clean:
+compiler_yacc_decl_make_all:
+compiler_yacc_decl_clean:
+compiler_yacc_impl_make_all:
+compiler_yacc_impl_clean:
+compiler_lex_make_all:
+compiler_lex_clean:
+compiler_clean: compiler_moc_header_clean
+
+
+
+####### Compile
+
+objs/opmaps.o: opmaps.cpp opmaps.h \
+ debugheader.h \
+ memorycache.h \
+ rawtile.h \
+ maptype.h \
+ point.h \
+ kibertilecache.h \
+ cache.h \
+ pureimagecache.h \
+ pureimage.h \
+ accessmode.h \
+ languagetype.h \
+ cacheitemqueue.h \
+ tilecachequeue.h \
+ alllayersoftype.h \
+ urlfactory.h \
+ providerstrings.h \
+ ../internals/pointlatlng.h \
+ ../internals/sizelatlng.h \
+ geodecoderstatus.h \
+ placemark.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\opmaps.o opmaps.cpp
+
+objs/pureimagecache.o: pureimagecache.cpp pureimagecache.h \
+ maptype.h \
+ point.h \
+ pureimage.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\pureimagecache.o pureimagecache.cpp
+
+objs/pureimage.o: pureimage.cpp pureimage.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\pureimage.o pureimage.cpp
+
+objs/rawtile.o: rawtile.cpp rawtile.h \
+ maptype.h \
+ point.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\rawtile.o rawtile.cpp
+
+objs/memorycache.o: memorycache.cpp memorycache.h \
+ rawtile.h \
+ maptype.h \
+ point.h \
+ kibertilecache.h \
+ debugheader.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\memorycache.o memorycache.cpp
+
+objs/cache.o: cache.cpp cache.h \
+ pureimagecache.h \
+ maptype.h \
+ point.h \
+ pureimage.h \
+ debugheader.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\cache.o cache.cpp
+
+objs/languagetype.o: languagetype.cpp languagetype.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\languagetype.o languagetype.cpp
+
+objs/providerstrings.o: providerstrings.cpp providerstrings.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\providerstrings.o providerstrings.cpp
+
+objs/cacheitemqueue.o: cacheitemqueue.cpp cacheitemqueue.h \
+ maptype.h \
+ point.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\cacheitemqueue.o cacheitemqueue.cpp
+
+objs/tilecachequeue.o: tilecachequeue.cpp tilecachequeue.h \
+ cacheitemqueue.h \
+ maptype.h \
+ point.h \
+ pureimagecache.h \
+ pureimage.h \
+ cache.h \
+ debugheader.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\tilecachequeue.o tilecachequeue.cpp
+
+objs/alllayersoftype.o: alllayersoftype.cpp alllayersoftype.h \
+ maptype.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\alllayersoftype.o alllayersoftype.cpp
+
+objs/urlfactory.o: urlfactory.cpp urlfactory.h \
+ providerstrings.h \
+ pureimagecache.h \
+ maptype.h \
+ point.h \
+ pureimage.h \
+ ../internals/pointlatlng.h \
+ ../internals/sizelatlng.h \
+ geodecoderstatus.h \
+ cache.h \
+ debugheader.h \
+ placemark.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\urlfactory.o urlfactory.cpp
+
+objs/placemark.o: placemark.cpp placemark.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\placemark.o placemark.cpp
+
+objs/point.o: point.cpp point.h \
+ size.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\point.o point.cpp
+
+objs/size.o: size.cpp size.h \
+ point.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\size.o size.cpp
+
+objs/kibertilecache.o: kibertilecache.cpp kibertilecache.h \
+ rawtile.h \
+ maptype.h \
+ point.h \
+ debugheader.h
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\kibertilecache.o kibertilecache.cpp
+
+objs/moc_maptype.o: mocs/moc_maptype.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\moc_maptype.o mocs\moc_maptype.cpp
+
+objs/moc_tilecachequeue.o: mocs/moc_tilecachequeue.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\moc_tilecachequeue.o mocs\moc_tilecachequeue.cpp
+
+objs/moc_urlfactory.o: mocs/moc_urlfactory.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\moc_urlfactory.o mocs\moc_urlfactory.cpp
+
+objs/moc_geodecoderstatus.o: mocs/moc_geodecoderstatus.cpp
+ $(CXX) -c $(CXXFLAGS) $(INCPATH) -o objs\moc_geodecoderstatus.o mocs\moc_geodecoderstatus.cpp
+
+####### Install
+
+install: FORCE
+
+uninstall: FORCE
+
+FORCE:
+
diff --git a/ground/src/libs/opmapcontrol/src/core/accessmode.h b/ground/src/libs/opmapcontrol/src/core/accessmode.h
new file mode 100644
index 000000000..daa0bcb29
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/accessmode.h
@@ -0,0 +1,58 @@
+/**
+******************************************************************************
+*
+* @file accessmode.h
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#ifndef ACCESSMODE_H
+#define ACCESSMODE_H
+
+#include "debugheader.h"
+
+namespace core {
+ struct AccessMode
+ {
+
+ public:
+ enum Types
+ {
+ ///
+ /// access only server
+ ///
+ ServerOnly,
+
+ ///
+ /// access first server and caches localy
+ ///
+ ServerAndCache,
+
+ ///
+ /// access only cache
+ ///
+ CacheOnly,
+ };
+
+ };
+}
+#endif // ACCESSMODE_H
diff --git a/ground/src/libs/opmapcontrol/src/core/alllayersoftype.cpp b/ground/src/libs/opmapcontrol/src/core/alllayersoftype.cpp
new file mode 100644
index 000000000..6ecb6076e
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/alllayersoftype.cpp
@@ -0,0 +1,88 @@
+/**
+******************************************************************************
+*
+* @file alllayersoftype.cpp
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#include "alllayersoftype.h"
+
+namespace core {
+ AllLayersOfType::AllLayersOfType()
+ {
+
+ }
+ QVector AllLayersOfType::GetAllLayersOfType(const MapType::Types &type)
+ {
+ QVector types;
+ {
+ switch(type)
+ {
+ case MapType::GoogleHybrid:
+ {
+
+ types.append(MapType::GoogleSatellite);
+ types.append(MapType::GoogleLabels);
+ }
+ break;
+
+ case MapType::GoogleHybridChina:
+ {
+ types.append(MapType::GoogleSatelliteChina);
+ types.append(MapType::GoogleLabelsChina);
+ }
+ break;
+
+ case MapType::GoogleHybridKorea:
+ {
+ types.append(MapType::GoogleSatelliteKorea);
+ types.append(MapType::GoogleLabelsKorea);
+ }
+ break;
+
+ case MapType::YahooHybrid:
+ {
+ types.append(MapType::YahooSatellite);
+ types.append(MapType::YahooLabels);
+ }
+ break;
+
+ case MapType::ArcGIS_MapsLT_Map_Hybrid:
+ {
+ types.append(MapType::ArcGIS_MapsLT_OrtoFoto);
+ types.append(MapType::ArcGIS_MapsLT_Map_Labels);
+ }
+ break;
+
+ default:
+ {
+ types.append(type);
+ }
+ break;
+ }
+ }
+
+ return types;
+
+ }
+}
diff --git a/ground/src/libs/opmapcontrol/src/core/alllayersoftype.h b/ground/src/libs/opmapcontrol/src/core/alllayersoftype.h
new file mode 100644
index 000000000..d8ef15d7c
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/alllayersoftype.h
@@ -0,0 +1,44 @@
+/**
+******************************************************************************
+*
+* @file alllayersoftype.h
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#ifndef ALLLAYERSOFTYPE_H
+#define ALLLAYERSOFTYPE_H
+
+#include "maptype.h"
+#include
+#include
+
+namespace core {
+ class AllLayersOfType
+ {
+ public:
+ AllLayersOfType();
+ QVector GetAllLayersOfType(const MapType::Types &type);
+ };
+
+}
+#endif // ALLLAYERSOFTYPE_H
diff --git a/ground/src/libs/opmapcontrol/src/core/cache.cpp b/ground/src/libs/opmapcontrol/src/core/cache.cpp
new file mode 100644
index 000000000..a4748fb84
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/cache.cpp
@@ -0,0 +1,197 @@
+/**
+******************************************************************************
+*
+* @file cache.cpp
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#include "cache.h"
+
+
+namespace core {
+ Cache* Cache::m_pInstance=0;
+
+ Cache* Cache::Instance()
+ {
+ if(!m_pInstance)
+ m_pInstance=new Cache;
+ return m_pInstance;
+ }
+
+ void Cache::setCacheLocation(const QString& value)
+ {
+ cache=value;
+ routeCache = cache + "RouteCache" + QDir::separator();
+ geoCache = cache + "GeocoderCache"+ QDir::separator();
+ placemarkCache = cache + "PlacemarkCache" + QDir::separator();
+ ImageCache.setGtileCache(value);
+ }
+ QString Cache::CacheLocation()
+ {
+ return cache;
+ }
+ Cache::Cache()
+ {
+ if(cache.isNull()|cache.isEmpty())
+ {
+ cache=QDir::currentPath()+QDir::separator()+"mapscache"+QDir::separator();
+ setCacheLocation(cache);
+ }
+ }
+ QString Cache::GetGeocoderFromCache(const QString &urlEnd)
+ {
+#ifdef DEBUG_GetGeocoderFromCache
+ qDebug()<<"Entered GetGeocoderFromCache";
+#endif
+ QString ret=QString::null;
+ QString filename=geoCache+QString(urlEnd)+".geo";
+#ifdef DEBUG_GetGeocoderFromCache
+ qDebug()<<"GetGeocoderFromCache: Does file exist?:"<>ret;
+ }
+ }
+#ifdef DEBUG_GetGeocoderFromCache
+ qDebug()<<"GetGeocoderFromCache:Returning:"<>ret;
+ }
+ }
+#ifdef DEBUG_CACHE
+ qDebug()<<"GetPlacemarkFromCache:Returning:"<
+
+
+
+namespace core {
+ class CacheItemQueue
+ {
+ public:
+ CacheItemQueue(const MapType::Types &Type,const Point &Pos,const QByteArray &Img,const int &Zoom);
+ CacheItemQueue(){};
+ CacheItemQueue(const CacheItemQueue &cSource)
+ {
+ img=cSource.img;
+ pos=cSource.pos;
+ type=cSource.type;
+ zoom=cSource.zoom;
+ }
+ CacheItemQueue& operator= (const CacheItemQueue &cSource);
+ bool operator== (const CacheItemQueue &cSource);
+ void SetMapType(const MapType::Types &value);
+ void SetPosition(const Point &value);
+ void SetImg(const QByteArray &value);
+ MapType::Types GetMapType();
+ Point GetPosition();
+ QByteArray GetImg();
+ int GetZoom(){return zoom;};
+ void SetZoom(const int &value) {zoom=value;};
+ private:
+
+
+ MapType::Types type;
+ Point pos;
+ QByteArray img;
+ int zoom;
+ };
+
+}
+#endif // CACHEITEMQUEUE_H
diff --git a/ground/src/libs/opmapcontrol/src/core/core.pro b/ground/src/libs/opmapcontrol/src/core/core.pro
new file mode 100644
index 000000000..3e1b19635
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/core.pro
@@ -0,0 +1,38 @@
+include (../common.pri)
+
+SOURCES += opmaps.cpp \
+ pureimagecache.cpp \
+ pureimage.cpp \
+ rawtile.cpp \
+ memorycache.cpp \
+ cache.cpp \
+ languagetype.cpp \
+ providerstrings.cpp \
+ cacheitemqueue.cpp \
+ tilecachequeue.cpp \
+ alllayersoftype.cpp \
+ urlfactory.cpp \
+ placemark.cpp \
+ point.cpp \
+ size.cpp \
+ kibertilecache.cpp
+HEADERS += opmaps.h \
+ size.h \
+ maptype.h \
+ pureimagecache.h \
+ pureimage.h \
+ rawtile.h \
+ memorycache.h \
+ cache.h \
+ accessmode.h \
+ languagetype.h \
+ providerstrings.h \
+ cacheitemqueue.h \
+ tilecachequeue.h \
+ alllayersoftype.h \
+ urlfactory.h \
+ geodecoderstatus.h \
+ placemark.h \
+ point.h \
+ kibertilecache.h \
+ debugheader.h
diff --git a/ground/src/libs/opmapcontrol/src/core/debugheader.h b/ground/src/libs/opmapcontrol/src/core/debugheader.h
new file mode 100644
index 000000000..0e1f73195
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/debugheader.h
@@ -0,0 +1,13 @@
+#ifndef DEBUGHEADER_H
+#define DEBUGHEADER_H
+
+//#define DEBUG_MEMORY_CACHE
+//#define DEBUG_CACHE
+//#define DEBUG_GMAPS
+//#define DEBUG_PUREIMAGECACHE
+//#define DEBUG_TILECACHEQUEUE
+//#define DEBUG_URLFACTORY
+//#define DEBUG_MEMORY_CACHE
+//#define DEBUG_GetGeocoderFromCache
+
+#endif // DEBUGHEADER_H
diff --git a/ground/src/libs/opmapcontrol/src/core/geodecoderstatus.h b/ground/src/libs/opmapcontrol/src/core/geodecoderstatus.h
new file mode 100644
index 000000000..713aa35f7
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/geodecoderstatus.h
@@ -0,0 +1,120 @@
+/**
+******************************************************************************
+*
+* @file geodecoderstatus.h
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#ifndef GEODECODERSTATUS_H
+#define GEODECODERSTATUS_H
+
+#include
+#include
+#include
+namespace core {
+ class GeoCoderStatusCode:public QObject
+ {
+ Q_OBJECT
+ Q_ENUMS(Types)
+ public:
+ enum Types
+ {
+ ///
+ /// unknow response
+ ///
+ Unknow = -1,
+
+ ///
+ /// No errors occurred; the address was successfully parsed and its geocode has been returned.
+ ///
+ G_GEO_SUCCESS=200,
+
+ ///
+ /// A directions request could not be successfully parsed.
+ /// For example, the request may have been rejected if it contained more than the maximum number of waypoints allowed.
+ ///
+ G_GEO_BAD_REQUEST=400,
+
+ ///
+ /// A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.
+ ///
+ G_GEO_SERVER_ERROR=500,
+
+ ///
+ /// The HTTP q parameter was either missing or had no value.
+ /// For geocoding requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.
+ ///
+ G_GEO_MISSING_QUERY=601,
+
+ ///
+ /// Synonym for G_GEO_MISSING_QUERY.
+ ///
+ G_GEO_MISSING_ADDRESS=601,
+
+ ///
+ /// No corresponding geographic location could be found for the specified address.
+ /// This may be due to the fact that the address is relatively new, or it may be incorrect.
+ ///
+ G_GEO_UNKNOWN_ADDRESS=602,
+
+ ///
+ /// The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.
+ ///
+ G_GEO_UNAVAILABLE_ADDRESS=603,
+
+ ///
+ /// The GDirections object could not compute directions between the points mentioned in the query.
+ /// This is usually because there is no route available between the two points, or because we do not have data for routing in that region.
+ ///
+ G_GEO_UNKNOWN_DIRECTIONS=604,
+
+ ///
+ /// The given key is either invalid or does not match the domain for which it was given.
+ ///
+ G_GEO_BAD_KEY=610,
+
+ ///
+ /// The given key has gone over the requests limit in the 24 hour period or has submitted too many requests in too short a period of time.
+ /// If you're sending multiple requests in parallel or in a tight loop, use a timer or pause in your code to make sure you don't send the requests too quickly.
+ ///
+ G_GEO_TOO_MANY_QUERIES=620,
+
+ };
+ static QString StrByType(Types const& value)
+ {
+ QMetaObject metaObject = GeoCoderStatusCode().staticMetaObject;
+ QMetaEnum metaEnum= metaObject.enumerator( metaObject.indexOfEnumerator("Types"));
+ QString s=metaEnum.valueToKey(value);
+ return s;
+ }
+ static Types TypeByStr(QString const& value)
+ {
+ QMetaObject metaObject = GeoCoderStatusCode().staticMetaObject;
+ QMetaEnum metaEnum= metaObject.enumerator( metaObject.indexOfEnumerator("Types"));
+ Types s=(Types)metaEnum.keyToValue(value.toLatin1());
+ return s;
+ }
+
+ };
+}
+#endif // GEODECODERSTATUS_H
diff --git a/ground/src/libs/opmapcontrol/src/core/kibertilecache.cpp b/ground/src/libs/opmapcontrol/src/core/kibertilecache.cpp
new file mode 100644
index 000000000..ded151d23
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/kibertilecache.cpp
@@ -0,0 +1,70 @@
+/**
+******************************************************************************
+*
+* @file kibertilecache.cpp
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#include "kibertilecache.h"
+
+//TODO add readwrite lock
+
+namespace core {
+ KiberTileCache::KiberTileCache()
+ {
+ memoryCacheSize = 0;
+ _MemoryCacheCapacity = 22;
+ }
+
+ void KiberTileCache::setMemoryCacheCapacity(const int &value)
+ {
+ kiberCacheLock.lockForWrite();
+ _MemoryCacheCapacity=value;
+ kiberCacheLock.unlock();
+ }
+ int KiberTileCache::MemoryCacheCapacity()
+ {
+ kiberCacheLock.lockForRead();
+ return _MemoryCacheCapacity;
+ kiberCacheLock.unlock();
+ }
+
+ void KiberTileCache::RemoveMemoryOverload()
+ {
+ while(MemoryCacheSize()>MemoryCacheCapacity())
+ {
+ if(cachequeue.count()>0 && list.count()>0)
+ {
+#ifdef DEBUG_MEMORY_CACHE
+ qDebug()<<"Cleaning Memory cache="<<" started with "<
+#include
+#include
+#include
+#include "debugheader.h"
+namespace core {
+ class KiberTileCache
+ {
+ public:
+ KiberTileCache();
+
+ void setMemoryCacheCapacity(const int &value);
+ int MemoryCacheCapacity();
+ double MemoryCacheSize(){return memoryCacheSize/1048576.0;}
+ void RemoveMemoryOverload();
+ QReadWriteLock kiberCacheLock;
+ QHash cachequeue;
+ QQueue list;
+ long memoryCacheSize;
+ private:
+ int _MemoryCacheCapacity;
+
+ };
+
+
+
+}
+#endif // KIBERTILECACHE_H
diff --git a/ground/src/libs/opmapcontrol/src/core/languagetype.cpp b/ground/src/libs/opmapcontrol/src/core/languagetype.cpp
new file mode 100644
index 000000000..14e43969f
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/languagetype.cpp
@@ -0,0 +1,101 @@
+/**
+******************************************************************************
+*
+* @file languagetype.cpp
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#include "languagetype.h"
+
+
+
+namespace core {
+ LanguageType::LanguageType()
+ {
+ list
+ <<"ar"
+ <<"bg"
+ <<"bn"
+ <<"ca"
+ <<"cs"
+ <<"da"
+ <<"de"
+ <<"el"
+ <<"en"
+ <<"en-AU"
+ <<"en-GB"
+ <<"es"
+ <<"eu"
+ <<"fi"
+ <<"fil"
+ <<"fr"
+ <<"gl"
+ <<"gu"
+ <<"hi"
+ <<"hr"
+ <<"hu"
+ <<"id"
+ <<"it"
+ <<"iw"
+ <<"ja"
+ <<"kn"
+ <<"ko"
+ <<"lt"
+ <<"lv"
+ <<"ml"
+ <<"mr"
+ <<"nl"
+ <<"nn"
+ <<"no"
+ <<"or"
+ <<"pl"
+ <<"pt"
+ <<"pt-BR"
+ <<"pt-PT"
+ <<"rm"
+ <<"ro"
+ <<"ru"
+ <<"sk"
+ <<"sl"
+ <<"sr"
+ <<"sv"
+ <<"ta"
+ <<"te"
+ <<"th"
+ <<"tr"
+ <<"uk"
+ <<"vi"
+ <<"zh-CN"
+ <<"zh-TW";
+
+ }
+ QString LanguageType::toString(Types type)
+ {
+ return list[type];
+ }
+ LanguageType::~LanguageType()
+ {
+ list.clear();
+ }
+
+}
diff --git a/ground/src/libs/opmapcontrol/src/core/languagetype.h b/ground/src/libs/opmapcontrol/src/core/languagetype.h
new file mode 100644
index 000000000..743181e5f
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/languagetype.h
@@ -0,0 +1,108 @@
+/**
+******************************************************************************
+*
+* @file languagetype.h
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#ifndef LANGUAGETYPE_H
+#define LANGUAGETYPE_H
+
+#include
+#include
+
+
+
+namespace core {
+ class LanguageType
+ {
+ public:
+
+ enum Types
+ {
+ Arabic,
+ Bulgarian,
+ Bengali,
+ Catalan,
+ Czech,
+ Danish,
+ German,
+ Greek,
+ English,
+ EnglishAustralian,
+ EnglishGreatBritain,
+ Spanish,
+ Basque,
+ Finnish,
+ Filipino,
+ French,
+ Galician,
+ Gujarati,
+ Hindi,
+ Croatian,
+ Hungarian,
+ Indonesian,
+ Italian,
+ Hebrew,
+ Japanese,
+ Kannada,
+ Korean,
+ Lithuanian,
+ Latvian,
+ Malayalam,
+ Marathi,
+ Dutch,
+ NorwegianNynorsk,
+ Norwegian,
+ Oriya,
+ Polish,
+ Portuguese,
+ PortugueseBrazil,
+ PortuguesePortugal,
+ Romansch,
+ Romanian,
+ Russian,
+ Slovak,
+ Slovenian,
+ Serbian,
+ Swedish,
+ Tamil,
+ Telugu,
+ Thai,
+ Turkish,
+ Ukrainian,
+ Vietnamese,
+ ChineseSimplified,
+ ChineseTraditional,
+ };
+
+
+ QString toString(Types type);
+ LanguageType();
+ ~LanguageType();
+ private:
+ QStringList list;
+ };
+
+}
+#endif // LANGUAGETYPE_H
diff --git a/ground/src/libs/opmapcontrol/src/core/maptype.h b/ground/src/libs/opmapcontrol/src/core/maptype.h
new file mode 100644
index 000000000..27589e7e6
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/maptype.h
@@ -0,0 +1,130 @@
+/**
+******************************************************************************
+*
+* @file maptype.h
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#ifndef MAPTYPE_H
+#define MAPTYPE_H
+#include
+#include
+#include
+
+namespace core {
+ class MapType:public QObject
+ {
+ Q_OBJECT
+ Q_ENUMS(Types)
+ public:
+ enum Types
+ {
+ GoogleMap=1,
+ GoogleSatellite=4,
+ GoogleLabels=8,
+ GoogleTerrain=16,
+ GoogleHybrid=20,
+
+ GoogleMapChina=22,
+ GoogleSatelliteChina=24,
+ GoogleLabelsChina=26,
+ GoogleTerrainChina=28,
+ GoogleHybridChina=29,
+
+ OpenStreetMap=32,
+ OpenStreetOsm=33,
+ OpenStreetMapSurfer=34,
+ OpenStreetMapSurferTerrain=35,
+
+ YahooMap=64,
+ YahooSatellite=128,
+ YahooLabels=256,
+ YahooHybrid=333,
+
+ BingMap=444,
+ BingSatellite=555,
+ BingHybrid=666,
+
+ ArcGIS_Map=777,
+ ArcGIS_Satellite=788,
+ ArcGIS_ShadedRelief=799,
+ ArcGIS_Terrain=811,
+
+ // use these numbers to clean up old stuff
+ //ArcGIS_MapsLT_Map_Old= 877,
+ //ArcGIS_MapsLT_OrtoFoto_Old = 888,
+ //ArcGIS_MapsLT_Map_Labels_Old = 890,
+ //ArcGIS_MapsLT_Map_Hybrid_Old = 899,
+ //ArcGIS_MapsLT_Map=977,
+ //ArcGIS_MapsLT_OrtoFoto=988,
+ //ArcGIS_MapsLT_Map_Labels=990,
+ //ArcGIS_MapsLT_Map_Hybrid=999,
+ //ArcGIS_MapsLT_Map=978,
+ //ArcGIS_MapsLT_OrtoFoto=989,
+ //ArcGIS_MapsLT_Map_Labels=991,
+ //ArcGIS_MapsLT_Map_Hybrid=998,
+
+ ArcGIS_MapsLT_Map=1000,
+ ArcGIS_MapsLT_OrtoFoto=1001,
+ ArcGIS_MapsLT_Map_Labels=1002,
+ ArcGIS_MapsLT_Map_Hybrid=1003,
+
+ PergoTurkeyMap = 2001,
+ SigPacSpainMap = 3001,
+
+ GoogleMapKorea=4001,
+ GoogleSatelliteKorea=4002,
+ GoogleLabelsKorea=4003,
+ GoogleHybridKorea=4005,
+
+ YandexMapRu = 5000,
+ };
+ static QString StrByType(Types const& value)
+ {
+ QMetaObject metaObject = MapType().staticMetaObject;
+ QMetaEnum metaEnum= metaObject.enumerator( metaObject.indexOfEnumerator("Types"));
+ QString s=metaEnum.valueToKey(value);
+ return s;
+ }
+ static Types TypeByStr(QString const& value)
+ {
+ QMetaObject metaObject = MapType().staticMetaObject;
+ QMetaEnum metaEnum= metaObject.enumerator( metaObject.indexOfEnumerator("Types"));
+ Types s=(Types)metaEnum.keyToValue(value.toLatin1());
+ return s;
+ }
+ static QStringList TypesList()
+ {
+ QStringList ret;
+ QMetaObject metaObject = MapType().staticMetaObject;
+ QMetaEnum metaEnum= metaObject.enumerator( metaObject.indexOfEnumerator("Types"));
+ for(int x=0;x
+#include
+#include
+#include "kibertilecache.h"
+#include
+#include "debugheader.h"
+namespace core {
+ class MemoryCache
+ {
+ public:
+ MemoryCache();
+
+ KiberTileCache TilesInMemory;
+ QByteArray GetTileFromMemoryCache(const RawTile &tile);
+ void AddTileToMemoryCache(const RawTile &tile, const QByteArray &pic);
+ QReadWriteLock kiberCacheLock;
+ };
+
+
+}
+#endif // MEMORYCACHE_H
diff --git a/ground/src/libs/opmapcontrol/src/core/opmaps.cpp b/ground/src/libs/opmapcontrol/src/core/opmaps.cpp
new file mode 100644
index 000000000..1c9758857
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/opmaps.cpp
@@ -0,0 +1,259 @@
+/**
+******************************************************************************
+*
+* @file OPMaps.cpp
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#include "opmaps.h"
+
+
+namespace core {
+ OPMaps* OPMaps::m_pInstance=0;
+
+ OPMaps* OPMaps::Instance()
+ {
+ if(!m_pInstance)
+ m_pInstance=new OPMaps;
+ return m_pInstance;
+ }
+ OPMaps::OPMaps():useMemoryCache(true),MaxZoom(19),RetryLoadTile(2)
+ {
+ accessmode=AccessMode::ServerAndCache;
+ Language=LanguageType::PortuguesePortugal;
+ LanguageStr=LanguageType().toString(Language);
+ // Cache::Instance()->ImageCache=PureImageCache();
+
+ }
+
+
+ OPMaps::~OPMaps()
+ {
+ //delete Proxy;
+ }
+
+
+
+ QByteArray OPMaps::GetImageFrom(const MapType::Types &type,const Point &pos,const int &zoom)
+ {
+#ifdef DEBUG_TIMINGS
+ QTime time;
+ time.restart();
+#endif
+#ifdef DEBUG_GMAPS
+ qDebug()<<"Entered GetImageFrom";
+#endif //DEBUG_GMAPS
+ QByteArray ret;
+
+ if(useMemoryCache)
+ {
+#ifdef DEBUG_GMAPS
+ qDebug()<<"Try Tile from memory:Size="<ImageCache.GetImageFromCache(type,pos,zoom);
+ if(!ret.isEmpty())
+ {
+#ifdef DEBUG_GMAPS
+ qDebug()<<"Tile found in Database";
+#endif //DEBUG_GMAPS
+ if(useMemoryCache)
+ {
+#ifdef DEBUG_GMAPS
+ qDebug()<<"Add Tile to memory";
+#endif //DEBUG_GMAPS
+ AddTileToMemoryCache(RawTile(type,pos,zoom),ret);
+ }
+ return ret;
+ }
+ }
+ if(accessmode!=AccessMode::CacheOnly)
+ {
+ QNetworkReply *reply;
+ QNetworkRequest qheader;
+ QNetworkAccessManager network;
+ network.setProxy(Proxy);
+#ifdef DEBUG_GMAPS
+ qDebug()<<"Try Tile from the Internet";
+#endif //DEBUG_GMAPS
+#ifdef DEBUG_TIMINGS
+ qDebug()<<"opmaps before make image url"<isFinished() | time.elapsed()>(6*Timeout)) ){QCoreApplication::processEvents(QEventLoop::AllEvents);}
+#ifdef DEBUG_TIMINGS
+ qDebug()<<"Network time:"<error()<<" abort?"<<(time.elapsed()>Timeout*6);
+#endif //DEBUG_GMAPS
+ if( (reply->error()!=QNetworkReply::NoError) | (time.elapsed()>Timeout*6))
+ {
+#ifdef DEBUG_GMAPS
+ qDebug()<<"Request timed out ";//<readAll();
+ reply->deleteLater();//TODO can't this be global??
+ if(ret.isEmpty())
+ {
+#ifdef DEBUG_GMAPS
+ qDebug()<<"Invalid Tile";
+#endif //DEBUG_GMAPS
+ return ret;
+ }
+#ifdef DEBUG_GMAPS
+ qDebug()<<"Received Tile from the Internet";
+#endif //DEBUG_GMAPS
+ if (useMemoryCache)
+ {
+#ifdef DEBUG_GMAPS
+ qDebug()<<"Add Tile to memory cache";
+#endif //DEBUG_GMAPS
+ AddTileToMemoryCache(RawTile(type,pos,zoom),ret);
+ }
+ if(accessmode!=AccessMode::ServerOnly)
+ {
+#ifdef DEBUG_GMAPS
+ qDebug()<<"Add tile to DataBase";
+#endif //DEBUG_GMAPS
+ CacheItemQueue item(type,pos,ret,zoom);
+ TileDBcacheQueue.EnqueueCacheTask(item);
+ }
+
+
+ }
+ }
+#ifdef DEBUG_GMAPS
+ qDebug()<<"Entered GetImageFrom";
+#endif //DEBUG_GMAPS
+ return ret;
+ }
+
+ bool OPMaps::ExportToGMDB(const QString &file)
+ {
+ return Cache::Instance()->ImageCache.ExportMapDataToDB(Cache::Instance()->ImageCache.GtileCache()+QDir::separator()+"Data.qmdb",file);
+ }
+ bool OPMaps::ImportFromGMDB(const QString &file)
+ {
+ return Cache::Instance()->ImageCache.ExportMapDataToDB(file,Cache::Instance()->ImageCache.GtileCache()+QDir::separator()+"Data.qmdb");
+ }
+}
diff --git a/ground/src/libs/opmapcontrol/src/core/opmaps.h b/ground/src/libs/opmapcontrol/src/core/opmaps.h
new file mode 100644
index 000000000..e1723eaa6
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/opmaps.h
@@ -0,0 +1,93 @@
+/**
+******************************************************************************
+*
+* @file OPMaps.h
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#ifndef OPMaps_H
+#define OPMaps_H
+
+
+#include "debugheader.h"
+#include "memorycache.h"
+#include "rawtile.h"
+#include "cache.h"
+#include "accessmode.h"
+#include "languagetype.h"
+#include "cacheitemqueue.h"
+#include "tilecachequeue.h"
+#include "pureimagecache.h"
+#include "alllayersoftype.h"
+#include "urlfactory.h"
+//#include "point.h"
+
+
+namespace core {
+ class OPMaps: public MemoryCache,public AllLayersOfType,public UrlFactory
+ {
+
+
+ public:
+
+ ~OPMaps();
+
+ static OPMaps* Instance();
+ bool ImportFromGMDB(const QString &file);
+ bool ExportToGMDB(const QString &file);
+ ///
+ /// timeout for map connections
+ ///
+
+
+ QByteArray GetImageFrom(const MapType::Types &type,const Point &pos,const int &zoom);
+ bool UseMemoryCache();//TODO
+ void setUseMemoryCache(const bool& value){useMemoryCache=value;}
+ void setLanguage(const LanguageType::Types& language);//TODO
+ LanguageType::Types GetLanguage();//TODO
+ AccessMode::Types GetAccessMode()const{return accessmode;};
+ void setAccessMode(const AccessMode::Types& mode){accessmode=mode;};
+ int MaxZoom;
+ int RetryLoadTile;
+ private:
+ bool useMemoryCache;
+ LanguageType::Types Language;
+ AccessMode::Types accessmode;
+ // PureImageCache ImageCacheLocal;//TODO Criar acesso Get Set
+ TileCacheQueue TileDBcacheQueue;
+ OPMaps();
+
+ OPMaps(OPMaps const&){};
+ OPMaps& operator=(OPMaps const&){};
+ static OPMaps* m_pInstance;
+
+
+ protected:
+ // MemoryCache TilesInMemory;
+
+
+
+ };
+
+}
+#endif // OPMaps_H
diff --git a/ground/src/libs/opmapcontrol/src/core/placemark.cpp b/ground/src/libs/opmapcontrol/src/core/placemark.cpp
new file mode 100644
index 000000000..5954c7d61
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/placemark.cpp
@@ -0,0 +1,29 @@
+/**
+******************************************************************************
+*
+* @file placemark.cpp
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#include "placemark.h"
+
diff --git a/ground/src/libs/opmapcontrol/src/core/placemark.h b/ground/src/libs/opmapcontrol/src/core/placemark.h
new file mode 100644
index 000000000..b8fd3e4e2
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/placemark.h
@@ -0,0 +1,55 @@
+/**
+******************************************************************************
+*
+* @file placemark.h
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#ifndef PLACEMARK_H
+#define PLACEMARK_H
+
+#include
+
+
+namespace core {
+ class Placemark
+ {
+ public:
+ Placemark(const QString &address)
+ {
+ this->address = address;
+ }
+ QString Address(){return address;}
+ int Accuracy(){return accuracy;}
+ void SetAddress(const QString &adr){address=adr;}
+ void SetAccuracy(const int &value){accuracy=value;}
+ private:
+
+ QString address;
+ int accuracy;
+ protected:
+
+
+ };
+}
+#endif // PLACEMARK_H
diff --git a/ground/src/libs/opmapcontrol/src/core/point.cpp b/ground/src/libs/opmapcontrol/src/core/point.cpp
new file mode 100644
index 000000000..a59185734
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/point.cpp
@@ -0,0 +1,75 @@
+/**
+******************************************************************************
+*
+* @file point.cpp
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#include "point.h"
+#include "size.h"
+
+namespace core {
+ Point::Point(int dw)
+ {
+ this->x=(short)Point::LOWORD(dw);
+ this->y=(short)Point::HIWORD(dw);
+ empty=false;
+ }
+ Point::Point(Size sz)
+ {
+ this->x=sz.Width();
+ this->y=sz.Height();
+ empty=false;
+ }
+ Point::Point(int x, int y)
+ {
+ this->x=x;
+ this->y=y;
+ empty=false;
+ }
+ Point::Point():x(0),y(0),empty(true)
+ {}
+ uint qHash(Point const& point)
+ {
+ return point.x^point.y;
+ }
+ bool operator==(Point const &lhs,Point const &rhs)
+ {
+ return (lhs.x==rhs.x && lhs.y==rhs.y);
+ }
+ bool operator!=(Point const &lhs,Point const &rhs)
+ {
+ return !(lhs==rhs);
+ }
+ int Point::HIWORD(int n)
+ {
+ return (n >> 16) & 0xffff;
+ }
+
+ int Point::LOWORD(int n)
+ {
+ return n & 0xffff;
+ }
+ Point Point::Empty=Point();
+
+}
diff --git a/ground/src/libs/opmapcontrol/src/core/point.h b/ground/src/libs/opmapcontrol/src/core/point.h
new file mode 100644
index 000000000..c9d3aeeb2
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/point.h
@@ -0,0 +1,73 @@
+/**
+******************************************************************************
+*
+* @file point.h
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#ifndef POINT_H
+#define POINT_H
+
+
+#include
+
+namespace core {
+ struct Size;
+ struct Point
+ {
+ friend uint qHash(Point const& point);
+ friend bool operator==(Point const& lhs,Point const& rhs);
+ friend bool operator!=(Point const& lhs,Point const& rhs);
+ public:
+
+ Point();
+ Point(int x,int y);
+ Point(Size sz);
+ Point(int dw);
+ bool IsEmpty(){return empty;}
+ int X()const{return this->x;}
+ int Y()const{return this->y;}
+ void SetX(const int &value){x=value;empty=false;}
+ void SetY(const int &value){y=value;empty=false;}
+ QString ToString()const{return "{"+QString::number(x)+","+QString::number(y)+"}";}
+
+ static Point Empty;
+ void Offset(const int &dx,const int &dy)
+ {
+ x += dx;
+ y += dy;
+ }
+ void Offset(Point p)
+ {
+ Offset(p.x, p.y);
+ }
+ static int HIWORD(int n);
+ static int LOWORD(int n);
+
+ private:
+ int x;
+ int y;
+ bool empty;
+ };
+}
+#endif // POINT_H
diff --git a/ground/src/libs/opmapcontrol/src/core/providerstrings.cpp b/ground/src/libs/opmapcontrol/src/core/providerstrings.cpp
new file mode 100644
index 000000000..f512bbf11
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/providerstrings.cpp
@@ -0,0 +1,83 @@
+/**
+******************************************************************************
+*
+* @file providerstrings.cpp
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#include "providerstrings.h"
+
+
+namespace core {
+ const QString ProviderStrings::levelsForSigPacSpainMap[] = {"0", "1", "2", "3", "4",
+ "MTNSIGPAC",
+ "MTN2000", "MTN2000", "MTN2000", "MTN2000", "MTN2000",
+ "MTN200", "MTN200", "MTN200",
+ "MTN25", "MTN25",
+ "ORTOFOTOS","ORTOFOTOS","ORTOFOTOS","ORTOFOTOS"};
+
+ ProviderStrings::ProviderStrings()
+ {
+ // Google version strings
+ VersionGoogleMap = "m@123";
+ VersionGoogleSatellite = "59";
+ VersionGoogleLabels = "h@123";
+ VersionGoogleTerrain = "t@108,r@123";
+ SecGoogleWord = "Galileo";
+
+ // Google (China) version strings
+ VersionGoogleMapChina = "m@123";
+ VersionGoogleSatelliteChina = "s@59";
+ VersionGoogleLabelsChina = "h@123";
+ VersionGoogleTerrainChina = "t@108,r@123";
+
+ // Google (Korea) version strings
+ VersionGoogleMapKorea = "kr1.12";
+ VersionGoogleSatelliteKorea = "59";
+ VersionGoogleLabelsKorea = "kr1t.12";
+
+ ///
+ /// Google Maps API generated using http://greatmaps.codeplex.com/
+ /// from http://code.google.com/intl/en-us/apis/maps/signup.html
+ ///
+ GoogleMapsAPIKey = "ABQIAAAAWaQgWiEBF3lW97ifKnAczhRAzBk5Igf8Z5n2W3hNnMT0j2TikxTLtVIGU7hCLLHMAuAMt-BO5UrEWA";
+
+ // Yahoo version strings
+ VersionYahooMap = "4.3";
+ VersionYahooSatellite = "1.9";
+ VersionYahooLabels = "4.3";
+
+ // BingMaps
+ VersionBingMaps = "452";
+
+ // YandexMap
+ VersionYandexMap = "2.10.2";
+
+ ///
+ /// Bing Maps Customer Identification, more info here
+ /// http://msdn.microsoft.com/en-us/library/bb924353.aspx
+ ///
+ BingMapsClientToken = "";
+
+ }
+}
diff --git a/ground/src/libs/opmapcontrol/src/core/providerstrings.h b/ground/src/libs/opmapcontrol/src/core/providerstrings.h
new file mode 100644
index 000000000..4b1a8105f
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/providerstrings.h
@@ -0,0 +1,86 @@
+/**
+******************************************************************************
+*
+* @file providerstrings.h
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#ifndef PROVIDERSTRINGS_H
+#define PROVIDERSTRINGS_H
+
+#include
+
+
+namespace core {
+ class ProviderStrings
+ {
+ public:
+ ProviderStrings();
+ static const QString levelsForSigPacSpainMap[];
+ QString GoogleMapsAPIKey;
+ // Google version strings
+ QString VersionGoogleMap;
+ QString VersionGoogleSatellite;
+ QString VersionGoogleLabels;
+ QString VersionGoogleTerrain;
+ QString SecGoogleWord;
+
+ // Google (China) version strings
+ QString VersionGoogleMapChina;
+ QString VersionGoogleSatelliteChina;
+ QString VersionGoogleLabelsChina;
+ QString VersionGoogleTerrainChina;
+
+ // Google (Korea) version strings
+ QString VersionGoogleMapKorea;
+ QString VersionGoogleSatelliteKorea;
+ QString VersionGoogleLabelsKorea;
+
+ ///
+ /// Google Maps API generated using http://greatmaps.codeplex.com/
+ /// from http://code.google.com/intl/en-us/apis/maps/signup.html
+ ///
+
+
+ // Yahoo version strings
+ QString VersionYahooMap;
+ QString VersionYahooSatellite;
+ QString VersionYahooLabels;
+
+ // BingMaps
+ QString VersionBingMaps;
+
+ // YandexMap
+ QString VersionYandexMap;
+
+
+
+ ///
+ /// Bing Maps Customer Identification, more info here
+ /// http://msdn.microsoft.com/en-us/library/bb924353.aspx
+ ///
+ QString BingMapsClientToken;
+ };
+
+}
+#endif // PROVIDERSTRINGS_H
diff --git a/ground/src/libs/opmapcontrol/src/core/pureimage.cpp b/ground/src/libs/opmapcontrol/src/core/pureimage.cpp
new file mode 100644
index 000000000..3b6531722
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/pureimage.cpp
@@ -0,0 +1,47 @@
+/**
+******************************************************************************
+*
+* @file pureimage.cpp
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#include "pureimage.h"
+
+
+
+namespace core {
+PureImageProxy::PureImageProxy()
+{
+
+}
+
+QPixmap PureImageProxy::FromStream(const QByteArray &array)
+{
+ return QPixmap::fromImage(QImage::fromData(array));
+}
+bool PureImageProxy::Save(const QByteArray &array, QPixmap &pic)
+{
+ pic=QPixmap::fromImage(QImage::fromData(array));
+ return true;
+}
+}
diff --git a/ground/src/libs/opmapcontrol/src/core/pureimage.h b/ground/src/libs/opmapcontrol/src/core/pureimage.h
new file mode 100644
index 000000000..2a87a6aac
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/pureimage.h
@@ -0,0 +1,45 @@
+/**
+******************************************************************************
+*
+* @file pureimage.h
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#ifndef PUREIMAGE_H
+#define PUREIMAGE_H
+
+#include
+#include
+
+
+namespace core {
+ class PureImageProxy
+ {
+ public:
+ PureImageProxy();
+ static QPixmap FromStream(const QByteArray &array);
+ static bool Save(const QByteArray &array,QPixmap &pic);
+ };
+
+}
+#endif // PUREIMAGE_H
diff --git a/ground/src/libs/opmapcontrol/src/core/pureimagecache.cpp b/ground/src/libs/opmapcontrol/src/core/pureimagecache.cpp
new file mode 100644
index 000000000..a6a47b9a3
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/pureimagecache.cpp
@@ -0,0 +1,309 @@
+/**
+******************************************************************************
+*
+* @file pureimagecache.cpp
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#include "pureimagecache.h"
+
+
+namespace core {
+qlonglong PureImageCache::ConnCounter=0;
+
+PureImageCache::PureImageCache()
+{
+ gtilecache=QDir::currentPath()+QDir::separator()+"mapscache"+QDir::separator();
+}
+
+void PureImageCache::setGtileCache(const QString &value)
+{
+ gtilecache=value;
+}
+
+QString PureImageCache::GtileCache()
+{
+ return gtilecache;
+}
+
+
+bool PureImageCache::CreateEmptyDB(const QString &file)
+{
+#ifdef DEBUG_PUREIMAGECACHE
+ qDebug()<<"Create database at:"< add;
+ if(!QFileInfo(destFile).exists())
+ {
+#ifdef DEBUG_PUREIMAGECACHE
+ qDebug()<<"Try to create EmptyDB";
+#endif //DEBUG_PUREIMAGECACHE
+ ret=CreateEmptyDB(destFile);
+ }
+ if(!ret) return false;
+ QSqlDatabase ca = QSqlDatabase::addDatabase("QSQLITE","ca");
+ ca.setDatabaseName(sourceFile);
+
+ if(ca.open())
+ {
+ QSqlDatabase cb = QSqlDatabase::addDatabase("QSQLITE","cb");
+ cb.setDatabaseName(destFile);
+ if(cb.open())
+ {
+ QSqlQuery queryb(cb);
+ queryb.exec(QString("ATTACH DATABASE \"%1\" AS Source").arg(sourceFile));
+ QSqlQuery querya(ca);
+ querya.exec("SELECT id, X, Y, Zoom, Type FROM Tiles");
+ while(querya.next())
+ {
+ long id=querya.value(0).toLongLong();
+ queryb.exec(QString("SELECT id FROM Tiles WHERE X=%1 AND Y=%2 AND Zoom=%3 AND Type=%4;").arg(querya.value(1).toLongLong()).arg(querya.value(2).toLongLong()).arg(querya.value(3).toLongLong()).arg(querya.value(4).toLongLong()));
+ if(!queryb.next())
+ {
+ add.append(id);
+ }
+
+ }
+ long f;
+ foreach(f,add)
+ {
+ queryb.exec(QString("INSERT INTO Tiles(X, Y, Zoom, Type) SELECT X, Y, Zoom, Type FROM Source.Tiles WHERE id=%1").arg(f));
+ queryb.exec(QString("INSERT INTO TilesData(id, Tile) Values((SELECT last_insert_rowid()), (SELECT Tile FROM Source.TilesData WHERE id=%1))").arg(f));
+ }
+ add.clear();
+ ca.close();
+ cb.close();
+
+ }
+ else return false;
+ }
+ else return false;
+
+ return true;
+
+}
+
+}
diff --git a/ground/src/libs/opmapcontrol/src/core/pureimagecache.h b/ground/src/libs/opmapcontrol/src/core/pureimagecache.h
new file mode 100644
index 000000000..12e94e180
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/pureimagecache.h
@@ -0,0 +1,65 @@
+/**
+******************************************************************************
+*
+* @file pureimagecache.h
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#ifndef PUREIMAGECACHE_H
+#define PUREIMAGECACHE_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "maptype.h"
+#include "point.h"
+#include
+#include "pureimage.h"
+#include
+#include
+
+namespace core {
+ class PureImageCache
+ {
+
+ public:
+ PureImageCache();
+ static bool CreateEmptyDB(const QString &file);
+ bool PutImageToCache(const QByteArray &tile,const MapType::Types &type,const Point &pos, const int &zoom);
+ QByteArray GetImageFromCache(MapType::Types type, Point pos, int zoom);
+ QString GtileCache();
+ void setGtileCache(const QString &value);
+ static bool ExportMapDataToDB(QString sourceFile, QString destFile);
+ private:
+ QString gtilecache;
+ QMutex Mcounter;
+ static qlonglong ConnCounter;
+ };
+
+}
+#endif // PUREIMAGECACHE_H
diff --git a/ground/src/libs/opmapcontrol/src/core/rawtile.cpp b/ground/src/libs/opmapcontrol/src/core/rawtile.cpp
new file mode 100644
index 000000000..468be92c9
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/rawtile.cpp
@@ -0,0 +1,77 @@
+/**
+******************************************************************************
+*
+* @file rawtile.cpp
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#include "rawtile.h"
+
+
+namespace core {
+RawTile::RawTile(const MapType::Types &Type, const Point &Pos, const int &Zoom)
+{
+ zoom=Zoom;
+ type=Type;
+ pos=Pos;
+}
+QString RawTile::ToString()
+{
+ return QString("%1 at zoom %2, pos:%3,%4").arg(type).arg(zoom).arg(pos.X()).arg(pos.Y());
+}
+Point RawTile::Pos()
+{
+ return pos;
+}
+MapType::Types RawTile::Type()
+{
+ return type;
+}
+int RawTile::Zoom()
+{
+ return zoom;
+}
+void RawTile::setType(const MapType::Types &value)
+{
+ type=value;
+}
+void RawTile::setPos(const Point &value)
+{
+ pos=value;
+}
+void RawTile::setZoom(const int &value)
+{
+ zoom=value;
+}
+uint qHash(RawTile const& tile)
+{
+ // RawTile tile=tilee;
+ quint64 tmp=(((quint64)(tile.zoom))<<54)+(((int)(tile.type))<<36)+(((quint64)(tile.pos.X()))<<18)+(((quint64)(tile.pos.Y())));
+ // quint64 tmp5=tmp+tmp2+tmp3+tmp4;
+ return ::qHash(tmp);
+}
+bool operator==(RawTile const &lhs,RawTile const &rhs)
+{
+ return (lhs.pos==rhs.pos && lhs.zoom==rhs.zoom && lhs.type==rhs.type);
+}
+}
diff --git a/ground/src/libs/opmapcontrol/src/core/rawtile.h b/ground/src/libs/opmapcontrol/src/core/rawtile.h
new file mode 100644
index 000000000..3b14007ad
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/rawtile.h
@@ -0,0 +1,57 @@
+/**
+******************************************************************************
+*
+* @file rawtile.h
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#ifndef RAWTILE_H
+#define RAWTILE_H
+
+#include "maptype.h"
+#include "point.h"
+#include
+#include
+
+namespace core {
+ class RawTile
+ {
+ friend uint qHash(RawTile const& tile);
+ friend bool operator==(RawTile const& lhs,RawTile const& rhs);
+
+ public:
+ RawTile(const MapType::Types &Type,const Point &Pos,const int &Zoom);
+ QString ToString(void);
+ MapType::Types Type();
+ Point Pos();
+ int Zoom();
+ void setType(const MapType::Types &value);
+ void setPos(const Point &value);
+ void setZoom(const int &value);
+ private:
+ MapType::Types type;
+ Point pos;
+ int zoom;
+ };
+}
+#endif // RAWTILE_H
diff --git a/ground/src/libs/opmapcontrol/src/core/size.cpp b/ground/src/libs/opmapcontrol/src/core/size.cpp
new file mode 100644
index 000000000..f4d10b5c0
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/size.cpp
@@ -0,0 +1,34 @@
+/**
+******************************************************************************
+*
+* @file size.cpp
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#include "size.h"
+
+
+namespace core {
+Size::Size():width(0),height(0)
+{}
+}
diff --git a/ground/src/libs/opmapcontrol/src/core/size.h b/ground/src/libs/opmapcontrol/src/core/size.h
new file mode 100644
index 000000000..241d09fea
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/size.h
@@ -0,0 +1,60 @@
+/**
+******************************************************************************
+*
+* @file size.h
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#ifndef SIZE_H
+#define SIZE_H
+
+#include "point.h"
+#include
+#include
+
+namespace core {
+ struct Size
+ {
+
+ Size();
+ Size(Point pt){width=pt.X(); height=pt.Y();};
+ Size(int Width,int Height){width=Width; height=Height;};
+ friend uint qHash(Size const& size);
+ // friend bool operator==(Size const& lhs,Size const& rhs);
+ Size operator-(const Size &sz1){return Size(width-sz1.width,height-sz1.height);}
+ Size operator+(const Size &sz1){return Size(sz1.width+width,sz1.height+height);}
+
+ int GetHashCode(){return width^height;}
+ uint qHash(Size const& rect){return width^height;}
+ QString ToString(){return "With="+QString::number(width)+" ,Height="+QString::number(height);}
+ int Width()const {return width;}
+ int Height()const {return height;}
+ void SetWidth(int const& value){width=value;}
+ void SetHeight(int const& value){height=value;}
+ private:
+ int width;
+ int height;
+ Point p;
+ };
+}
+#endif // SIZE_H
diff --git a/ground/src/libs/opmapcontrol/src/core/tilecachequeue.cpp b/ground/src/libs/opmapcontrol/src/core/tilecachequeue.cpp
new file mode 100644
index 000000000..4408c6e12
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/tilecachequeue.cpp
@@ -0,0 +1,112 @@
+/**
+******************************************************************************
+*
+* @file tilecachequeue.cpp
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#include "tilecachequeue.h"
+
+
+
+
+namespace core {
+TileCacheQueue::TileCacheQueue()
+{
+
+}
+
+void TileCacheQueue::EnqueueCacheTask(CacheItemQueue &task)
+{
+#ifdef DEBUG_TILECACHEQUEUE
+ qDebug()<<"DB Do I EnqueueCacheTask"<isRunning())
+ {
+#ifdef DEBUG_TILECACHEQUEUE
+ qDebug()<<"Wake Thread";
+#endif //DEBUG_TILECACHEQUEUE
+ wait.wakeOne();
+ }
+ else
+ {
+#ifdef DEBUG_TILECACHEQUEUE
+ qDebug()<<"Start Thread";
+#endif //DEBUG_TILECACHEQUEUE
+ this->start(QThread::LowestPriority);
+ }
+ }
+
+}
+void TileCacheQueue::run()
+{
+#ifdef DEBUG_TILECACHEQUEUE
+ qDebug()<<"Cache Engine Start";
+#endif //DEBUG_TILECACHEQUEUE
+ while(true)
+ {
+ CacheItemQueue task;
+#ifdef DEBUG_TILECACHEQUEUE
+ qDebug()<<"Cache";
+#endif //DEBUG_TILECACHEQUEUE
+ if(tileCacheQueue.count()>0)
+ {
+ mutex.lock();
+ task=tileCacheQueue.dequeue();
+ mutex.unlock();
+#ifdef DEBUG_TILECACHEQUEUE
+ qDebug()<<"Cache engine Put:"<ImageCache.PutImageToCache(task.GetImg(),task.GetMapType(),task.GetPosition(),task.GetZoom());
+ QThread::usleep(44);
+ }
+
+ else
+ {
+ waitmutex.lock();
+ if(!wait.wait(&waitmutex,4444))
+
+ {
+#ifdef DEBUG_TILECACHEQUEUE
+ qDebug()<<"Cache Engine TimeOut";
+#endif //DEBUG_TILECACHEQUEUE
+ if(tileCacheQueue.count()==0) break;
+ }
+ waitmutex.unlock();
+ }
+ }
+#ifdef DEBUG_TILECACHEQUEUE
+ qDebug()<<"Cache Engine Stopped";
+#endif //DEBUG_TILECACHEQUEUE
+}
+
+
+}
diff --git a/ground/src/libs/opmapcontrol/src/core/tilecachequeue.h b/ground/src/libs/opmapcontrol/src/core/tilecachequeue.h
new file mode 100644
index 000000000..358c02ed4
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/tilecachequeue.h
@@ -0,0 +1,60 @@
+/**
+******************************************************************************
+*
+* @file tilecachequeue.h
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#ifndef TILECACHEQUEUE_H
+#define TILECACHEQUEUE_H
+
+#include
+#include "cacheitemqueue.h"
+#include
+#include
+#include
+#include
+#include
+#include "pureimagecache.h"
+#include "cache.h"
+
+
+namespace core {
+ class TileCacheQueue:public QThread
+ {
+ Q_OBJECT
+ public:
+ TileCacheQueue();
+
+ void EnqueueCacheTask(CacheItemQueue &task);
+
+ protected:
+ QQueue tileCacheQueue;
+ private:
+ void run();
+ QMutex mutex;
+ QMutex waitmutex;
+ QWaitCondition wait;
+ };
+}
+#endif // TILECACHEQUEUE_H
diff --git a/ground/src/libs/opmapcontrol/src/core/urlfactory.cpp b/ground/src/libs/opmapcontrol/src/core/urlfactory.cpp
new file mode 100644
index 000000000..39cdc12c8
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/urlfactory.cpp
@@ -0,0 +1,760 @@
+/**
+******************************************************************************
+*
+* @file urlfactory.cpp
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#include "urlfactory.h"
+
+
+namespace core {
+UrlFactory::UrlFactory()
+{
+ ///
+ /// timeout for map connections
+ ///
+
+ Proxy.setType(QNetworkProxy::NoProxy);
+
+ ///
+ /// Gets or sets the value of the User-agent HTTP header.
+ ///
+ UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7";
+
+ Timeout = 30 * 1000;
+ CorrectGoogleVersions=true;
+ isCorrectedGoogleVersions = false;
+ UseGeocoderCache=true;
+ UsePlacemarkCache=true;
+ // timer.setSingleShot(true);
+
+
+}
+UrlFactory::~UrlFactory()
+{
+}
+QString UrlFactory::TileXYToQuadKey(const int &tileX,const int &tileY,const int &levelOfDetail) const
+{
+ QString quadKey;
+ for(int i = levelOfDetail; i > 0; i--)
+ {
+ char digit = '0';
+ int mask = 1 << (i - 1);
+ if((tileX & mask) != 0)
+ {
+ digit++;
+ }
+ if((tileY & mask) != 0)
+ {
+ digit++;
+ digit++;
+ }
+ quadKey.append(digit);
+ }
+ return quadKey;
+}
+int UrlFactory::GetServerNum(const Point &pos,const int &max) const
+{
+ return (pos.X() + 2 * pos.Y()) % max;
+}
+void UrlFactory::setIsCorrectGoogleVersions(bool value)
+{
+ isCorrectedGoogleVersions=value;
+
+}
+
+bool UrlFactory::IsCorrectGoogleVersions()
+{
+ return isCorrectedGoogleVersions;
+}
+
+void UrlFactory::TryCorrectGoogleVersions()
+{
+ if(CorrectGoogleVersions && !IsCorrectGoogleVersions())
+ {
+ QNetworkReply *reply;
+ QNetworkRequest qheader;
+ QNetworkAccessManager network;
+ network.setProxy(Proxy);
+#ifdef DEBUG_URLFACTORY
+ qDebug()<<"Correct GoogleVersion";
+#endif //DEBUG_URLFACTORY
+ setIsCorrectGoogleVersions(true);
+ QString url = "http://maps.google.com";
+
+ qheader.setUrl(QUrl(url));
+ qheader.setRawHeader("User-Agent",UserAgent);
+ reply=network.get(qheader);
+ QTime time;
+ time.start();
+ while( (!(reply->isFinished()) || (time.elapsed()>(6*Timeout))) ){QCoreApplication::processEvents(QEventLoop::AllEvents);}
+#ifdef DEBUG_URLFACTORY
+ qDebug()<<"Finished?"<error()<<" abort?"<<(time.elapsed()>Timeout*6);
+#endif //DEBUG_URLFACTORY
+ if( (reply->error()!=QNetworkReply::NoError) | (time.elapsed()>Timeout*6))
+ {
+#ifdef DEBUG_URLFACTORY
+ qDebug()<<"Try corrected version network error:";
+#endif //DEBUG_URLFACTORY
+ return;
+ }
+ {
+#ifdef DEBUG_URLFACTORY
+ qDebug()<<"Try corrected version withou abort or error:"<errorString();
+#endif //DEBUG_URLFACTORY
+ QString html=QString(reply->readAll());
+ // find it
+ // apiCallback(["http://mt0.google.com/vt/v\x3dw2.106\x26hl\x3dlt\x26","http://mt1.google.com/vt/v\x3dw2.106\x26hl\x3dlt\x26","http://mt2.google.com/vt/v\x3dw2.106\x26hl\x3dlt\x26","http://mt3.google.com/vt/v\x3dw2.106\x26hl\x3dlt\x26"],
+ // ["http://khm0.google.com/kh/v\x3d45\x26","http://khm1.google.com/kh/v\x3d45\x26","http://khm2.google.com/kh/v\x3d45\x26","http://khm3.google.com/kh/v\x3d45\x26"],
+ // ["http://mt0.google.com/vt/v\x3dw2t.106\x26hl\x3dlt\x26","http://mt1.google.com/vt/v\x3dw2t.106\x26hl\x3dlt\x26","http://mt2.google.com/vt/v\x3dw2t.106\x26hl\x3dlt\x26","http://mt3.google.com/vt/v\x3dw2t.106\x26hl\x3dlt\x26"],
+ // "","","",false,"G",opts,["http://mt0.google.com/vt/v\x3dw2p.106\x26hl\x3dlt\x26","http://mt1.google.com/vt/v\x3dw2p.106\x26hl\x3dlt\x26","http://mt2.google.com/vt/v\x3dw2p.106\x26hl\x3dlt\x26","http://mt3.google.com/vt/v\x3dw2p.106\x26hl\x3dlt\x26"],jslinker,pageArgs);
+
+ int id = html.lastIndexOf("apiCallback([");
+ if(id > 0)
+ {
+ int idEnd = html.indexOf("jslinker,pageArgs", id);
+ if(idEnd > id)
+ {
+ QString api = html.mid(id, idEnd - id);
+ if(!(api.isNull()|api.isEmpty()))
+ {
+ int i = 0;
+ QStringList opts = api.split("["); //"[\""
+ QString opt;
+ foreach( opt ,opts)
+ {
+ if(opt.contains("http://"))
+ {
+ int start = opt.indexOf("x3d");
+ if(start > 0)
+ {
+ int end = opt.indexOf("\\x26", start);
+ if(end > start)
+ {
+ start += 3;
+ QString u = opt.mid(start, end - start);
+
+ if(i == 0)
+ {
+ if(u.startsWith("m@"))
+ {
+#ifdef DEBUG_URLFACTORY
+ qDebug()<<("TryCorrectGoogleVersions[map]: " + u);
+#endif //DEBUG_URLFACTORY
+ VersionGoogleMap = u;
+ }
+ else
+ {
+#ifdef DEBUG_URLFACTORY
+ qDebug()<<("TryCorrectGoogleVersions[map FAILED]: " + u);
+#endif //DEBUG_URLFACTORY
+ }
+ }
+ else
+ if(i == 1)
+ {
+ // 45
+ if(u[0].isDigit())
+ {
+#ifdef DEBUG_URLFACTORY
+ qDebug()<<("TryCorrectGoogleVersions[satelite]: " + u);
+#endif //DEBUG_URLFACTORY
+ VersionGoogleSatellite = u;
+ }
+ else
+ {
+#ifdef DEBUG_URLFACTORY
+ qDebug()<<("TryCorrectGoogleVersions[satelite FAILED]: " + u);
+#endif //DEBUG_URLFACTORY
+ }
+ }
+ else
+ if(i == 2)
+ {
+ if(u.startsWith("h@"))
+ {
+#ifdef DEBUG_URLFACTORY
+ qDebug()<<("TryCorrectGoogleVersions[labels]: " + u);
+#endif //DEBUG_URLFACTORY
+ VersionGoogleLabels = u;
+ }
+ else
+ {
+#ifdef DEBUG_URLFACTORY
+ qDebug()<<("TryCorrectGoogleVersions[labels FAILED]: " + u);
+#endif //DEBUG_URLFACTORY
+ }
+ }
+ else
+ if(i == 3)
+ {
+ // t@108,r@120
+ if(u.startsWith("t@"))
+ {
+#ifdef DEBUG_URLFACTORY
+ qDebug()<<("TryCorrectGoogleVersions[terrain]: " + u);
+#endif //DEBUG_URLFACTORY
+ VersionGoogleTerrain = u;
+ VersionGoogleTerrainChina = u;
+ }
+ else
+ {
+#ifdef DEBUG_URLFACTORY
+ qDebug()<<("TryCorrectGoogleVersions[terrain FAILED]: " + u);
+#endif //DEBUG_URLFACTORY
+ }
+ break;
+ }
+ i++;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ reply->deleteLater();
+ }
+}
+QString UrlFactory::MakeImageUrl(const MapType::Types &type,const Point &pos,const int &zoom,const QString &language)
+{
+#ifdef DEBUG_URLFACTORY
+ qDebug()<<"Entered MakeImageUrl";
+#endif //DEBUG_URLFACTORY
+ switch(type)
+ {
+ case MapType::GoogleMap:
+ {
+ QString server = "mt";
+ QString request = "vt";
+ QString sec1 = ""; // after &x=...
+ QString sec2 = ""; // after &zoom=...
+ GetSecGoogleWords(pos, sec1, sec2);
+ TryCorrectGoogleVersions();
+
+ return QString("http://%1%2.google.com/%3/lyrs=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleMap).arg(language).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2);
+ }
+ break;
+ case MapType::GoogleSatellite:
+ {
+ QString server = "khm";
+ QString request = "kh";
+ QString sec1 = ""; // after &x=...
+ QString sec2 = ""; // after &zoom=...
+ GetSecGoogleWords(pos, sec1, sec2);
+ TryCorrectGoogleVersions();
+ return QString("http://%1%2.google.com/%3/v=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleSatellite).arg(language).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2);
+ }
+ break;
+ case MapType::GoogleLabels:
+ {
+ QString server = "mt";
+ QString request = "vt";
+ QString sec1 = ""; // after &x=...
+ QString sec2 = ""; // after &zoom=...
+ GetSecGoogleWords(pos, sec1, sec2);
+ TryCorrectGoogleVersions();
+
+ return QString("http://%1%2.google.com/%3/lyrs=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleLabels).arg(language).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2);
+ }
+ break;
+ case MapType::GoogleTerrain:
+ {
+ QString server = "mt";
+ QString request = "vt";
+ QString sec1 = ""; // after &x=...
+ QString sec2 = ""; // after &zoom=...
+ GetSecGoogleWords(pos, sec1, sec2);
+ TryCorrectGoogleVersions();
+ return QString("http://%1%2.google.com/%3/v=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleTerrain).arg(language).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2);
+ }
+ break;
+ case MapType::GoogleMapChina:
+ {
+ QString server = "mt";
+ QString request = "vt";
+ QString sec1 = ""; // after &x=...
+ QString sec2 = ""; // after &zoom=...
+ GetSecGoogleWords(pos, sec1, sec2);
+ TryCorrectGoogleVersions();
+ // http://mt0.google.cn/vt/v=w2.101&hl=zh-CN&gl=cn&x=12&y=6&z=4&s=Ga
+
+ return QString("http://%1%2.google.cn/%3/lyrs=%4&hl=%5&gl=cn&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleMapChina).arg("zh-CN").arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2);
+ }
+ break;
+ case MapType::GoogleSatelliteChina:
+ {
+ QString server = "mt";
+ QString request = "vt";
+ QString sec1 = ""; // after &x=...
+ QString sec2 = ""; // after &zoom=...
+ GetSecGoogleWords(pos, sec1, sec2);
+ // TryCorrectGoogleVersions();
+ // http://khm0.google.cn/kh/v=46&x=12&y=6&z=4&s=Ga
+
+ return QString("http://%1%2.google.cn/%3/lyrs=%4&gl=cn&x=%5%6&y=%7&z=%8&s=%9").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleSatelliteChina).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2);
+ }
+ break;
+ case MapType::GoogleLabelsChina:
+ {
+ QString server = "mt";
+ QString request = "vt";
+ QString sec1 = ""; // after &x=...
+ QString sec2 = ""; // after &zoom=...
+ GetSecGoogleWords(pos, sec1, sec2);
+ TryCorrectGoogleVersions();
+ // http://mt0.google.cn/vt/v=w2t.110&hl=zh-CN&gl=cn&x=12&y=6&z=4&s=Ga
+
+ return QString("http://%1%2.google.cn/%3/imgtp=png32&lyrs=%4&hl=%5&gl=cn&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleLabelsChina).arg("zh-CN").arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2);
+ }
+ break;
+ case MapType::GoogleTerrainChina:
+ {
+ QString server = "mt";
+ QString request = "vt";
+ QString sec1 = ""; // after &x=...
+ QString sec2 = ""; // after &zoom=...
+ GetSecGoogleWords(pos, sec1, sec2);
+ TryCorrectGoogleVersions();
+ // http://mt0.google.cn/vt/v=w2p.110&hl=zh-CN&gl=cn&x=12&y=6&z=4&s=Ga
+
+ return QString("http://%1%2.google.com/%3/lyrs=%4&hl=%5&gl=cn&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleTerrainChina).arg("zh-CN").arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2);
+ }
+ break;
+ case MapType::GoogleMapKorea:
+ {
+ QString server = "mt";
+ QString request = "mt";
+ QString sec1 = ""; // after &x=...
+ QString sec2 = ""; // after &zoom=...
+ GetSecGoogleWords(pos, sec1, sec2);
+
+ //http://mt3.gmaptiles.co.kr/mt/v=kr1.11&hl=lt&x=109&y=49&z=7&s=
+
+ QString ret = QString("http://%1%2.gmaptiles.co.kr/%3/v=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleMapKorea).arg(language).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2);
+ return ret;
+ }
+ break;
+ case MapType::GoogleSatelliteKorea:
+ {
+ QString server = "khm";
+ QString request = "kh";
+ QString sec1 = ""; // after &x=...
+ QString sec2 = ""; // after &zoom=...
+ GetSecGoogleWords(pos, sec1, sec2);
+
+ // http://khm1.google.co.kr/kh/v=54&x=109&y=49&z=7&s=
+
+ return QString("http://%1%2.google.co.kr/%3/v=%4&x=%5%6&y=%7&z=%8&s=%9").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleSatelliteKorea).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2);
+ }
+ break;
+ case MapType::GoogleLabelsKorea:
+ {
+ QString server = "mt";
+ QString request = "mt";
+ QString sec1 = ""; // after &x=...
+ QString sec2 = ""; // after &zoom=...
+ GetSecGoogleWords(pos, sec1, sec2);
+
+ // http://mt1.gmaptiles.co.kr/mt/v=kr1t.11&hl=lt&x=109&y=50&z=7&s=G
+
+ return QString("http://%1%2.gmaptiles.co.kr/%3/v=%4&hl=%5&x=%6%7&y=%8&z=%9&s=%10").arg(server).arg(GetServerNum(pos, 4)).arg(request).arg(VersionGoogleLabelsKorea).arg(language).arg(pos.X()).arg(sec1).arg(pos.Y()).arg(zoom).arg(sec2);
+ }
+ break;
+ case MapType::YahooMap:
+ {
+ return QString("http://maps%1.yimg.com/hx/tl?v=%2&.intl=%3&x=%4&y=%5&z=%6&r=1").arg(((GetServerNum(pos, 2)) + 1)).arg(VersionYahooMap).arg(language).arg(pos.X()).arg((((1 << zoom) >> 1) - 1 - pos.Y())).arg((zoom + 1));
+ }
+
+ case MapType::YahooSatellite:
+ {
+ return QString("http://maps%1.yimg.com/ae/ximg?v=%2&t=a&s=256&.intl=%3&x=%4&y=%5&z=%6&r=1").arg("3").arg(VersionYahooSatellite).arg(language).arg(pos.X()).arg(((1 << zoom) >> 1) - 1 - pos.Y()).arg(zoom + 1);
+ }
+ break;
+ case MapType::YahooLabels:
+ {
+ return QString("http://maps%1.yimg.com/hx/tl?v=%2&t=h&.intl=%3&x=%4&y=%5&z=%6&r=1").arg("1").arg(VersionYahooLabels).arg(language).arg(pos.X()).arg(((1 << zoom) >> 1) - 1 - pos.Y()).arg(zoom + 1);
+ }
+ break;
+ case MapType::OpenStreetMap:
+ {
+ char letter= "abc"[GetServerNum(pos, 3)];
+ return QString("http://%1.tile.openstreetmap.org/%2/%3/%4.png").arg(letter).arg(zoom).arg(pos.X()).arg(pos.Y());
+ }
+ break;
+ case MapType::OpenStreetOsm:
+ {
+ char letter = "abc"[GetServerNum(pos, 3)];
+ return QString("http://%1.tah.openstreetmap.org/Tiles/tile/%2/%3/%4.png").arg(letter).arg(zoom).arg(pos.X()).arg(pos.Y());
+ }
+ break;
+ case MapType::OpenStreetMapSurfer:
+ {
+ // http://tiles1.mapsurfer.net/tms_r.ashx?x=37378&y=20826&z=16
+
+ return QString("http://tiles1.mapsurfer.net/tms_r.ashx?x=%1&y=%2&z=%3").arg(pos.X()).arg(pos.Y()).arg(zoom);
+ }
+ break;
+ case MapType::OpenStreetMapSurferTerrain:
+ {
+ // http://tiles2.mapsurfer.net/tms_t.ashx?x=9346&y=5209&z=14
+
+ return QString("http://tiles2.mapsurfer.net/tms_t.ashx?x=%1&y=%2&z=%3").arg(pos.X()).arg(pos.Y()).arg(zoom);
+ }
+ break;
+ case MapType::BingMap:
+ {
+ QString key = TileXYToQuadKey(pos.X(), pos.Y(), zoom);
+ return QString("http://ecn.t%1.tiles.virtualearth.net/tiles/r%2.png?g=%3&mkt=%4%5").arg(GetServerNum(pos, 4)).arg(key).arg(VersionBingMaps).arg(language).arg(!(BingMapsClientToken.isNull()|BingMapsClientToken.isEmpty()) ? "&token=" + BingMapsClientToken : QString(""));
+ }
+ break;
+ case MapType::BingSatellite:
+ {
+ QString key = TileXYToQuadKey(pos.X(), pos.Y(), zoom);
+ return QString("http://ecn.t%1.tiles.virtualearth.net/tiles/a%2.jpeg?g=%3&mkt=%4%5").arg(GetServerNum(pos, 4)).arg(key).arg(VersionBingMaps).arg(language).arg(!(BingMapsClientToken.isNull()|BingMapsClientToken.isEmpty()) ? "&token=" + BingMapsClientToken : QString(""));
+ }
+ break;
+ case MapType::BingHybrid:
+ {
+ QString key = TileXYToQuadKey(pos.X(), pos.Y(), zoom);
+ return QString("http://ecn.t%1.tiles.virtualearth.net/tiles/h%2.jpeg?g=%3&mkt=%4%5").arg(GetServerNum(pos, 4)).arg(key).arg(VersionBingMaps).arg(language).arg(!(BingMapsClientToken.isNull()|BingMapsClientToken.isEmpty()) ? "&token=" + BingMapsClientToken : QString(""));
+ }
+
+ case MapType::ArcGIS_Map:
+ {
+ // http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer/tile/0/0/0.jpg
+
+ return QString("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer/tile/%1/%2/%3").arg(zoom).arg(pos.Y()).arg(pos.X());
+ }
+ break;
+ case MapType::ArcGIS_Satellite:
+ {
+ // http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer/tile/1/0/1.jpg
+
+ return QString("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer/tile/%1/%2/%3").arg(zoom).arg(pos.Y()).arg(pos.X());
+ }
+ break;
+ case MapType::ArcGIS_ShadedRelief:
+ {
+ // http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_ShadedRelief_World_2D/MapServer/tile/1/0/1.jpg
+
+ return QString("http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_ShadedRelief_World_2D/MapServer/tile/%1/%2/%3").arg(zoom).arg(pos.Y()).arg(pos.X());
+ }
+ break;
+ case MapType::ArcGIS_Terrain:
+ {
+ // http://server.arcgisonline.com/ArcGIS/rest/services/NGS_Topo_US_2D/MapServer/tile/4/3/15
+
+ return QString("http://server.arcgisonline.com/ArcGIS/rest/services/NGS_Topo_US_2D/MapServer/tile/%1/%2/%3").arg(zoom).arg(pos.Y()).arg(pos.X());
+ }
+ break;
+ case MapType::ArcGIS_MapsLT_OrtoFoto:
+ {
+ // http://www.maps.lt/ortofoto/mapslt_ortofoto_vector_512/map/_alllayers/L02/R0000001b/C00000028.jpg
+ // http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto/MapServer/tile/0/9/13
+ // return string.Format("http://www.maps.lt/ortofoto/mapslt_ortofoto_vector_512/map/_alllayers/L{0:00}/R{1:x8}/C{2:x8}.jpg", zoom, pos.Y(), pos.X());
+ // http://dc1.maps.lt/cache/mapslt_ortofoto_512/map/_alllayers/L03/R0000001c/C00000029.jpg
+ // return string.Format("http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto/MapServer/tile/{0}/{1}/{2}", zoom, pos.Y(), pos.X());
+ // http://dc1.maps.lt/cache/mapslt_ortofoto_512/map/_alllayers/L03/R0000001d/C0000002a.jpg
+ //TODO verificar
+ return QString("http://dc1.maps.lt/cache/mapslt_ortofoto/map/_alllayers/L%1/R%2/C%3.jpg").arg(zoom,2,10,(QChar)'0').arg(pos.Y(),8,16,(QChar)'0').arg(pos.X(),8,16,(QChar)'0');
+ }
+ break;
+ case MapType::ArcGIS_MapsLT_Map:
+ {
+ // http://www.maps.lt/ortofoto/mapslt_ortofoto_vector_512/map/_alllayers/L02/R0000001b/C00000028.jpg
+ // http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto/MapServer/tile/0/9/13
+ // return string.Format("http://www.maps.lt/ortofoto/mapslt_ortofoto_vector_512/map/_alllayers/L{0:00}/R{1:x8}/C{2:x8}.jpg", zoom, pos.Y(), pos.X());
+ // http://arcgis.maps.lt/ArcGIS/rest/services/mapslt/MapServer/tile/7/1162/1684.png
+ // http://dc1.maps.lt/cache/mapslt_512/map/_alllayers/L03/R0000001b/C00000029.png
+ //TODO verificar
+ // http://dc1.maps.lt/cache/mapslt/map/_alllayers/L02/R0000001c/C00000029.png
+ return QString("http://dc1.maps.lt/cache/mapslt/map/_alllayers/L%1/R%2/C%3.png").arg(zoom,2,10,(QChar)'0').arg(pos.Y(),8,16,(QChar)'0').arg(pos.X(),8,16,(QChar)'0');
+ }
+ break;
+ case MapType::ArcGIS_MapsLT_Map_Labels:
+ {
+ //http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto_overlay/MapServer/tile/0/9/13
+ //return string.Format("http://arcgis.maps.lt/ArcGIS/rest/services/mapslt_ortofoto_overlay/MapServer/tile/{0}/{1}/{2}", zoom, pos.Y(), pos.X());
+ //http://dc1.maps.lt/cache/mapslt_ortofoto_overlay_512/map/_alllayers/L03/R0000001d/C00000029.png
+ //TODO verificar
+ return QString("http://dc1.maps.lt/cache/mapslt_ortofoto_overlay/map/_alllayers/L%1/R%2/C%3.png").arg(zoom,2,10,(QChar)'0').arg(pos.Y(),8,16,(QChar)'0').arg(pos.X(),8,16,(QChar)'0');
+ }
+ break;
+ case MapType::PergoTurkeyMap:
+ {
+ // http://{domain}/{layerName}/{zoomLevel}/{first3LetterOfTileX}/{second3LetterOfTileX}/{third3LetterOfTileX}/{first3LetterOfTileY}/{second3LetterOfTileY}/{third3LetterOfTileXY}.png
+
+ // http://map3.pergo.com.tr/tile/00/000/000/001/000/000/000.png
+ // That means: Zoom Level: 0 TileX: 1 TileY: 0
+
+ // http://domain/tile/14/000/019/371/000/011/825.png
+ // That means: Zoom Level: 14 TileX: 19371 TileY:11825
+
+ // string x = pos.X().ToString("000000000").Insert(3, "/").Insert(7, "/"); // - 000/000/001
+ // string y = pos.Y().ToString("000000000").Insert(3, "/").Insert(7, "/"); // - 000/000/000
+ QString x=QString("%1").arg(pos.X(),9,(QChar)'0');
+ x.insert(3,"/").insert(7,"/");
+ QString y=QString("%1").arg(pos.X(),9,(QChar)'0');
+ y.insert(3,"/").insert(7,"/");
+
+ return QString("http://map%1.pergo.com.tr/tile/%2/%3/%4.png").arg(GetServerNum(pos, 4),2,10,(QChar)'0').arg(zoom).arg(x).arg(y);
+ }
+ break;
+ case MapType::SigPacSpainMap:
+ {
+ return QString("http://sigpac.mapa.es/kmlserver/raster/%1@3785/%2.%3.%4.img").arg(levelsForSigPacSpainMap[zoom]).arg(zoom).arg(pos.X()).arg((2 << (zoom - 1)) - pos.Y() - 1);
+ }
+ break;
+
+ case MapType::YandexMapRu:
+ {
+ QString server = "vec";
+
+ //http://vec01.maps.yandex.ru/tiles?l=map&v=2.10.2&x=1494&y=650&z=11
+
+ return QString("http://%10%2.maps.yandex.ru/tiles?l=map&v=%3&x=%4&y=%5&z=%6").arg(server).arg(GetServerNum(pos, 4)+1).arg(VersionYandexMap).arg(pos.X()).arg(pos.Y()).arg(zoom);
+ }
+ break;
+ default:
+ break;
+ }
+
+ return QString::null;
+}
+void UrlFactory::GetSecGoogleWords(const Point &pos, QString &sec1, QString &sec2)
+{
+ sec1 = ""; // after &x=...
+ sec2 = ""; // after &zoom=...
+ int seclen = ((pos.X() * 3) + pos.Y()) % 8;
+ sec2 = SecGoogleWord.left(seclen);
+ if(pos.Y() >= 10000 && pos.Y() < 100000)
+ {
+ sec1 = "&s=";
+ }
+}
+QString UrlFactory::MakeGeocoderUrl(QString keywords)
+{
+ QString key = keywords.replace(' ', '+');
+ return QString("http://maps.google.com/maps/geo?q=%1&output=csv&key=%2").arg(key).arg(GoogleMapsAPIKey);
+}
+QString UrlFactory::MakeReverseGeocoderUrl(PointLatLng &pt,const QString &language)
+{
+
+ return QString("http://maps.google.com/maps/geo?hl=%1&ll=%2,%3&output=csv&key=%4").arg(language).arg(QString::number(pt.Lat())).arg(QString::number(pt.Lng())).arg(GoogleMapsAPIKey);
+
+}
+PointLatLng UrlFactory::GetLatLngFromGeodecoder(const QString &keywords, GeoCoderStatusCode::Types &status)
+{
+ return GetLatLngFromGeocoderUrl(MakeGeocoderUrl(keywords),UseGeocoderCache,status);
+}
+PointLatLng UrlFactory::GetLatLngFromGeocoderUrl(const QString &url, const bool &useCache, GeoCoderStatusCode::Types &status)
+{
+#ifdef DEBUG_URLFACTORY
+ qDebug()<<"Entered GetLatLngFromGeocoderUrl:";
+#endif //DEBUG_URLFACTORY
+ status = GeoCoderStatusCode::Unknow;
+ PointLatLng ret(0,0);
+ QString urlEnd = url.right(url.indexOf("geo?q="));
+ urlEnd.replace( QRegExp(
+ "[^"
+ "A-Z,a-z,0-9,"
+ "\\^,\\&,\\',\\@,"
+ "\\{,\\},\\[,\\],"
+ "\\,,\\$,\\=,\\!,"
+ "\\-,\\#,\\(,\\),"
+ "\\%,\\.,\\+,\\~,\\_"
+ "]"), "_" );
+
+ QString geo = useCache ? Cache::Instance()->GetGeocoderFromCache(urlEnd) : "";
+
+ if(geo.isNull()|geo.isEmpty())
+ {
+#ifdef DEBUG_URLFACTORY
+ qDebug()<<"GetLatLngFromGeocoderUrl:Not in cache going internet";
+#endif //DEBUG_URLFACTORY
+ QNetworkReply *reply;
+ QNetworkRequest qheader;
+ QNetworkAccessManager network;
+ network.setProxy(Proxy);
+ qheader.setUrl(QUrl(url));
+ qheader.setRawHeader("User-Agent",UserAgent);
+ reply=network.get(qheader);
+#ifdef DEBUG_URLFACTORY
+ qDebug()<<"GetLatLngFromGeocoderUrl:URL="<isFinished()) || (time.elapsed()>(6*Timeout))) ){QCoreApplication::processEvents(QEventLoop::AllEvents);}
+#ifdef DEBUG_URLFACTORY
+ qDebug()<<"Finished?"<error()<<" abort?"<<(time.elapsed()>Timeout*6);
+#endif //DEBUG_URLFACTORY
+ if( (reply->error()!=QNetworkReply::NoError) | (time.elapsed()>Timeout*6))
+ {
+#ifdef DEBUG_URLFACTORY
+ qDebug()<<"GetLatLngFromGeocoderUrl::Network error";
+#endif //DEBUG_URLFACTORY
+ return PointLatLng(0,0);
+ }
+ {
+#ifdef DEBUG_URLFACTORY
+ qDebug()<<"GetLatLngFromGeocoderUrl:Reply ok";
+#endif //DEBUG_URLFACTORY
+ geo=reply->readAll();
+
+
+ // cache geocoding
+ if(useCache && geo.startsWith("200"))
+ {
+ Cache::Instance()->CacheGeocoder(urlEnd, geo);
+ }
+ }
+ reply->deleteLater();
+ }
+
+
+ // parse values
+ // true : 200,4,56.1451640,22.0681787
+ // false: 602,0,0,0
+ {
+ QStringList values = geo.split(',');
+ if(values.count() == 4)
+ {
+ status = (GeoCoderStatusCode::Types) QString(values[0]).toInt();
+ if(status == GeoCoderStatusCode::G_GEO_SUCCESS)
+ {
+ double lat = QString(values[2]).toDouble();
+ double lng = QString(values[3]).toDouble();
+
+ ret = PointLatLng(lat, lng);
+#ifdef DEBUG_URLFACTORY
+ qDebug()<<"Lat="<GetPlacemarkFromCache(urlEnd) : "";
+
+ if(reverse.isNull()|reverse.isEmpty())
+ {
+#ifdef DEBUG_URLFACTORY
+ qDebug()<<"GetLatLngFromGeocoderUrl:Not in cache going internet";
+#endif //DEBUG_URLFACTORY
+ QNetworkReply *reply;
+ QNetworkRequest qheader;
+ QNetworkAccessManager network;
+ network.setProxy(Proxy);
+ qheader.setUrl(QUrl(url));
+ qheader.setRawHeader("User-Agent",UserAgent);
+ reply=network.get(qheader);
+#ifdef DEBUG_URLFACTORY
+ qDebug()<<"GetLatLngFromGeocoderUrl:URL="<isFinished()) || (time.elapsed()>(6*Timeout))) ){QCoreApplication::processEvents(QEventLoop::AllEvents);}
+#ifdef DEBUG_URLFACTORY
+ qDebug()<<"Finished?"<error()<<" abort?"<<(time.elapsed()>Timeout*6);
+#endif //DEBUG_URLFACTORY
+ if( (reply->error()!=QNetworkReply::NoError) | (time.elapsed()>Timeout*6))
+ {
+#ifdef DEBUG_URLFACTORY
+ qDebug()<<"GetLatLngFromGeocoderUrl::Network error";
+#endif //DEBUG_URLFACTORY
+ return ret;
+ }
+ {
+#ifdef DEBUG_URLFACTORY
+ qDebug()<<"GetLatLngFromGeocoderUrl:Reply ok";
+#endif //DEBUG_URLFACTORY
+ QByteArray a=(reply->readAll());
+ QTextCodec *codec = QTextCodec::codecForName("UTF-8");
+ reverse = codec->toUnicode(a);
+#ifdef DEBUG_URLFACTORY
+ qDebug()<CachePlacemark(urlEnd, reverse);
+ }
+ }
+ reply->deleteLater();
+ }
+
+
+ // parse values
+ // true : 200,4,56.1451640,22.0681787
+ // false: 602,0,0,0
+ if(reverse.startsWith("200"))
+ {
+ QString acc = reverse.left(reverse.indexOf('\"'));
+ ret = Placemark(reverse.remove(reverse.indexOf('\"')));
+ ret.SetAccuracy ((int) (( (QString) acc.split(',')[1]).toInt()) );
+
+ }
+ return ret;
+}
+double UrlFactory::GetDistance(PointLatLng p1, PointLatLng p2)
+{
+ double dLat1InRad = p1.Lat() * (M_PI / 180);
+ double dLong1InRad = p1.Lng() * (M_PI / 180);
+ double dLat2InRad = p2.Lat() * (M_PI / 180);
+ double dLong2InRad = p2.Lng() * (M_PI / 180);
+ double dLongitude = dLong2InRad - dLong1InRad;
+ double dLatitude = dLat2InRad - dLat1InRad;
+ double a = pow(sin(dLatitude / 2), 2) + cos(dLat1InRad) * cos(dLat2InRad) * pow(sin(dLongitude / 2), 2);
+ double c = 2 * atan2(sqrt(a), sqrt(1 - a));
+ double dDistance = EarthRadiusKm * c;
+ return dDistance;
+}
+}
diff --git a/ground/src/libs/opmapcontrol/src/core/urlfactory.h b/ground/src/libs/opmapcontrol/src/core/urlfactory.h
new file mode 100644
index 000000000..6d69de047
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/core/urlfactory.h
@@ -0,0 +1,90 @@
+/**
+******************************************************************************
+*
+* @file urlfactory.h
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#ifndef URLFACTORY_H
+#define URLFACTORY_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "providerstrings.h"
+#include "pureimagecache.h"
+#include "../internals/pointlatlng.h"
+#include "geodecoderstatus.h"
+#include
+#include "cache.h"
+#include "placemark.h"
+#include
+#include "cmath"
+
+using namespace internals;
+
+namespace core {
+ class UrlFactory: public QObject,public ProviderStrings
+ {
+ Q_OBJECT
+ public:
+ ///
+ /// Gets or sets the value of the User-agent HTTP header.
+ ///
+ QByteArray UserAgent;
+ QNetworkProxy Proxy;
+ UrlFactory();
+ ~UrlFactory();
+ QString MakeImageUrl(const MapType::Types &type,const Point &pos,const int &zoom,const QString &language);
+ PointLatLng GetLatLngFromGeodecoder(const QString &keywords,GeoCoderStatusCode::Types &status);
+ Placemark GetPlacemarkFromGeocoder(PointLatLng location);
+ int Timeout;
+ private:
+ void GetSecGoogleWords(const Point &pos, QString &sec1, QString &sec2);
+ int GetServerNum(const Point &pos,const int &max) const;
+ void TryCorrectGoogleVersions();
+ bool isCorrectedGoogleVersions;
+ QString TileXYToQuadKey(const int &tileX,const int &tileY,const int &levelOfDetail) const;
+ bool CorrectGoogleVersions;
+ bool UseGeocoderCache; //TODO GetSet
+ bool UsePlacemarkCache;//TODO GetSet
+ static const double EarthRadiusKm = 6378.137; // WGS-84
+ double GetDistance(PointLatLng p1,PointLatLng p2);
+
+ protected:
+ static short timelapse;
+ QString LanguageStr;
+ bool IsCorrectGoogleVersions();
+ void setIsCorrectGoogleVersions(bool value);
+ QString MakeGeocoderUrl(QString keywords);
+ QString MakeReverseGeocoderUrl(PointLatLng &pt,const QString &language);
+ PointLatLng GetLatLngFromGeocoderUrl(const QString &url,const bool &useCache, GeoCoderStatusCode::Types &status);
+ Placemark GetPlacemarkFromReverseGeocoderUrl(const QString &url,const bool &useCache);
+ };
+
+}
+#endif // URLFACTORY_H
diff --git a/ground/src/libs/opmapcontrol/src/finaltest/finaltest.pro b/ground/src/libs/opmapcontrol/src/finaltest/finaltest.pro
new file mode 100644
index 000000000..4795c90d1
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/finaltest/finaltest.pro
@@ -0,0 +1,14 @@
+TARGET = finaltest
+TEMPLATE = app
+
+#include(../../opmapcontrol.pri)
+LIBS+=../../../../../lib/openpilotgcs/OPMapWidgetd.dll
+DESTDIR = ../../../../../bin
+
+
+SOURCES += main.cpp\
+ mainwindow.cpp
+
+HEADERS += mainwindow.h
+
+FORMS += mainwindow.ui
diff --git a/ground/src/libs/opmapcontrol/src/finaltest/main.cpp b/ground/src/libs/opmapcontrol/src/finaltest/main.cpp
new file mode 100644
index 000000000..49a2cb9b8
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/finaltest/main.cpp
@@ -0,0 +1,10 @@
+#include
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ MainWindow w;
+ w.show();
+ return a.exec();
+}
diff --git a/ground/src/libs/opmapcontrol/src/finaltest/mainwindow.cpp b/ground/src/libs/opmapcontrol/src/finaltest/mainwindow.cpp
new file mode 100644
index 000000000..bfde8bb1f
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/finaltest/mainwindow.cpp
@@ -0,0 +1,101 @@
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+
+MainWindow::MainWindow(QWidget *parent) :
+ QMainWindow(parent),
+ ui(new Ui::MainWindow)
+{
+ map=new mapcontrol::OPMapWidget();
+ ui->setupUi(this);
+ ui->comboBox->addItems(mapcontrol::Helper::MapTypes());
+ ui->comboBox->setCurrentIndex(mapcontrol::Helper::MapTypes().indexOf("GoogleHybrid"));
+ QHBoxLayout *layout=new QHBoxLayout(parent);
+ layout->addWidget(map);
+ layout->addWidget(ui->widget);
+ ui->centralWidget->setLayout(layout);
+ connect(map,SIGNAL(zoomChanged(double)),this,SLOT(zoomChanged(double)));
+}
+
+MainWindow::~MainWindow()
+{
+ delete ui;
+ delete map;
+}
+
+void MainWindow::changeEvent(QEvent *e)
+{
+ QMainWindow::changeEvent(e);
+ switch (e->type()) {
+ case QEvent::LanguageChange:
+ ui->retranslateUi(this);
+ break;
+ default:
+ break;
+ }
+}
+
+void MainWindow::on_pushButtonZoomP_clicked()
+{
+ double x,y;
+ x=map->Zoom();
+ y=ui->doubleSpinBox->value();
+ map->SetZoom(map->Zoom()+ui->doubleSpinBox->value());
+}
+
+void MainWindow::on_pushButtonZoomM_clicked()
+{
+ map->SetZoom(map->Zoom()-ui->doubleSpinBox->value());
+}
+
+void MainWindow::on_checkBox_clicked(bool checked)
+{
+ map->SetShowTileGridLines(checked);
+}
+void MainWindow::zoomChanged(double zoom)
+{
+ ui->label_5->setText("CurrentZoom="+QString::number(zoom));
+}
+
+void MainWindow::on_pushButtonRL_clicked()
+{
+ map->SetRotate(map->Rotate()-1);
+}
+
+void MainWindow::on_pushButtonRC_clicked()
+{
+ map->SetRotate(0);
+}
+
+void MainWindow::on_pushButtonRR_clicked()
+{
+ map->SetRotate(map->Rotate()+1);
+}
+
+void MainWindow::on_pushButton_clicked()
+{
+ map->ReloadMap();
+}
+
+void MainWindow::on_pushButtonGO_clicked()
+{
+ core::GeoCoderStatusCode::Types x=map->SetCurrentPositionByKeywords(ui->lineEdit->text());
+ ui->label->setText( mapcontrol::Helper::StrFromGeoCoderStatusCode(x));
+
+}
+
+void MainWindow::on_checkBox_2_clicked(bool checked)
+{
+ map->SetUseOpenGL(checked);
+}
+
+void MainWindow::on_comboBox_currentIndexChanged(QString value)
+{
+ if (map->isStarted())
+ map->SetMapType(mapcontrol::Helper::MapTypeFromString(value));
+}
+
+void MainWindow::on_pushButton_2_clicked()
+{
+ map->X();
+}
diff --git a/ground/src/libs/opmapcontrol/src/finaltest/mainwindow.h b/ground/src/libs/opmapcontrol/src/finaltest/mainwindow.h
new file mode 100644
index 000000000..71add1649
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/finaltest/mainwindow.h
@@ -0,0 +1,39 @@
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+#include "../mapwidget/opmapwidget.h"
+#include "C:/Users/Xapo\Documents/QT/OpenPilot/src/libs/opmapcontrol/opmapcontrol.h"
+#include
+
+namespace Ui {
+ class MainWindow;
+}
+
+class MainWindow : public QMainWindow {
+ Q_OBJECT
+public:
+ MainWindow(QWidget *parent = 0);
+ ~MainWindow();
+
+protected:
+ void changeEvent(QEvent *e);
+
+private:
+ Ui::MainWindow *ui;
+ mapcontrol::OPMapWidget *map;
+
+private slots:
+ void on_pushButton_2_clicked();
+ void on_comboBox_currentIndexChanged(QString );
+ void on_checkBox_2_clicked(bool checked);
+ void on_pushButtonGO_clicked();
+ void on_pushButton_clicked();
+ void on_pushButtonRR_clicked();
+ void on_pushButtonRC_clicked();
+ void on_pushButtonRL_clicked();
+ void on_checkBox_clicked(bool checked);
+ void on_pushButtonZoomM_clicked();
+ void on_pushButtonZoomP_clicked();
+ void zoomChanged(double zoom);
+};
+
+#endif // MAINWINDOW_H
diff --git a/ground/src/libs/opmapcontrol/src/finaltest/mainwindow.ui b/ground/src/libs/opmapcontrol/src/finaltest/mainwindow.ui
new file mode 100644
index 000000000..935adc977
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/finaltest/mainwindow.ui
@@ -0,0 +1,248 @@
+
+
+ MainWindow
+
+
+
+ 0
+ 0
+ 524
+ 496
+
+
+
+ MainWindow
+
+
+
+
+
+ 110
+ 15
+ 181
+ 421
+
+
+
+
+ 10
+ 0
+
+
+
+
+ 181
+ 16777215
+
+
+
+
+ 0
+
+
+ 0
+
+ -
+
+
-
+
+
+ MapType
+
+
+
-
+
+
+ -
+
+
+ PushButton
+
+
+
+
+
+
+ -
+
+
+ Goto Place
+
+
+
-
+
+
-
+
+
+ -
+
+
+ GO
+
+
+
+
+
+ -
+
+
+ GeoCoderStatusCode
+
+
+
+
+
+
+ -
+
+
+ Rotate
+
+
+
-
+
+
+ Left
+
+
+
+ -
+
+
+ Center
+
+
+
+ -
+
+
+ Right
+
+
+
+
+
+
+ -
+
+
+ Zoom
+
+
+
-
+
+
-
+
+
+ +
+
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
-
+
+
+ ZoomIncrement
+
+
+ Qt::AlignCenter
+
+
+
+
+
+ -
+
+
+ 0.100000000000000
+
+
+ 1.000000000000000
+
+
+
+ -
+
+
+ CurrentZoom=
+
+
+ Qt::AlignCenter
+
+
+
+ -
+
+
+ Misc
+
+
+
-
+
+
+ ShowGridLines
+
+
+ true
+
+
+
+ -
+
+
+ UseOpenGL
+
+
+
+ -
+
+
+ ReloadMap
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ TopToolBarArea
+
+
+ false
+
+
+
+
+
+
+
+
diff --git a/ground/src/libs/opmapcontrol/src/finaltest/ui_mainwindow.h b/ground/src/libs/opmapcontrol/src/finaltest/ui_mainwindow.h
new file mode 100644
index 000000000..49f1b436e
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/finaltest/ui_mainwindow.h
@@ -0,0 +1,297 @@
+/********************************************************************************
+** Form generated from reading UI file 'mainwindow.ui'
+**
+** Created: Mon 14. Jun 16:53:19 2010
+** by: Qt User Interface Compiler version 4.6.2
+**
+** WARNING! All changes made in this file will be lost when recompiling UI file!
+********************************************************************************/
+
+#ifndef UI_MAINWINDOW_H
+#define UI_MAINWINDOW_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+QT_BEGIN_NAMESPACE
+
+class Ui_MainWindow
+{
+public:
+ QWidget *centralWidget;
+ QWidget *widget;
+ QVBoxLayout *verticalLayout_4;
+ QVBoxLayout *verticalLayout_3;
+ QGroupBox *groupBox_5;
+ QVBoxLayout *verticalLayout_8;
+ QComboBox *comboBox;
+ QPushButton *pushButton_2;
+ QGroupBox *groupBox;
+ QVBoxLayout *verticalLayout_6;
+ QVBoxLayout *verticalLayout_5;
+ QLineEdit *lineEdit;
+ QPushButton *pushButtonGO;
+ QLabel *label;
+ QGroupBox *groupBox_2;
+ QHBoxLayout *horizontalLayout;
+ QPushButton *pushButtonRL;
+ QPushButton *pushButtonRC;
+ QPushButton *pushButtonRR;
+ QGroupBox *groupBox_3;
+ QVBoxLayout *verticalLayout;
+ QHBoxLayout *horizontalLayout_3;
+ QPushButton *pushButtonZoomP;
+ QPushButton *pushButtonZoomM;
+ QVBoxLayout *verticalLayout_2;
+ QLabel *label_4;
+ QDoubleSpinBox *doubleSpinBox;
+ QLabel *label_5;
+ QGroupBox *groupBox_4;
+ QVBoxLayout *verticalLayout_7;
+ QCheckBox *checkBox;
+ QCheckBox *checkBox_2;
+ QPushButton *pushButton;
+ QMenuBar *menuBar;
+ QToolBar *mainToolBar;
+ QStatusBar *statusBar;
+
+ void setupUi(QMainWindow *MainWindow)
+ {
+ if (MainWindow->objectName().isEmpty())
+ MainWindow->setObjectName(QString::fromUtf8("MainWindow"));
+ MainWindow->resize(524, 496);
+ centralWidget = new QWidget(MainWindow);
+ centralWidget->setObjectName(QString::fromUtf8("centralWidget"));
+ widget = new QWidget(centralWidget);
+ widget->setObjectName(QString::fromUtf8("widget"));
+ widget->setGeometry(QRect(110, 15, 181, 421));
+ QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
+ sizePolicy.setHorizontalStretch(10);
+ sizePolicy.setVerticalStretch(0);
+ sizePolicy.setHeightForWidth(widget->sizePolicy().hasHeightForWidth());
+ widget->setSizePolicy(sizePolicy);
+ widget->setMaximumSize(QSize(181, 16777215));
+ verticalLayout_4 = new QVBoxLayout(widget);
+ verticalLayout_4->setSpacing(0);
+ verticalLayout_4->setContentsMargins(0, 0, 0, 0);
+ verticalLayout_4->setObjectName(QString::fromUtf8("verticalLayout_4"));
+ verticalLayout_3 = new QVBoxLayout();
+ verticalLayout_3->setSpacing(6);
+ verticalLayout_3->setObjectName(QString::fromUtf8("verticalLayout_3"));
+ groupBox_5 = new QGroupBox(widget);
+ groupBox_5->setObjectName(QString::fromUtf8("groupBox_5"));
+ verticalLayout_8 = new QVBoxLayout(groupBox_5);
+ verticalLayout_8->setSpacing(6);
+ verticalLayout_8->setContentsMargins(11, 11, 11, 11);
+ verticalLayout_8->setObjectName(QString::fromUtf8("verticalLayout_8"));
+ comboBox = new QComboBox(groupBox_5);
+ comboBox->setObjectName(QString::fromUtf8("comboBox"));
+
+ verticalLayout_8->addWidget(comboBox);
+
+ pushButton_2 = new QPushButton(groupBox_5);
+ pushButton_2->setObjectName(QString::fromUtf8("pushButton_2"));
+
+ verticalLayout_8->addWidget(pushButton_2);
+
+
+ verticalLayout_3->addWidget(groupBox_5);
+
+ groupBox = new QGroupBox(widget);
+ groupBox->setObjectName(QString::fromUtf8("groupBox"));
+ verticalLayout_6 = new QVBoxLayout(groupBox);
+ verticalLayout_6->setSpacing(6);
+ verticalLayout_6->setContentsMargins(11, 11, 11, 11);
+ verticalLayout_6->setObjectName(QString::fromUtf8("verticalLayout_6"));
+ verticalLayout_5 = new QVBoxLayout();
+ verticalLayout_5->setSpacing(6);
+ verticalLayout_5->setObjectName(QString::fromUtf8("verticalLayout_5"));
+ lineEdit = new QLineEdit(groupBox);
+ lineEdit->setObjectName(QString::fromUtf8("lineEdit"));
+
+ verticalLayout_5->addWidget(lineEdit);
+
+ pushButtonGO = new QPushButton(groupBox);
+ pushButtonGO->setObjectName(QString::fromUtf8("pushButtonGO"));
+
+ verticalLayout_5->addWidget(pushButtonGO);
+
+
+ verticalLayout_6->addLayout(verticalLayout_5);
+
+ label = new QLabel(groupBox);
+ label->setObjectName(QString::fromUtf8("label"));
+
+ verticalLayout_6->addWidget(label);
+
+
+ verticalLayout_3->addWidget(groupBox);
+
+ groupBox_2 = new QGroupBox(widget);
+ groupBox_2->setObjectName(QString::fromUtf8("groupBox_2"));
+ horizontalLayout = new QHBoxLayout(groupBox_2);
+ horizontalLayout->setSpacing(6);
+ horizontalLayout->setContentsMargins(11, 11, 11, 11);
+ horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
+ pushButtonRL = new QPushButton(groupBox_2);
+ pushButtonRL->setObjectName(QString::fromUtf8("pushButtonRL"));
+
+ horizontalLayout->addWidget(pushButtonRL);
+
+ pushButtonRC = new QPushButton(groupBox_2);
+ pushButtonRC->setObjectName(QString::fromUtf8("pushButtonRC"));
+
+ horizontalLayout->addWidget(pushButtonRC);
+
+ pushButtonRR = new QPushButton(groupBox_2);
+ pushButtonRR->setObjectName(QString::fromUtf8("pushButtonRR"));
+
+ horizontalLayout->addWidget(pushButtonRR);
+
+
+ verticalLayout_3->addWidget(groupBox_2);
+
+ groupBox_3 = new QGroupBox(widget);
+ groupBox_3->setObjectName(QString::fromUtf8("groupBox_3"));
+ verticalLayout = new QVBoxLayout(groupBox_3);
+ verticalLayout->setSpacing(6);
+ verticalLayout->setContentsMargins(11, 11, 11, 11);
+ verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
+ horizontalLayout_3 = new QHBoxLayout();
+ horizontalLayout_3->setSpacing(6);
+ horizontalLayout_3->setObjectName(QString::fromUtf8("horizontalLayout_3"));
+ pushButtonZoomP = new QPushButton(groupBox_3);
+ pushButtonZoomP->setObjectName(QString::fromUtf8("pushButtonZoomP"));
+
+ horizontalLayout_3->addWidget(pushButtonZoomP);
+
+ pushButtonZoomM = new QPushButton(groupBox_3);
+ pushButtonZoomM->setObjectName(QString::fromUtf8("pushButtonZoomM"));
+
+ horizontalLayout_3->addWidget(pushButtonZoomM);
+
+
+ verticalLayout->addLayout(horizontalLayout_3);
+
+ verticalLayout_2 = new QVBoxLayout();
+ verticalLayout_2->setSpacing(6);
+ verticalLayout_2->setObjectName(QString::fromUtf8("verticalLayout_2"));
+ label_4 = new QLabel(groupBox_3);
+ label_4->setObjectName(QString::fromUtf8("label_4"));
+ label_4->setAlignment(Qt::AlignCenter);
+
+ verticalLayout_2->addWidget(label_4);
+
+
+ verticalLayout->addLayout(verticalLayout_2);
+
+ doubleSpinBox = new QDoubleSpinBox(groupBox_3);
+ doubleSpinBox->setObjectName(QString::fromUtf8("doubleSpinBox"));
+ doubleSpinBox->setSingleStep(0.1);
+ doubleSpinBox->setValue(1);
+
+ verticalLayout->addWidget(doubleSpinBox);
+
+ label_5 = new QLabel(groupBox_3);
+ label_5->setObjectName(QString::fromUtf8("label_5"));
+ label_5->setAlignment(Qt::AlignCenter);
+
+ verticalLayout->addWidget(label_5);
+
+ groupBox_4 = new QGroupBox(groupBox_3);
+ groupBox_4->setObjectName(QString::fromUtf8("groupBox_4"));
+ verticalLayout_7 = new QVBoxLayout(groupBox_4);
+ verticalLayout_7->setSpacing(6);
+ verticalLayout_7->setContentsMargins(11, 11, 11, 11);
+ verticalLayout_7->setObjectName(QString::fromUtf8("verticalLayout_7"));
+ checkBox = new QCheckBox(groupBox_4);
+ checkBox->setObjectName(QString::fromUtf8("checkBox"));
+ checkBox->setChecked(true);
+
+ verticalLayout_7->addWidget(checkBox);
+
+ checkBox_2 = new QCheckBox(groupBox_4);
+ checkBox_2->setObjectName(QString::fromUtf8("checkBox_2"));
+
+ verticalLayout_7->addWidget(checkBox_2);
+
+ pushButton = new QPushButton(groupBox_4);
+ pushButton->setObjectName(QString::fromUtf8("pushButton"));
+
+ verticalLayout_7->addWidget(pushButton);
+
+
+ verticalLayout->addWidget(groupBox_4);
+
+
+ verticalLayout_3->addWidget(groupBox_3);
+
+
+ verticalLayout_4->addLayout(verticalLayout_3);
+
+ MainWindow->setCentralWidget(centralWidget);
+ menuBar = new QMenuBar(MainWindow);
+ menuBar->setObjectName(QString::fromUtf8("menuBar"));
+ menuBar->setGeometry(QRect(0, 0, 524, 21));
+ MainWindow->setMenuBar(menuBar);
+ mainToolBar = new QToolBar(MainWindow);
+ mainToolBar->setObjectName(QString::fromUtf8("mainToolBar"));
+ MainWindow->addToolBar(Qt::TopToolBarArea, mainToolBar);
+ statusBar = new QStatusBar(MainWindow);
+ statusBar->setObjectName(QString::fromUtf8("statusBar"));
+ MainWindow->setStatusBar(statusBar);
+
+ retranslateUi(MainWindow);
+
+ QMetaObject::connectSlotsByName(MainWindow);
+ } // setupUi
+
+ void retranslateUi(QMainWindow *MainWindow)
+ {
+ MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0, QApplication::UnicodeUTF8));
+ groupBox_5->setTitle(QApplication::translate("MainWindow", "MapType", 0, QApplication::UnicodeUTF8));
+ pushButton_2->setText(QApplication::translate("MainWindow", "PushButton", 0, QApplication::UnicodeUTF8));
+ groupBox->setTitle(QApplication::translate("MainWindow", "Goto Place", 0, QApplication::UnicodeUTF8));
+ pushButtonGO->setText(QApplication::translate("MainWindow", "GO", 0, QApplication::UnicodeUTF8));
+ label->setText(QApplication::translate("MainWindow", "GeoCoderStatusCode", 0, QApplication::UnicodeUTF8));
+ groupBox_2->setTitle(QApplication::translate("MainWindow", "Rotate", 0, QApplication::UnicodeUTF8));
+ pushButtonRL->setText(QApplication::translate("MainWindow", "Left", 0, QApplication::UnicodeUTF8));
+ pushButtonRC->setText(QApplication::translate("MainWindow", "Center", 0, QApplication::UnicodeUTF8));
+ pushButtonRR->setText(QApplication::translate("MainWindow", "Right", 0, QApplication::UnicodeUTF8));
+ groupBox_3->setTitle(QApplication::translate("MainWindow", "Zoom", 0, QApplication::UnicodeUTF8));
+ pushButtonZoomP->setText(QApplication::translate("MainWindow", "+", 0, QApplication::UnicodeUTF8));
+ pushButtonZoomM->setText(QApplication::translate("MainWindow", "-", 0, QApplication::UnicodeUTF8));
+ label_4->setText(QApplication::translate("MainWindow", "ZoomIncrement", 0, QApplication::UnicodeUTF8));
+ label_5->setText(QApplication::translate("MainWindow", "CurrentZoom=", 0, QApplication::UnicodeUTF8));
+ groupBox_4->setTitle(QApplication::translate("MainWindow", "Misc", 0, QApplication::UnicodeUTF8));
+ checkBox->setText(QApplication::translate("MainWindow", "ShowGridLines", 0, QApplication::UnicodeUTF8));
+ checkBox_2->setText(QApplication::translate("MainWindow", "UseOpenGL", 0, QApplication::UnicodeUTF8));
+ pushButton->setText(QApplication::translate("MainWindow", "ReloadMap", 0, QApplication::UnicodeUTF8));
+ } // retranslateUi
+
+};
+
+namespace Ui {
+ class MainWindow: public Ui_MainWindow {};
+} // namespace Ui
+
+QT_END_NAMESPACE
+
+#endif // UI_MAINWINDOW_H
diff --git a/ground/src/libs/opmapcontrol/src/internals/MouseWheelZoomType.cpp b/ground/src/libs/opmapcontrol/src/internals/MouseWheelZoomType.cpp
new file mode 100644
index 000000000..9240fafa2
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/MouseWheelZoomType.cpp
@@ -0,0 +1,34 @@
+/**
+******************************************************************************
+*
+* @file MouseWheelZoomType.cpp
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#include "mousewheelzoomtype.h"
+
+
+namespace internals {
+QStringList MouseWheelZoomType::strList=QStringList()<<"MousePositionAndCenter"<<"MousePositionWithoutCenter"<<"ViewCenter";
+
+}
diff --git a/ground/src/libs/opmapcontrol/src/internals/copyrightstrings.h b/ground/src/libs/opmapcontrol/src/internals/copyrightstrings.h
new file mode 100644
index 000000000..15c77c298
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/copyrightstrings.h
@@ -0,0 +1,42 @@
+/**
+******************************************************************************
+*
+* @file copyrightstrings.h
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#ifndef COPYRIGHTSTRINGS_H
+#define COPYRIGHTSTRINGS_H
+
+#include
+#include
+
+namespace internals {
+static const QString googleCopyright = QString("©%1 Google - Map data ©%1 Tele Atlas, Imagery ©%1 TerraMetrics").arg(QDate::currentDate().year());
+static const QString openStreetMapCopyright = QString("© OpenStreetMap - Map data ©%1 OpenStreetMap").arg(QDate::currentDate().year());
+static const QString yahooMapCopyright = QString("© Yahoo! Inc. - Map data & Imagery ©%1 NAVTEQ").arg(QDate::currentDate().year());
+static const QString virtualEarthCopyright = QString("©%1 Microsoft Corporation, ©%1 NAVTEQ, ©%1 Image courtesy of NASA").arg(QDate::currentDate().year());
+static const QString arcGisCopyright = QString("©%1 ESRI - Map data ©%1 ArcGIS").arg(QDate::currentDate().year());
+
+}
+#endif // COPYRIGHTSTRINGS_H
diff --git a/ground/src/libs/opmapcontrol/src/internals/core.cpp b/ground/src/libs/opmapcontrol/src/internals/core.cpp
new file mode 100644
index 000000000..8b0b712df
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/core.cpp
@@ -0,0 +1,644 @@
+/**
+******************************************************************************
+*
+* @file core.cpp
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#include "core.h"
+
+#ifdef DEBUG_CORE
+qlonglong internals::Core::debugcounter=0;
+#endif
+
+using namespace projections;
+
+namespace internals {
+ Core::Core():currentPosition(0,0),currentPositionPixel(0,0),LastLocationInBounds(-1,-1),sizeOfMapArea(0,0)
+ ,minOfTiles(0,0),maxOfTiles(0,0),isDragging(false),started(false),MouseWheelZooming(false),TooltipTextPadding(10,10),zoom(0),loaderLimit(5)
+ {
+ mousewheelzoomtype=MouseWheelZoomType::MousePositionAndCenter;
+ SetProjection(new MercatorProjection());
+ this->setAutoDelete(false);
+ ProcessLoadTaskCallback.setMaxThreadCount(10);
+ renderOffset=Point(0,0);
+ dragPoint=Point(0,0);
+ CanDragMap=true;
+ }
+ void Core::run()
+ {
+#ifdef DEBUG_CORE
+ qlonglong debug;
+ Mdebug.lock();
+ debug=++debugcounter;
+ Mdebug.unlock();
+ qDebug()<<"core:run"<<" ID="< 0)
+ {
+ task = tileLoadQueue.dequeue();
+ {
+ last = tileLoadQueue.count() == 0;
+#ifdef DEBUG_CORE
+ qDebug()<<"TileLoadQueue: " << tileLoadQueue.count()<<" Point:"<GetPos().ToString()<<" now has "<Overlays.count()<<" overlays"<<" ID="<RetryLoadTile > 0)
+ {
+#ifdef DEBUG_CORE
+ qDebug()<<"ProcessLoadTask: " << task.ToString()<< " -> empty tile, retry " << retry<<" ID="<RetryLoadTile);
+ }
+
+ if(t->Overlays.count() > 0)
+ {
+ Matrix.SetTileAt(task.Pos,t);
+ emit OnNeedInvalidation();
+#ifdef DEBUG_CORE
+ qDebug()<<"Core::run add tile "<GetPos().ToString()<<" to matrix index "<Overlays.count()<<" ID="<kiberCacheLock.lockForWrite();
+ OPMaps::Instance()->TilesInMemory.RemoveMemoryOverload();
+ OPMaps::Instance()->kiberCacheLock.unlock();
+
+ MtileDrawingList.lock();
+ {
+ Matrix.ClearPointsNotIn(tileDrawingList);
+ }
+ MtileDrawingList.unlock();
+
+
+ emit OnTileLoadComplete();
+
+
+ emit OnNeedInvalidation();
+
+ }
+ }
+
+
+
+ }
+#ifdef DEBUG_CORE
+ qDebug()<<"loaderLimit release:"+loaderLimit.available()<<" ID="<GetTileMatrixMinXY(value);
+ maxOfTiles=Projection()->GetTileMatrixMaxXY(value);
+ currentPositionPixel=Projection()->FromLatLngToPixel(currentPosition,value);
+ if(started)
+ {
+ MtileLoadQueue.lock();
+ tileLoadQueue.clear();
+ MtileLoadQueue.unlock();
+ Matrix.Clear();
+ GoToCurrentPositionOnZoom();
+ UpdateBounds();
+ emit OnMapDrag();
+ emit OnMapZoomChanged();
+ emit OnNeedInvalidation();
+ }
+ }
+ }
+
+ void Core::SetCurrentPosition(const PointLatLng &value)
+ {
+ if(!IsDragging())
+ {
+ currentPosition = value;
+ SetCurrentPositionGPixel(Projection()->FromLatLngToPixel(value, Zoom()));
+
+ if(started)
+ {
+ GoToCurrentPosition();
+ emit OnCurrentPositionChanged(currentPosition);
+ }
+ }
+ else
+ {
+ currentPosition = value;
+ SetCurrentPositionGPixel(Projection()->FromLatLngToPixel(value, Zoom()));
+
+ if(started)
+ {
+ emit OnCurrentPositionChanged(currentPosition);
+ }
+ }
+ }
+ void Core::SetMapType(const MapType::Types &value)
+ {
+
+ if(value != GetMapType())
+ {
+ mapType = value;
+
+ switch(value)
+ {
+
+
+ case MapType::ArcGIS_Map:
+ case MapType::ArcGIS_Satellite:
+ case MapType::ArcGIS_ShadedRelief:
+ case MapType::ArcGIS_Terrain:
+ {
+ if(Projection()->Type()!="PlateCarreeProjection")
+ {
+ SetProjection(new PlateCarreeProjection());
+ }
+ }
+ break;
+
+ case MapType::ArcGIS_MapsLT_Map_Hybrid:
+ case MapType::ArcGIS_MapsLT_Map_Labels:
+ case MapType::ArcGIS_MapsLT_Map:
+ case MapType::ArcGIS_MapsLT_OrtoFoto:
+ {
+ if(Projection()->Type()!="LKS94Projection")
+ {
+ SetProjection(new LKS94Projection());
+ }
+ }
+ break;
+
+ case MapType::PergoTurkeyMap:
+ {
+ if(Projection()->Type()!="PlateCarreeProjectionPergo")
+ {
+ SetProjection(new PlateCarreeProjectionPergo());
+ }
+ }
+ break;
+
+ case MapType::YandexMapRu:
+ {
+ if(Projection()->Type()!="MercatorProjectionYandex")
+ {
+ SetProjection(new MercatorProjectionYandex());
+ }
+ }
+ break;
+
+ default:
+ {
+ if(Projection()->Type()!="MercatorProjection")
+ {
+ SetProjection(new MercatorProjection());
+ }
+ }
+ break;
+ }
+
+ minOfTiles = Projection()->GetTileMatrixMinXY(Zoom());
+ maxOfTiles = Projection()->GetTileMatrixMaxXY(Zoom());
+ SetCurrentPositionGPixel(Projection()->FromLatLngToPixel(CurrentPosition(), Zoom()));
+
+ if(started)
+ {
+ CancelAsyncTasks();
+ OnMapSizeChanged(Width, Height);
+ GoToCurrentPosition();
+ ReloadMap();
+ GoToCurrentPosition();
+ emit OnMapTypeChanged(value);
+
+ }
+ }
+
+ }
+ void Core::StartSystem()
+ {
+ if(!started)
+ {
+ started = true;
+
+ ReloadMap();
+ GoToCurrentPosition();
+ }
+ }
+
+ void Core::UpdateCenterTileXYLocation()
+ {
+ PointLatLng center = FromLocalToLatLng(Width/2, Height/2);
+ Point centerPixel = Projection()->FromLatLngToPixel(center, Zoom());
+ centerTileXYLocation = Projection()->FromPixelToTileXY(centerPixel);
+ }
+
+ void Core::OnMapSizeChanged(int const& width, int const& height)
+ {
+ Width = width;
+ Height = height;
+
+ sizeOfMapArea.SetWidth(1 + (Width/Projection()->TileSize().Width())/2);
+ sizeOfMapArea.SetHeight(1 + (Height/Projection()->TileSize().Height())/2);
+
+ UpdateCenterTileXYLocation();
+
+ if(started)
+ {
+ UpdateBounds();
+
+ emit OnCurrentPositionChanged(currentPosition);
+ }
+ }
+ void Core::OnMapClose()
+ {
+ // if(waitOnEmptyTasks != null)
+ // {
+ // try
+ // {
+ // waitOnEmptyTasks.Set();
+ // waitOnEmptyTasks.Close();
+ // }
+ // catch
+ // {
+ // }
+ // }
+
+ CancelAsyncTasks();
+ }
+ GeoCoderStatusCode::Types Core::SetCurrentPositionByKeywords(QString const& keys)
+ {
+ GeoCoderStatusCode::Types status = GeoCoderStatusCode::Unknow;
+ PointLatLng pos = OPMaps::Instance()->GetLatLngFromGeodecoder(keys, status);
+ if(!pos.IsEmpty() && (status == GeoCoderStatusCode::G_GEO_SUCCESS))
+ {
+ SetCurrentPosition(pos);
+ }
+
+ return status;
+ }
+ RectLatLng Core::CurrentViewArea()
+ {
+ PointLatLng p = Projection()->FromPixelToLatLng(-renderOffset.X(), -renderOffset.Y(), Zoom());
+ double rlng = Projection()->FromPixelToLatLng(-renderOffset.X() + Width, -renderOffset.Y(), Zoom()).Lng();
+ double blat = Projection()->FromPixelToLatLng(-renderOffset.X(), -renderOffset.Y() + Height, Zoom()).Lat();
+ return RectLatLng::FromLTRB(p.Lng(), p.Lat(), rlng, blat);
+
+ }
+ PointLatLng Core::FromLocalToLatLng(int const& x, int const& y)
+ {
+ return Projection()->FromPixelToLatLng(Point(x - renderOffset.X(), y - renderOffset.Y()), Zoom());
+ }
+
+
+ Point Core::FromLatLngToLocal(PointLatLng const& latlng)
+ {
+ Point pLocal = Projection()->FromLatLngToPixel(latlng, Zoom());
+ pLocal.Offset(renderOffset);
+ return pLocal;
+ }
+ int Core::GetMaxZoomToFitRect(RectLatLng const& rect)
+ {
+ int zoom = 0;
+
+ for(int i = 1; i <= OPMaps::Instance()->MaxZoom; i++)
+ {
+ Point p1 = Projection()->FromLatLngToPixel(rect.LocationTopLeft(), i);
+ Point p2 = Projection()->FromLatLngToPixel(rect.Bottom(), rect.Right(), i);
+
+ if(((p2.X() - p1.X()) <= Width+10) && (p2.Y() - p1.Y()) <= Height+10)
+ {
+ zoom = i;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ return zoom;
+ }
+ void Core::BeginDrag(Point const& pt)
+ {
+ dragPoint.SetX(pt.X() - renderOffset.X());
+ dragPoint.SetY(pt.Y() - renderOffset.Y());
+ isDragging = true;
+ }
+ void Core::EndDrag()
+ {
+ isDragging = false;
+ emit OnNeedInvalidation();
+
+ }
+ void Core::ReloadMap()
+ {
+ if(started)
+ {
+#ifdef DEBUG_CORE
+ qDebug()<<"------------------";
+#endif //DEBUG_CORE
+
+ MtileLoadQueue.lock();
+ {
+ tileLoadQueue.clear();
+ }
+ MtileLoadQueue.unlock();
+ Matrix.Clear();
+
+ emit OnNeedInvalidation();
+
+ }
+ }
+ void Core::GoToCurrentPosition()
+ {
+ // reset stuff
+ renderOffset = Point::Empty;
+ centerTileXYLocationLast = Point::Empty;
+ dragPoint = Point::Empty;
+
+ // goto location
+ Drag(Point(-(GetcurrentPositionGPixel().X() - Width/2), -(GetcurrentPositionGPixel().Y() - Height/2)));
+ }
+ void Core::GoToCurrentPositionOnZoom()
+ {
+ // reset stuff
+ renderOffset = Point::Empty;
+ centerTileXYLocationLast = Point::Empty;
+ dragPoint = Point::Empty;
+
+ // goto location and centering
+ if(MouseWheelZooming)
+ {
+ if(mousewheelzoomtype != MouseWheelZoomType::MousePositionWithoutCenter)
+ {
+ Point pt = Point(-(GetcurrentPositionGPixel().X() - Width/2), -(GetcurrentPositionGPixel().Y() - Height/2));
+ renderOffset.SetX(pt.X() - dragPoint.X());
+ renderOffset.SetY(pt.Y() - dragPoint.Y());
+ }
+ else // without centering
+ {
+ renderOffset.SetX(-GetcurrentPositionGPixel().X() - dragPoint.X());
+ renderOffset.SetY(-GetcurrentPositionGPixel().Y() - dragPoint.Y());
+ renderOffset.Offset(mouseLastZoom);
+ }
+ }
+ else // use current map center
+ {
+ mouseLastZoom = Point::Empty;
+
+ Point pt = Point(-(GetcurrentPositionGPixel().X() - Width/2), -(GetcurrentPositionGPixel().Y() - Height/2));
+ renderOffset.SetX(pt.X() - dragPoint.X());
+ renderOffset.SetY(pt.Y() - dragPoint.Y());
+ }
+
+ UpdateCenterTileXYLocation();
+ }
+ void Core::DragOffset(Point const& offset)
+ {
+ renderOffset.Offset(offset);
+
+ UpdateCenterTileXYLocation();
+
+ if(centerTileXYLocation != centerTileXYLocationLast)
+ {
+ centerTileXYLocationLast = centerTileXYLocation;
+ UpdateBounds();
+ }
+
+ {
+ LastLocationInBounds = CurrentPosition();
+ SetCurrentPosition (FromLocalToLatLng((int) Width/2, (int) Height/2));
+ }
+
+ emit OnNeedInvalidation();
+ emit OnMapDrag();
+ }
+ void Core::Drag(Point const& pt)
+ {
+ renderOffset.SetX(pt.X() - dragPoint.X());
+ renderOffset.SetY(pt.Y() - dragPoint.Y());
+
+ UpdateCenterTileXYLocation();
+
+ if(centerTileXYLocation != centerTileXYLocationLast)
+ {
+ centerTileXYLocationLast = centerTileXYLocation;
+ UpdateBounds();
+ }
+
+ if(IsDragging())
+ {
+ LastLocationInBounds = CurrentPosition();
+ SetCurrentPosition(FromLocalToLatLng((int) Width/2, (int) Height/2));
+ }
+
+ emit OnNeedInvalidation();
+
+
+ emit OnMapDrag();
+
+ }
+ void Core::CancelAsyncTasks()
+ {
+ if(started)
+ {
+ ProcessLoadTaskCallback.waitForDone();
+ MtileLoadQueue.lock();
+ {
+ tileLoadQueue.clear();
+ }
+ MtileLoadQueue.unlock();
+ // ProcessLoadTaskCallback.waitForDone();
+ }
+ }
+ void Core::UpdateBounds()
+ {
+ MtileDrawingList.lock();
+ {
+ FindTilesAround(tileDrawingList);
+
+#ifdef DEBUG_CORE
+ qDebug()<<"OnTileLoadStart: " << tileDrawingList.count() << " tiles to load at zoom " << Zoom() << ", time: " << QDateTime::currentDateTime().date();
+#endif //DEBUG_CORE
+
+ emit OnTileLoadStart();
+
+
+ foreach(Point p,tileDrawingList)
+ {
+ LoadTask task = LoadTask(p, Zoom());
+ {
+ MtileLoadQueue.lock();
+ {
+ if(!tileLoadQueue.contains(task))
+ {
+ tileLoadQueue.enqueue(task);
+#ifdef DEBUG_CORE
+ qDebug()<<"Core::UpdateBounds new Task"< &list)
+ {
+ list.clear();;
+ for(int i = -sizeOfMapArea.Width(); i <= sizeOfMapArea.Width(); i++)
+ {
+ for(int j = -sizeOfMapArea.Height(); j <= sizeOfMapArea.Height(); j++)
+ {
+ Point p = centerTileXYLocation;
+ p.SetX(p.X() + i);
+ p.SetY(p.Y() + j);
+
+ //if(p.X < minOfTiles.Width)
+ //{
+ // p.X += (maxOfTiles.Width + 1);
+ //}
+
+ //if(p.X > maxOfTiles.Width)
+ //{
+ // p.X -= (maxOfTiles.Width + 1);
+ //}
+
+ if(p.X() >= minOfTiles.Width() && p.Y() >= minOfTiles.Height() && p.X() <= maxOfTiles.Width() && p.Y() <= maxOfTiles.Height())
+ {
+ if(!list.contains(p))
+ {
+ list.append(p);
+ }
+ }
+ }
+ }
+
+
+ }
+ void Core::UpdateGroundResolution()
+ {
+ double rez = Projection()->GetGroundResolution(Zoom(), CurrentPosition().Lat());
+ pxRes100m = (int) (100.0 / rez); // 100 meters
+ pxRes1000m = (int) (1000.0 / rez); // 1km
+ pxRes10km = (int) (10000.0 / rez); // 10km
+ pxRes100km = (int) (100000.0 / rez); // 100km
+ pxRes1000km = (int) (1000000.0 / rez); // 1000km
+ pxRes5000km = (int) (5000000.0 / rez); // 5000km
+ }
+}
diff --git a/ground/src/libs/opmapcontrol/src/internals/core.h b/ground/src/libs/opmapcontrol/src/internals/core.h
new file mode 100644
index 000000000..6ee603006
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/core.h
@@ -0,0 +1,274 @@
+/**
+******************************************************************************
+*
+* @file core.h
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#ifndef CORE_H
+#define CORE_H
+
+#include "debugheader.h"
+
+#include "../internals/PointLatlng.h"
+#include "mousewheelzoomtype.h"
+#include "../core/size.h"
+#include "../core/maptype.h"
+#include "rectangle.h"
+#include "QThreadPool"
+#include "tilematrix.h"
+#include
+#include "loadtask.h"
+#include "copyrightstrings.h"
+#include "rectlatlng.h"
+#include "../internals/projections/lks94projection.h"
+#include "../internals/projections/mercatorprojection.h"
+#include "../internals/projections/mercatorprojectionyandex.h"
+#include "../internals/projections/platecarreeprojection.h"
+#include "../internals/projections/platecarreeprojectionpergo.h"
+#include "../core/geodecoderstatus.h"
+#include "../core/opmaps.h"
+#include
+#include
+#include
+
+#include
+
+namespace mapcontrol
+{
+ class OPMapControl;
+ class MapGraphicItem;
+}
+
+namespace internals {
+
+class Core:public QObject,public QRunnable
+{
+ Q_OBJECT
+
+ friend class mapcontrol::OPMapControl;
+ friend class mapcontrol::MapGraphicItem;
+public:
+ Core();
+ void run();
+ PointLatLng CurrentPosition()const{return currentPosition;};
+ void SetCurrentPosition(const PointLatLng &value);
+
+ Point GetcurrentPositionGPixel(){return currentPositionPixel;};
+ void SetcurrentPositionGPixel(const Point &value){currentPositionPixel=value;};
+
+ Point GetrenderOffset(){return renderOffset;};
+ void SetrenderOffset(const Point &value){renderOffset=value;};
+
+ Point GetcenterTileXYLocation(){return centerTileXYLocation;};
+ void SetcenterTileXYLocation(const Point &value){centerTileXYLocation=value;};
+
+ Point GetcenterTileXYLocationLast(){return centerTileXYLocationLast;};
+ void SetcenterTileXYLocationLast(const Point &value){centerTileXYLocationLast=value;};
+
+ Point GetdragPoint(){return dragPoint;};
+ void SetdragPoint(const Point &value){dragPoint=value;};
+
+ Point GetmouseDown(){return mouseDown;};
+ void SetmouseDown(const Point &value){mouseDown=value;};
+
+ Point GetmouseCurrent(){return mouseCurrent;};
+ void SetmouseCurrent(const Point &value){mouseCurrent=value;};
+
+ Point GetmouseLastZoom(){return mouseLastZoom;};
+ void SetmouseLastZoom(const Point &value){mouseLastZoom=value;};
+
+ MouseWheelZoomType::Types GetMouseWheelZoomType(){return mousewheelzoomtype;};
+ void SetMouseWheelZoomType(const MouseWheelZoomType::Types &value){mousewheelzoomtype=value;};
+
+ PointLatLng GetLastLocationInBounds(){return LastLocationInBounds;}
+ void SetLastLocationInBounds(const PointLatLng &value){LastLocationInBounds=value;}
+
+ Size GetsizeOfMapArea(){return sizeOfMapArea;}
+ void SetsizeOfMapArea(const Size &value){sizeOfMapArea=value;}
+
+ Size GetminOfTiles(){return minOfTiles;}
+ void SetminOfTiles(const Size &value){minOfTiles=value;}
+
+ Size GetmaxOfTiles(){return maxOfTiles;}
+ void SetmaxOfTiles(const Size &value){maxOfTiles=value;}
+
+ Rectangle GettileRect(){return tileRect;}
+ void SettileRect(const Rectangle &value){tileRect=value;}
+
+ Point GettilePoint(){return tilePoint;}
+ void SettilePoint(const Point &value){tilePoint=value;}
+
+ Rectangle GetCurrentRegion(){return CurrentRegion;}
+ void SetCurrentRegion(const Rectangle &value){CurrentRegion=value;}
+
+ QList tileDrawingList;
+
+ PureProjection* Projection()
+ {
+ return projection;
+ }
+ void SetProjection(PureProjection* value)
+ {
+ projection=value;
+ tileRect=Rectangle(Point(0,0),value->TileSize());
+ }
+ bool IsDragging()const{return isDragging;}
+
+ int Zoom()const{return zoom;}
+
+ void SetZoom(int const& value);
+
+
+ void UpdateBounds();
+
+ MapType::Types GetMapType(){return mapType;}
+ void SetMapType(MapType::Types const& value);
+
+ void StartSystem();
+
+ void UpdateCenterTileXYLocation();
+
+ void OnMapSizeChanged(int const& width, int const& height);//TODO had as slot
+
+ void OnMapClose();//TODO had as slot
+
+ GeoCoderStatusCode::Types SetCurrentPositionByKeywords(QString const& keys);
+
+ RectLatLng CurrentViewArea();
+
+ PointLatLng FromLocalToLatLng(int const& x, int const& y);
+
+
+ Point FromLatLngToLocal(PointLatLng const& latlng);
+
+ int GetMaxZoomToFitRect(RectLatLng const& rect);
+
+ void BeginDrag(Point const& pt);
+
+ void EndDrag();
+
+ void ReloadMap();
+
+ void GoToCurrentPosition();
+
+ bool MouseWheelZooming;
+
+ void DragOffset(Point const& offset);
+
+ void Drag(Point const& pt);
+
+ void CancelAsyncTasks();
+
+ void FindTilesAround(QList &list);
+
+ void UpdateGroundResolution();
+
+ TileMatrix Matrix;
+
+ bool isStarted(){return started;}
+
+
+signals:
+ void OnCurrentPositionChanged(PointLatLng point);
+ void OnTileLoadComplete();
+ void OnTileLoadStart();
+ void OnMapDrag();
+ void OnMapZoomChanged();
+ void OnMapTypeChanged(MapType::Types type);
+ void OnEmptyTileError(int zoom, Point pos);
+ void OnNeedInvalidation();
+
+private:
+
+
+ PointLatLng currentPosition;
+ Point currentPositionPixel;
+ Point renderOffset;
+ Point centerTileXYLocation;
+ Point centerTileXYLocationLast;
+ Point dragPoint;
+ Rectangle tileRect;
+ Point mouseDown;
+ bool CanDragMap;
+ Point mouseCurrent;
+ PointLatLng LastLocationInBounds;
+ Point mouseLastZoom;
+
+ MouseWheelZoomType::Types mousewheelzoomtype;
+
+
+ Size sizeOfMapArea;
+ Size minOfTiles;
+ Size maxOfTiles;
+
+
+
+ Point tilePoint;
+
+ Rectangle CurrentRegion;
+
+
+ QQueue tileLoadQueue;
+
+ int zoom;
+
+ PureProjection* projection;
+
+ bool isDragging;
+
+ QMutex MtileLoadQueue;
+
+ QMutex Moverlays;
+
+ QMutex MtileDrawingList;
+#ifdef DEBUG_CORE
+ QMutex Mdebug;
+ static qlonglong debugcounter;
+#endif
+ Size TooltipTextPadding;
+
+ MapType::Types mapType;
+
+ QSemaphore loaderLimit;
+
+ QThreadPool ProcessLoadTaskCallback;
+
+protected:
+ bool started;
+
+ int Width;
+ int Height;
+ int pxRes100m; // 100 meters
+ int pxRes1000m; // 1km
+ int pxRes10km; // 10km
+ int pxRes100km; // 100km
+ int pxRes1000km; // 1000km
+ int pxRes5000km; // 5000km
+ void SetCurrentPositionGPixel(Point const& value){currentPositionPixel = value;}
+ void GoToCurrentPositionOnZoom();
+
+};
+
+}
+#endif // CORE_H
diff --git a/ground/src/libs/opmapcontrol/src/internals/debugheader.h b/ground/src/libs/opmapcontrol/src/internals/debugheader.h
new file mode 100644
index 000000000..8e5bdba43
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/debugheader.h
@@ -0,0 +1,8 @@
+#ifndef DEBUGHEADER_H
+#define DEBUGHEADER_H
+
+//#define DEBUG_CORE
+//#define DEBUG_TILE
+//#define DEBUG_TILEMATRIX
+
+#endif // DEBUGHEADER_H
diff --git a/ground/src/libs/opmapcontrol/src/internals/internals.pro b/ground/src/libs/opmapcontrol/src/internals/internals.pro
new file mode 100644
index 000000000..21ce6b4b6
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/internals.pro
@@ -0,0 +1,35 @@
+include (../common.pri)
+HEADERS += core.h \
+ mousewheelzoomtype.h \
+ rectangle.h \
+ tile.h \
+ tilematrix.h \
+ loadtask.h \
+ copyrightstrings.h \
+ pureprojection.h \
+ pointlatlng.h \
+ rectlatlng.h \
+ sizelatlng.h \
+ debugheader.h
+SOURCES += core.cpp \
+ rectangle.cpp \
+ tile.cpp \
+ tilematrix.cpp \
+ pureprojection.cpp \
+ rectlatlng.cpp \
+ sizelatlng.cpp \
+ pointlatlng.cpp \
+ loadtask.cpp \
+ mousewheelzoomtype.cpp
+HEADERS += ./projections/lks94projection.h \
+ ./projections/mercatorprojection.h \
+ ./projections/mercatorprojectionyandex.h \
+ ./projections/platecarreeprojection.h \
+ ./projections/platecarreeprojectionpergo.h
+SOURCES += ./projections/lks94projection.cpp \
+ ./projections/mercatorprojection.cpp \
+ ./projections/mercatorprojectionyandex.cpp \
+ ./projections/platecarreeprojection.cpp \
+ ./projections/platecarreeprojectionpergo.cpp
+LIBS += -L../build \
+ -lcore
diff --git a/ground/src/libs/opmapcontrol/src/internals/loadtask.cpp b/ground/src/libs/opmapcontrol/src/internals/loadtask.cpp
new file mode 100644
index 000000000..3c92d2870
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/loadtask.cpp
@@ -0,0 +1,36 @@
+/**
+******************************************************************************
+*
+* @file loadtask.cpp
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#include "loadtask.h"
+
+
+namespace internals {
+bool operator==(LoadTask const& lhs,LoadTask const& rhs)
+{
+ return ((lhs.Pos==rhs.Pos)&&(lhs.Zoom==rhs.Zoom));
+}
+}
diff --git a/ground/src/libs/opmapcontrol/src/internals/loadtask.h b/ground/src/libs/opmapcontrol/src/internals/loadtask.h
new file mode 100644
index 000000000..7a09a565c
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/loadtask.h
@@ -0,0 +1,66 @@
+/**
+******************************************************************************
+*
+* @file loadtask.h
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#ifndef LOADTASK_H
+#define LOADTASK_H
+
+#include
+#include "../core/point.h"
+
+using namespace core;
+namespace internals
+{
+struct LoadTask
+ {
+ friend bool operator==(LoadTask const& lhs,LoadTask const& rhs);
+ public:
+ Point Pos;
+ int Zoom;
+
+
+ LoadTask(Point pos, int zoom)
+ {
+ Pos = pos;
+ Zoom = zoom;
+ }
+ LoadTask()
+ {
+ Pos=Point(-1,-1);
+ Zoom=-1;
+ }
+ bool HasValue()
+ {
+ return !(Zoom==-1);
+ }
+
+ QString ToString()const
+ {
+ return QString::number(Zoom) + " - " + Pos.ToString();
+ }
+ };
+}
+#endif // LOADTASK_H
diff --git a/ground/src/libs/opmapcontrol/src/internals/mousewheelzoomtype.h b/ground/src/libs/opmapcontrol/src/internals/mousewheelzoomtype.h
new file mode 100644
index 000000000..9d993291b
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/mousewheelzoomtype.h
@@ -0,0 +1,67 @@
+/**
+******************************************************************************
+*
+* @file mousewheelzoomtype.h
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#ifndef MOUSEWHEELZOOMTYPE_H
+#define MOUSEWHEELZOOMTYPE_H
+#include
+#include
+#include
+
+namespace internals {
+ struct MouseWheelZoomType:public QObject
+{
+ Q_OBJECT
+public:
+ enum Types
+ {
+ ///
+ /// zooms map to current mouse position and makes it map center
+ ///
+ MousePositionAndCenter,
+
+ ///
+ /// zooms to current mouse position, but doesn't make it map center,
+ /// google/bing style ;}
+ ///
+ MousePositionWithoutCenter,
+
+ ///
+ /// zooms map to current view center
+ ///
+ ViewCenter,
+ };
+ Q_ENUMS(Types)
+ static QStringList TypesStrList(){return strList;}
+ static Types TypeByStr(QString const& value){return (Types)MouseWheelZoomType::strList.indexOf(value);}
+private:
+ static QStringList strList;
+};
+
+}
+Q_DECLARE_METATYPE(internals::MouseWheelZoomType::Types)
+#endif // MOUSEWHEELZOOMTYPE_H
+
diff --git a/ground/src/libs/opmapcontrol/src/internals/pointlatlng.cpp b/ground/src/libs/opmapcontrol/src/internals/pointlatlng.cpp
new file mode 100644
index 000000000..f63f1e361
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/pointlatlng.cpp
@@ -0,0 +1,56 @@
+/**
+******************************************************************************
+*
+* @file pointlatlng.cpp
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#include "pointlatlng.h"
+
+
+namespace internals {
+PointLatLng PointLatLng::Empty=PointLatLng();
+PointLatLng::PointLatLng():lat(0),lng(0),empty(true)
+{
+
+}
+
+bool operator==(PointLatLng const& lhs,PointLatLng const& rhs)
+{
+ return ((lhs.Lng() == rhs.Lng()) && (lhs.Lat() == rhs.Lat()));
+}
+
+bool operator!=(PointLatLng const& left, PointLatLng const& right)
+{
+ return !(left == right);
+}
+PointLatLng operator+(PointLatLng pt, SizeLatLng sz)
+{
+ return PointLatLng::Add(pt, sz);
+}
+
+PointLatLng operator-(PointLatLng pt, SizeLatLng sz)
+{
+ return PointLatLng::Subtract(pt, sz);
+}
+}
diff --git a/ground/src/libs/opmapcontrol/src/internals/pointlatlng.h b/ground/src/libs/opmapcontrol/src/internals/pointlatlng.h
new file mode 100644
index 000000000..cb926fc5b
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/pointlatlng.h
@@ -0,0 +1,131 @@
+/**
+******************************************************************************
+*
+* @file pointlatlng.h
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#ifndef POINTLATLNG_H
+#define POINTLATLNG_H
+
+#include
+#include
+#include "sizelatlng.h"
+
+namespace internals {
+struct PointLatLng
+{
+ //friend uint qHash(PointLatLng const& point);
+ friend bool operator==(PointLatLng const& lhs,PointLatLng const& rhs);
+ friend bool operator!=(PointLatLng const& left, PointLatLng const& right);
+ friend PointLatLng operator+(PointLatLng pt, SizeLatLng sz);
+ friend PointLatLng operator-(PointLatLng pt, SizeLatLng sz);
+
+ //TODO Sizelatlng friend PointLatLng operator+(PointLatLng pt, SizeLatLng sz);
+
+ private:
+ double lat;
+ double lng;
+ bool empty;
+ public:
+ PointLatLng();
+
+
+ static PointLatLng Empty;
+
+ PointLatLng(const double &lat,const double &lng)
+ {
+ this->lat = lat;
+ this->lng = lng;
+ empty=false;
+ }
+
+ bool IsEmpty()
+ {
+ return empty;
+ }
+
+ double Lat()const
+ {
+ return this->lat;
+ }
+
+ void SetLat(const double &value)
+ {
+ this->lat = value;
+ empty=false;
+ }
+
+
+ double Lng()const
+ {
+ return this->lng;
+ }
+ void SetLng(const double &value)
+ {
+ this->lng = value;
+ empty=false;
+ }
+
+
+
+
+
+ static PointLatLng Add(PointLatLng const& pt, SizeLatLng const& sz)
+ {
+ return PointLatLng(pt.Lat() - sz.HeightLat(), pt.Lng() + sz.WidthLng());
+ }
+
+ static PointLatLng Subtract(PointLatLng const& pt, SizeLatLng const& sz)
+ {
+ return PointLatLng(pt.Lat() + sz.HeightLat(), pt.Lng() - sz.WidthLng());
+ }
+
+
+ void Offset(PointLatLng const& pos)
+ {
+ this->Offset(pos.Lat(), pos.Lng());
+ }
+
+ void Offset(double const& lat, double const& lng)
+ {
+ this->lng += lng;
+ this->lat -= lat;
+ }
+
+
+ QString ToString()const
+ {
+ return QString("{Lat=%1, Lng=%2}").arg(this->lat).arg(this->lng);
+ }
+
+//// static PointLatLng()
+//// {
+//// Empty = new PointLatLng();
+//// }
+ };
+
+
+//
+}
+#endif // POINTLATLNG_H
diff --git a/ground/src/libs/opmapcontrol/src/internals/projections/lks94projection.cpp b/ground/src/libs/opmapcontrol/src/internals/projections/lks94projection.cpp
new file mode 100644
index 000000000..a15e94cb6
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/projections/lks94projection.cpp
@@ -0,0 +1,787 @@
+/**
+******************************************************************************
+*
+* @file lks94projection.cpp
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#include "lks94projection.h"
+
+
+
+namespace projections {
+LKS94Projection::LKS94Projection():MinLatitude (53.33 ), MaxLatitude (56.55 ), MinLongitude (20.22 ),
+MaxLongitude (27.11 ), orignX (5122000 ), orignY (10000100 ),tileSize(256, 256)
+{
+}
+
+Size LKS94Projection::TileSize() const
+{
+ return tileSize;
+}
+double LKS94Projection::Axis() const
+{
+ return 6378137;
+}
+double LKS94Projection::Flattening() const
+{
+
+ return (1.0 / 298.257222101);
+
+}
+
+Point LKS94Projection::FromLatLngToPixel(double lat, double lng, int const& zoom)
+{
+ Point ret;
+
+ lat = Clip(lat, MinLatitude, MaxLatitude);
+ lng = Clip(lng, MinLongitude, MaxLongitude);
+ QVector lks(3);
+ lks[0]=lng;
+ lks[1]=lat;
+ lks = DTM10(lks);
+ lks = MTD10(lks);
+ lks = DTM00(lks);
+
+ double res = GetTileMatrixResolution(zoom);
+
+ ret.SetX((int) floor((lks[0] + orignX) / res));
+ ret.SetY((int) floor((orignY - lks[1]) / res));
+
+ return ret;
+}
+
+PointLatLng LKS94Projection::FromPixelToLatLng(int const& x, int const& y, int const& zoom)
+{
+ PointLatLng ret;// = PointLatLng::Empty;
+
+ double res = GetTileMatrixResolution(zoom);
+
+ QVector lks(2);
+ lks[0]=(x * res) - orignX;
+ lks[1]=-(y * res) + orignY;
+ lks = MTD11(lks);
+ lks = DTM10(lks);
+ lks = MTD10(lks);
+ ret.SetLat(Clip(lks[1], MinLatitude, MaxLatitude));
+ ret.SetLng(Clip(lks[0], MinLongitude, MaxLongitude));
+ return ret;
+}
+
+QVector LKS94Projection::DTM10(const QVector & lonlat)
+{
+ double es; // Eccentricity squared : (a^2 - b^2)/a^2
+ double semiMajor = 6378137.0; // major axis
+ double semiMinor = 6356752.3142451793; // minor axis
+ double ab; // Semi_major / semi_minor
+ double ba; // Semi_minor / semi_major
+ double ses; // Second eccentricity squared : (a^2 - b^2)/b^2
+
+ es = 1.0 - (semiMinor * semiMinor) / (semiMajor * semiMajor); //e^2
+ ses = (pow(semiMajor, 2) - pow(semiMinor, 2)) / pow(semiMinor, 2);
+ ba = semiMinor / semiMajor;
+ ab = semiMajor / semiMinor;
+
+ // ...
+
+ double lon = DegreesToRadians(lonlat[0]);
+ double lat = DegreesToRadians(lonlat[1]);
+ double h = lonlat.count() < 3 ? 0 : std::isnan(lonlat[2]) ? 0 : lonlat[2];//TODO NAN
+ double v = semiMajor / sqrt(1 - es * pow(sin(lat), 2));
+ double x = (v + h) * cos(lat) * cos(lon);
+ double y = (v + h) * cos(lat) * sin(lon);
+ double z = ((1 - es) * v + h) * sin(lat);
+ QVector ret(3);
+ ret[0]=x;
+ ret[1]=y;
+ ret[2]=z;
+ return ret;
+}
+QVector LKS94Projection::MTD10(QVector & pnt)
+{
+ QVector ret(3);
+ const double COS_67P5 = 0.38268343236508977; // cosine of 67.5 degrees
+ const double AD_C = 1.0026000; // Toms region 1 constant
+
+ double es; // Eccentricity squared : (a^2 - b^2)/a^2
+ double semiMajor = 6378137.0; // major axis
+ double semiMinor = 6356752.3141403561; // minor axis
+ double ab; // Semi_major / semi_minor
+ double ba; // Semi_minor / semi_major
+ double ses; // Second eccentricity squared : (a^2 - b^2)/b^2
+
+ es = 1.0 - (semiMinor * semiMinor) / (semiMajor * semiMajor); //e^2
+ ses = (pow(semiMajor, 2) - pow(semiMinor, 2)) / pow(semiMinor, 2);
+ ba = semiMinor / semiMajor;
+ ab = semiMajor / semiMinor;
+
+ // ...
+
+ bool AtPole = false; // is location in polar region
+ double Z = pnt.count() < 3 ? 0 : std::isnan(pnt[2]) ? 0 : pnt[2];//TODO NaN
+
+ double lon = 0;
+ double lat = 0;
+ double Height = 0;
+ if(pnt[0] != 0.0)
+ {
+ lon = atan2(pnt[1], pnt[0]);
+ }
+ else
+ {
+ if(pnt[1] > 0)
+ {
+ lon = M_PI / 2;
+ }
+ else
+ if(pnt[1] < 0)
+ {
+ lon = -M_PI * 0.5;
+ }
+ else
+ {
+ AtPole = true;
+ lon = 0.0;
+ if(Z > 0.0) // north pole
+ {
+ lat = M_PI * 0.5;
+ }
+ else
+ if(Z < 0.0) // south pole
+ {
+ lat = -M_PI * 0.5;
+ }
+ else // center of earth
+ {
+ ret[0]=RadiansToDegrees(lon);
+ ret[1]=RadiansToDegrees(M_PI * 0.5);
+ ret[2]=-semiMinor;
+ return ret;
+ }
+ }
+ }
+ double W2 = pnt[0] * pnt[0] + pnt[1] * pnt[1]; // Square of distance from Z axis
+ double W = sqrt(W2); // distance from Z axis
+ double T0 = Z * AD_C; // initial estimate of vertical component
+ double S0 = sqrt(T0 * T0 + W2); // initial estimate of horizontal component
+ double Sin_B0 = T0 / S0; // sin(B0), B0 is estimate of Bowring aux variable
+ double Cos_B0 = W / S0; // cos(B0)
+ double Sin3_B0 = pow(Sin_B0, 3);
+ double T1 = Z + semiMinor * ses * Sin3_B0; // corrected estimate of vertical component
+ double Sum = W - semiMajor * es * Cos_B0 * Cos_B0 * Cos_B0; // numerator of cos(phi1)
+ double S1 = sqrt(T1 * T1 + Sum * Sum); // corrected estimate of horizontal component
+ double Sin_p1 = T1 / S1; // sin(phi1), phi1 is estimated latitude
+ double Cos_p1 = Sum / S1; // cos(phi1)
+ double Rn = semiMajor / sqrt(1.0 - es * Sin_p1 * Sin_p1); // Earth radius at location
+ if(Cos_p1 >= COS_67P5)
+ {
+ Height = W / Cos_p1 - Rn;
+ }
+ else
+ if(Cos_p1 <= -COS_67P5)
+ {
+ Height = W / -Cos_p1 - Rn;
+ }
+ else
+ {
+ Height = Z / Sin_p1 + Rn * (es - 1.0);
+ }
+
+ if(!AtPole)
+ {
+ lat = atan(Sin_p1 / Cos_p1);
+ }
+ ret[0]=RadiansToDegrees(lon);
+ ret[1]=RadiansToDegrees(lat);
+ ret[2]=Height;
+ return ret;
+}
+QVector LKS94Projection::DTM00(QVector & lonlat)
+{
+ double scaleFactor = 0.9998; // scale factor
+ double centralMeridian = 0.41887902047863912; // Center qlonglongitude (projection center) */
+ double latOrigin = 0.0; // center latitude
+ double falseNorthing = 0.0; // y offset in meters
+ double falseEasting = 500000.0; // x offset in meters
+ double semiMajor = 6378137.0; // major axis
+ double semiMinor = 6356752.3141403561; // minor axis
+ double metersPerUnit = 1.0;
+
+ double e0, e1, e2, e3; // eccentricity constants
+ double e, es, esp; // eccentricity constants
+ double ml0; // small value m
+
+ es = 1.0 - pow(semiMinor / semiMajor, 2);
+ e = sqrt(es);
+ e0 = e0fn(es);
+ e1 = e1fn(es);
+ e2 = e2fn(es);
+ e3 = e3fn(es);
+ ml0 = semiMajor * mlfn(e0, e1, e2, e3, latOrigin);
+ esp = es / (1.0 - es);
+
+ // ...
+
+ double lon = DegreesToRadians(lonlat[0]);
+ double lat = DegreesToRadians(lonlat[1]);
+
+ double delta_lon = 0.0; // Delta qlonglongitude (Given qlonglongitude - center)
+ double sin_phi, cos_phi; // sin and cos value
+ double al, als; // temporary values
+ double c, t, tq; // temporary values
+ double con, n, ml; // cone constant, small m
+
+ delta_lon = LKS94Projection::AdjustLongitude(lon - centralMeridian);
+ LKS94Projection::SinCos(lat, sin_phi, cos_phi);
+
+ al = cos_phi * delta_lon;
+ als = pow(al, 2);
+ c = pow(cos_phi, 2);
+ tq = tan(lat);
+ t = pow(tq, 2);
+ con = 1.0 - es * pow(sin_phi, 2);
+ n = semiMajor / sqrt(con);
+ ml = semiMajor * mlfn(e0, e1, e2, e3, lat);
+
+ double x = scaleFactor * n * al * (1.0 + als / 6.0 * (1.0 - t + c + als / 20.0 *
+ (5.0 - 18.0 * t + pow(t, 2) + 72.0 * c - 58.0 * esp))) + falseEasting;
+
+ double y = scaleFactor * (ml - ml0 + n * tq * (als * (0.5 + als / 24.0 *
+ (5.0 - t + 9.0 * c + 4.0 * pow(c, 2) + als / 30.0 * (61.0 - 58.0 * t
+ + pow(t, 2) + 600.0 * c - 330.0 * esp))))) + falseNorthing;
+
+ if(lonlat.count() < 3)
+ {
+ QVector ret(2);
+ ret[0]= x / metersPerUnit;
+ ret[1]= y / metersPerUnit;
+ return ret;
+ }
+ else
+ {
+ QVector ret(3);
+ ret[0]= x / metersPerUnit;
+ ret[1]= y / metersPerUnit;
+ ret[2]=lonlat[2];
+ return ret;
+ }
+}
+
+QVector LKS94Projection::DTM01(QVector & lonlat)
+{
+ double es; // Eccentricity squared : (a^2 - b^2)/a^2
+ double semiMajor = 6378137.0; // major axis
+ double semiMinor = 6356752.3141403561; // minor axis
+ double ab; // Semi_major / semi_minor
+ double ba; // Semi_minor / semi_major
+ double ses; // Second eccentricity squared : (a^2 - b^2)/b^2
+
+ es = 1.0 - (semiMinor * semiMinor) / (semiMajor * semiMajor);
+ ses = (pow(semiMajor, 2) -pow(semiMinor, 2)) / pow(semiMinor, 2);
+ ba = semiMinor / semiMajor;
+ ab = semiMajor / semiMinor;
+
+ // ...
+
+ double lon = DegreesToRadians(lonlat[0]);
+ double lat = DegreesToRadians(lonlat[1]);
+ double h = lonlat.count() < 3 ? 0 : std::isnan(lonlat[2]) ? 0 : lonlat[2];//TODO NaN
+ double v = semiMajor / sqrt(1 - es * pow(sin(lat), 2));
+ double x = (v + h) * cos(lat) * cos(lon);
+ double y = (v + h) * cos(lat) * sin(lon);
+ double z = ((1 - es) * v + h) * sin(lat);
+ QVector ret(3);
+ ret[0]=x;
+ ret[1]=y;
+ ret[2]=z;
+ return ret;
+}
+QVector LKS94Projection::MTD01(QVector & pnt)
+{
+ const double COS_67P5 = 0.38268343236508977; // cosine of 67.5 degrees
+ const double AD_C = 1.0026000; // Toms region 1 constant
+
+ double es; // Eccentricity squared : (a^2 - b^2)/a^2
+ double semiMajor = 6378137.0; // major axis
+ double semiMinor = 6356752.3142451793; // minor axis
+ double ab; // Semi_major / semi_minor
+ double ba; // Semi_minor / semi_major
+ double ses; // Second eccentricity squared : (a^2 - b^2)/b^2
+
+ es = 1.0 - (semiMinor * semiMinor) / (semiMajor * semiMajor);
+ ses = (pow(semiMajor, 2) - pow(semiMinor, 2)) / pow(semiMinor, 2);
+ ba = semiMinor / semiMajor;
+ ab = semiMajor / semiMinor;
+
+ // ...
+
+ bool At_Pole = false; // is location in polar region
+ double Z = pnt.count() < 3 ? 0 : std::isnan(pnt[2]) ? 0 : pnt[2];//TODO NaN
+
+ double lon = 0;
+ double lat = 0;
+ double Height = 0;
+ if(pnt[0] != 0.0)
+ {
+ lon = atan2(pnt[1], pnt[0]);
+ }
+ else
+ {
+ if(pnt[1] > 0)
+ {
+ lon = M_PI / 2;
+ }
+ else
+ if(pnt[1] < 0)
+ {
+ lon = -M_PI * 0.5;
+ }
+ else
+ {
+ At_Pole = true;
+ lon = 0.0;
+ if(Z > 0.0) // north pole
+ {
+ lat = M_PI * 0.5;
+ }
+ else
+ if(Z < 0.0) // south pole
+ {
+ lat = -M_PI * 0.5;
+ }
+ else // center of earth
+ {
+ QVector ret(3);
+ ret[0]=RadiansToDegrees(lon);
+ ret[1]=RadiansToDegrees(M_PI * 0.5);
+ ret[2]=-semiMinor;
+ return ret;
+ }
+ }
+ }
+
+ double W2 = pnt[0] * pnt[0] + pnt[1] * pnt[1]; // Square of distance from Z axis
+ double W = sqrt(W2); // distance from Z axis
+ double T0 = Z * AD_C; // initial estimate of vertical component
+ double S0 = sqrt(T0 * T0 + W2); //initial estimate of horizontal component
+ double Sin_B0 = T0 / S0; // sin(B0), B0 is estimate of Bowring aux variable
+ double Cos_B0 = W / S0; // cos(B0)
+ double Sin3_B0 = pow(Sin_B0, 3);
+ double T1 = Z + semiMinor * ses * Sin3_B0; //corrected estimate of vertical component
+ double Sum = W - semiMajor * es * Cos_B0 * Cos_B0 * Cos_B0; // numerator of cos(phi1)
+ double S1 = sqrt(T1 * T1 + Sum * Sum); // corrected estimate of horizontal component
+ double Sin_p1 = T1 / S1; // sin(phi1), phi1 is estimated latitude
+ double Cos_p1 = Sum / S1; // cos(phi1)
+ double Rn = semiMajor / sqrt(1.0 - es * Sin_p1 * Sin_p1); // Earth radius at location
+
+ if(Cos_p1 >= COS_67P5)
+ {
+ Height = W / Cos_p1 - Rn;
+ }
+ else
+ if(Cos_p1 <= -COS_67P5)
+ {
+ Height = W / -Cos_p1 - Rn;
+ }
+ else
+ {
+ Height = Z / Sin_p1 + Rn * (es - 1.0);
+ }
+
+ if(!At_Pole)
+ {
+ lat = atan(Sin_p1 / Cos_p1);
+ }
+ QVector ret(3);
+ ret[0]=RadiansToDegrees(lon);
+ ret[1]=RadiansToDegrees(lat);
+ ret[2]=Height;
+ return ret;
+}
+QVector LKS94Projection::MTD11(QVector & p)
+{
+ double scaleFactor = 0.9998; // scale factor
+ double centralMeridian = 0.41887902047863912; // Center qlonglongitude (projection center)
+ double latOrigin = 0.0; // center latitude
+ double falseNorthing = 0.0; // y offset in meters
+ double falseEasting = 500000.0; // x offset in meters
+ double semiMajor = 6378137.0; // major axis
+ double semiMinor = 6356752.3141403561; // minor axis
+ double metersPerUnit = 1.0;
+
+ double e0, e1, e2, e3; // eccentricity constants
+ double e, es, esp; // eccentricity constants
+ double ml0; // small value m
+
+ es =(semiMinor * semiMinor) / (semiMajor * semiMajor);
+ es=1.0-es;
+ e = sqrt(es);
+ e0 = e0fn(es);
+ e1 = e1fn(es);
+ e2 = e2fn(es);
+ e3 = e3fn(es);
+ ml0 = semiMajor * mlfn(e0, e1, e2, e3, latOrigin);
+ esp = es / (1.0 - es);
+
+ // ...
+
+ double con, phi;
+ double delta_phi;
+ qlonglong i;
+ double sin_phi, cos_phi, tan_phi;
+ double c, cs, t, ts, n, r, d, ds;
+ qlonglong max_iter = 6;
+
+ double x = p[0] * metersPerUnit - falseEasting;
+ double y = p[1] * metersPerUnit - falseNorthing;
+
+ con = (ml0 + y / scaleFactor) / semiMajor;
+ phi = con;
+ for(i = 0; ; i++)
+ {
+ delta_phi = ((con + e1 * sin(2.0 * phi) - e2 * sin(4.0 * phi) + e3 * sin(6.0 * phi)) / e0) - phi;
+ phi += delta_phi;
+ if(fabs(delta_phi) <= EPSLoN)
+ break;
+
+ if(i >= max_iter)
+ throw "Latitude failed to converge";
+ }
+
+ if(fabs(phi) < HALF_PI)
+ {
+ SinCos(phi, sin_phi, cos_phi);
+ tan_phi = tan(phi);
+ c = esp * pow(cos_phi, 2);
+ cs = pow(c, 2);
+ t = pow(tan_phi, 2);
+ ts = pow(t, 2);
+ con = 1.0 - es * pow(sin_phi, 2);
+ n = semiMajor / sqrt(con);
+ r = n * (1.0 - es) / con;
+ d = x / (n * scaleFactor);
+ ds = pow(d, 2);
+
+ double lat = phi - (n * tan_phi * ds / r) * (0.5 - ds / 24.0 * (5.0 + 3.0 * t +
+ 10.0 * c - 4.0 * cs - 9.0 * esp - ds / 30.0 * (61.0 + 90.0 * t +
+ 298.0 * c + 45.0 * ts - 252.0 * esp - 3.0 * cs)));
+
+ double lon = AdjustLongitude(centralMeridian + (d * (1.0 - ds / 6.0 * (1.0 + 2.0 * t +
+ c - ds / 20.0 * (5.0 - 2.0 * c + 28.0 * t - 3.0 * cs + 8.0 * esp +
+ 24.0 * ts))) / cos_phi));
+
+ if(p.count() < 3)
+ {
+ QVector ret(2);
+ ret[0]= RadiansToDegrees(lon);
+ ret[1]= RadiansToDegrees(lat);
+ return ret;
+ }
+ else
+ {
+ QVector ret(3);
+ ret[0]= RadiansToDegrees(lon);
+ ret[1]= RadiansToDegrees(lat);
+ ret[2]=p[2];
+ return ret;
+ //return new double[] { RadiansToDegrees(lon), RadiansToDegrees(lat), p[2] };
+ }
+ }
+ else
+ {
+ if(p.count() < 3)
+ {
+ QVector ret(2);
+ ret[0]= RadiansToDegrees(HALF_PI * Sign(y));
+ ret[1]= RadiansToDegrees(centralMeridian);
+ return ret;
+ }
+
+ else
+ {
+ QVector ret(3);
+ ret[0]= RadiansToDegrees(HALF_PI * Sign(y));
+ ret[1]= RadiansToDegrees(centralMeridian);
+ ret[2]=p[2];
+ return ret;
+ }
+
+ }
+}
+
+double LKS94Projection::Clip(double const& n, double const& minValue, double const& maxValue)
+{
+ return qMin(qMax(n, minValue), maxValue);
+}
+double LKS94Projection::GetTileMatrixResolution(int const& zoom)
+{
+ double ret = 0;
+
+ switch(zoom)
+ {
+ case 0:
+ {
+ ret = 1587.50317500635;
+ }
+ break;
+
+ case 1:
+ {
+ ret = 793.751587503175;
+ }
+ break;
+
+ case 2:
+ {
+ ret = 529.167725002117;
+ }
+ break;
+
+ case 3:
+ {
+ ret = 264.583862501058;
+ }
+ break;
+
+ case 4:
+ {
+ ret = 132.291931250529;
+ }
+ break;
+
+ case 5:
+ {
+ ret = 52.9167725002117;
+ }
+ break;
+
+ case 6:
+ {
+ ret = 26.4583862501058;
+ }
+ break;
+
+ case 7:
+ {
+ ret = 13.2291931250529;
+ }
+ break;
+
+ case 8:
+ {
+ ret = 6.61459656252646;
+ }
+ break;
+
+ case 9:
+ {
+ ret = 2.64583862501058;
+ }
+ break;
+
+ case 10:
+ {
+ ret = 1.32291931250529;
+ }
+ break;
+
+ case 11:
+ {
+ ret = 0.529167725002117;
+ }
+ break;
+
+ }
+
+ return ret;
+}
+double LKS94Projection::GetGroundResolution(int const& zoom, double const& latitude)
+{
+ return GetTileMatrixResolution(zoom);
+}
+Size LKS94Projection::GetTileMatrixMinXY(int const& zoom)
+{
+ Size ret;
+
+ switch(zoom)
+ {
+
+ case 0:
+ {
+ ret = Size(12, 8);
+ }
+ break;
+
+ case 1:
+ {
+ ret = Size(24, 17);
+ }
+ break;
+
+ case 2:
+ {
+ ret = Size(37, 25);
+ }
+ break;
+
+ case 3:
+ {
+ ret = Size(74, 51);
+ }
+ break;
+
+ case 4:
+ {
+ ret = Size(149, 103);
+ }
+ break;
+
+ case 5:
+ {
+ ret = Size(374, 259);
+ }
+ break;
+
+ case 6:
+ {
+ ret = Size(749, 519);
+ }
+ break;
+
+ case 7:
+ {
+ ret = Size(1594, 1100);
+ }
+ break;
+
+ case 8:
+ {
+ ret = Size(3188, 2201);
+ }
+ break;
+
+ case 9:
+ {
+ ret = Size(7971, 5502);
+ }
+ break;
+
+ case 10:
+ {
+ ret = Size(15943, 11005);
+ }
+ break;
+
+ case 11:
+ {
+ ret = Size(39858, 27514);
+ }
+ break;
+ }
+
+ return ret;
+}
+
+Size LKS94Projection::GetTileMatrixMaxXY(int const& zoom)
+{
+ Size ret;
+
+ switch(zoom)
+ {
+ case 0:
+ {
+ ret = Size(14, 10);
+ }
+ break;
+
+ case 1:
+ {
+ ret = Size(30, 20);
+ }
+ break;
+
+ case 2:
+ {
+ ret = Size(45, 31);
+ }
+ break;
+
+ case 3:
+ {
+ ret = Size(90, 62);
+ }
+ break;
+
+ case 4:
+ {
+ ret = Size(181, 125);
+ }
+ break;
+
+ case 5:
+ {
+ ret = Size(454, 311);
+ }
+ break;
+
+ case 6:
+ {
+ ret = Size(903, 623);
+ }
+ break;
+
+ case 7:
+ {
+ ret = Size(1718, 1193);
+ }
+ break;
+
+ case 8:
+ {
+ ret = Size(3437, 2386);
+ }
+ break;
+
+ case 9:
+ {
+ ret = Size(8594, 5966);
+ }
+ break;
+
+ case 10:
+ {
+ ret = Size(17189, 11932);
+ }
+ break;
+
+ case 11:
+ {
+ ret = Size(42972, 29831);
+ }
+ break;
+ }
+
+ return ret;
+}
+
+}
diff --git a/ground/src/libs/opmapcontrol/src/internals/projections/lks94projection.h b/ground/src/libs/opmapcontrol/src/internals/projections/lks94projection.h
new file mode 100644
index 000000000..155b8d2e5
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/projections/lks94projection.h
@@ -0,0 +1,74 @@
+/**
+******************************************************************************
+*
+* @file lks94projection.h
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#ifndef LKS94PROJECTION_H
+#define LKS94PROJECTION_H
+#include
+#include "cmath"
+#include "../pureprojection.h"
+
+using namespace internals;
+
+namespace projections {
+class LKS94Projection:public internals::PureProjection
+{
+public:
+ LKS94Projection();
+ double GetTileMatrixResolution(int const& zoom);
+ virtual QString Type(){return "LKS94Projection";}
+ virtual Size TileSize() const;
+ virtual double Axis() const;
+ virtual double Flattening() const;
+ virtual Point FromLatLngToPixel(double lat, double lng, int const& zoom);
+ virtual PointLatLng FromPixelToLatLng(int const& x, int const& y, int const& zoom);
+ virtual double GetGroundResolution(int const& zoom, double const& latitude);
+ virtual Size GetTileMatrixMinXY(int const& zoom);
+ virtual Size GetTileMatrixMaxXY(int const& zoom);
+
+private:
+ const double MinLatitude;
+ const double MaxLatitude;
+ const double MinLongitude;
+ const double MaxLongitude;
+ const double orignX;
+ const double orignY;
+ Size tileSize;
+ QVector DTM10(const QVector & lonlat);
+ QVector MTD10(QVector & pnt);
+ QVector DTM00(QVector & lonlat);
+ QVector DTM01(QVector & lonlat);
+ QVector MTD01(QVector & pnt);
+ QVector MTD11(QVector & p);
+ double Clip(double const& n, double const& minValue, double const& maxValue);
+};
+
+}
+#endif // LKS94PROJECTION_H
+
+
+
+
diff --git a/ground/src/libs/opmapcontrol/src/internals/projections/mercatorprojection.cpp b/ground/src/libs/opmapcontrol/src/internals/projections/mercatorprojection.cpp
new file mode 100644
index 000000000..e7d8d56ee
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/projections/mercatorprojection.cpp
@@ -0,0 +1,97 @@
+/**
+******************************************************************************
+*
+* @file mercatorprojection.cpp
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#include "mercatorprojection.h"
+
+
+namespace projections {
+MercatorProjection::MercatorProjection():MinLatitude(-85.05112878), MaxLatitude(85.05112878),MinLongitude(-177),
+MaxLongitude(177), tileSize(256, 256)
+{
+}
+Point MercatorProjection::FromLatLngToPixel(double lat, double lng, const int &zoom)
+{
+ Point ret;// = Point.Empty;
+
+ lat = Clip(lat, MinLatitude, MaxLatitude);
+ lng = Clip(lng, MinLongitude, MaxLongitude);
+
+ double x = (lng + 180) / 360;
+ double sinLatitude = sin(lat * M_PI / 180);
+ double y = 0.5 - log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * M_PI);
+
+ Size s = GetTileMatrixSizePixel(zoom);
+ int mapSizeX = s.Width();
+ int mapSizeY = s.Height();
+
+ ret.SetX((int) Clip(x * mapSizeX + 0.5, 0, mapSizeX - 1));
+ ret.SetY((int) Clip(y * mapSizeY + 0.5, 0, mapSizeY - 1));
+
+ return ret;
+}
+PointLatLng MercatorProjection::FromPixelToLatLng(const int &x, const int &y, const int &zoom)
+{
+ PointLatLng ret;// = PointLatLng.Empty;
+
+ Size s = GetTileMatrixSizePixel(zoom);
+ double mapSizeX = s.Width();
+ double mapSizeY = s.Height();
+
+ double xx = (Clip(x, 0, mapSizeX - 1) / mapSizeX) - 0.5;
+ double yy = 0.5 - (Clip(y, 0, mapSizeY - 1) / mapSizeY);
+
+ ret.SetLat(90 - 360 * atan(exp(-yy * 2 * M_PI)) / M_PI);
+ ret.SetLng(360 * xx);
+
+ return ret;
+}
+double MercatorProjection::Clip(const double &n, const double &minValue, const double &maxValue) const
+{
+ return qMin(qMax(n, minValue), maxValue);
+}
+Size MercatorProjection::TileSize() const
+{
+ return tileSize;
+}
+double MercatorProjection::Axis() const
+{
+ return 6378137;
+}
+double MercatorProjection::Flattening() const
+{
+ return (1.0 / 298.257223563);
+}
+Size MercatorProjection::GetTileMatrixMaxXY(const int &zoom)
+{
+ int xy = (1 << zoom);
+ return Size(xy - 1, xy - 1);
+}
+Size MercatorProjection::GetTileMatrixMinXY(const int &zoom)
+{
+ return Size(0, 0);
+}
+}
diff --git a/ground/src/libs/opmapcontrol/src/internals/projections/mercatorprojection.h b/ground/src/libs/opmapcontrol/src/internals/projections/mercatorprojection.h
new file mode 100644
index 000000000..ce4c83a65
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/projections/mercatorprojection.h
@@ -0,0 +1,57 @@
+/**
+******************************************************************************
+*
+* @file mercatorprojection.h
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#ifndef MERCATORPROJECTION_H
+#define MERCATORPROJECTION_H
+#include "../pureprojection.h"
+
+using namespace internals;
+
+namespace projections {
+ class MercatorProjection:public internals::PureProjection
+{
+public:
+ MercatorProjection();
+ virtual QString Type(){return "MercatorProjection";}
+ virtual Size TileSize() const;
+ virtual double Axis() const;
+ virtual double Flattening()const;
+ virtual Point FromLatLngToPixel(double lat, double lng, int const& zoom);
+ virtual PointLatLng FromPixelToLatLng(const int &x,const int &y,const int &zoom);
+ virtual Size GetTileMatrixMinXY(const int &zoom);
+ virtual Size GetTileMatrixMaxXY(const int &zoom);
+private:
+ const double MinLatitude;
+ const double MaxLatitude;
+ const double MinLongitude;
+ const double MaxLongitude;
+ double Clip(double const& n, double const& minValue, double const& maxValue)const;
+ Size tileSize;
+};
+
+}
+#endif // MERCATORPROJECTION_H
diff --git a/ground/src/libs/opmapcontrol/src/internals/projections/mercatorprojectionyandex.cpp b/ground/src/libs/opmapcontrol/src/internals/projections/mercatorprojectionyandex.cpp
new file mode 100644
index 000000000..cb11bb657
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/projections/mercatorprojectionyandex.cpp
@@ -0,0 +1,112 @@
+/**
+******************************************************************************
+*
+* @file mercatorprojectionyandex.cpp
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#include "mercatorprojectionyandex.h"
+
+
+
+namespace projections {
+MercatorProjectionYandex::MercatorProjectionYandex():MinLatitude(-85.05112878), MaxLatitude(85.05112878),MinLongitude(-177),
+MaxLongitude(177), tileSize(256, 256),RAD_DEG(180 / M_PI),DEG_RAD(M_PI / 180), MathPiDiv4(M_PI / 4)
+{
+}
+Point MercatorProjectionYandex::FromLatLngToPixel(double lat, double lng, const int &zoom)
+{
+ lat = Clip(lat, MinLatitude, MaxLatitude);
+ lng = Clip(lng, MinLongitude, MaxLongitude);
+
+ double rLon = lng * DEG_RAD; // Math.PI / 180;
+ double rLat = lat * DEG_RAD; // Math.PI / 180;
+
+ double a = 6378137;
+ double k = 0.0818191908426;
+
+ double z = tan(MathPiDiv4 + rLat / 2) / pow((tan(MathPiDiv4 + asin(k * sin(rLat)) / 2)), k);
+ double z1 = pow(2, 23 - zoom);
+
+ double DX = ((20037508.342789 + a * rLon) * 53.5865938 / z1);
+ double DY = ((20037508.342789 - a * log(z)) * 53.5865938 / z1);
+
+ Point ret;// = Point.Empty;
+ ret.SetX((int) DX);
+ ret.SetY((int) DY);
+
+ return ret;
+
+}
+PointLatLng MercatorProjectionYandex::FromPixelToLatLng(const int &x, const int &y, const int &zoom)
+{
+ Size s = GetTileMatrixSizePixel(zoom);
+
+ double mapSizeX = s.Width();
+ double mapSizeY = s.Height();
+
+ double a = 6378137;
+ double c1 = 0.00335655146887969;
+ double c2 = 0.00000657187271079536;
+ double c3 = 0.00000001764564338702;
+ double c4 = 0.00000000005328478445;
+ double z1 = (23 - zoom);
+ double mercX = (x * pow(2, z1)) / 53.5865938 - 20037508.342789;
+ double mercY = 20037508.342789 - (y *pow(2, z1)) / 53.5865938;
+
+ double g = M_PI /2 - 2 *atan(1 / exp(mercY /a));
+ double z = g + c1 * sin(2 * g) + c2 * sin(4 * g) + c3 * sin(6 * g) + c4 * sin(8 * g);
+
+ PointLatLng ret;// = PointLatLng.Empty;
+ ret.SetLat(z * RAD_DEG);
+ ret.SetLng (mercX / a * RAD_DEG);
+
+ return ret;
+}
+double MercatorProjectionYandex::Clip(const double &n, const double &minValue, const double &maxValue) const
+{
+ return qMin(qMax(n, minValue), maxValue);
+}
+Size MercatorProjectionYandex::TileSize() const
+{
+ return tileSize;
+}
+double MercatorProjectionYandex::Axis() const
+{
+ return 6356752.3142;
+}
+double MercatorProjectionYandex::Flattening() const
+{
+ return (1.0 / 298.257223563);
+}
+Size MercatorProjectionYandex::GetTileMatrixMaxXY(const int &zoom)
+{
+ int xy = (1 << zoom);
+ return Size(xy - 1, xy - 1);
+}
+
+Size MercatorProjectionYandex::GetTileMatrixMinXY(const int &zoom)
+{
+ return Size(0, 0);
+}
+}
diff --git a/ground/src/libs/opmapcontrol/src/internals/projections/mercatorprojectionyandex.h b/ground/src/libs/opmapcontrol/src/internals/projections/mercatorprojectionyandex.h
new file mode 100644
index 000000000..606f1e65b
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/projections/mercatorprojectionyandex.h
@@ -0,0 +1,61 @@
+/**
+******************************************************************************
+*
+* @file mercatorprojectionyandex.h
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#ifndef MERCATORPROJECTIONYANDEX_H
+#define MERCATORPROJECTIONYANDEX_H
+
+#include "../pureprojection.h"
+
+using namespace internals;
+
+namespace projections {
+class MercatorProjectionYandex:public PureProjection
+{
+public:
+ MercatorProjectionYandex();
+ virtual QString Type(){return "MercatorProjectionYandex";}
+ virtual Size TileSize() const;
+ virtual double Axis() const;
+ virtual double Flattening()const;
+ virtual Point FromLatLngToPixel(double lat, double lng, int const& zoom);
+ virtual PointLatLng FromPixelToLatLng(const int &x,const int &y,const int &zoom);
+ virtual Size GetTileMatrixMinXY(const int &zoom);
+ virtual Size GetTileMatrixMaxXY(const int &zoom);
+private:
+ const double MinLatitude;
+ const double MaxLatitude;
+ const double MinLongitude;
+ const double MaxLongitude;
+ const double RAD_DEG;
+ const double DEG_RAD;
+ const double MathPiDiv4;
+ double Clip(double const& n, double const& minValue, double const& maxValue)const;
+ Size tileSize;
+};
+
+}
+#endif // MERCATORPROJECTIONYANDEX_H
diff --git a/ground/src/libs/opmapcontrol/src/internals/projections/platecarreeprojection.cpp b/ground/src/libs/opmapcontrol/src/internals/projections/platecarreeprojection.cpp
new file mode 100644
index 000000000..a5b56e16e
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/projections/platecarreeprojection.cpp
@@ -0,0 +1,97 @@
+/**
+******************************************************************************
+*
+* @file platecarreeprojection.cpp
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#include "platecarreeprojection.h"
+
+
+
+namespace projections {
+PlateCarreeProjection::PlateCarreeProjection():MinLatitude(-85.05112878), MaxLatitude(85.05112878),MinLongitude(-180),
+MaxLongitude(180), tileSize(512, 512)
+{
+}
+Point PlateCarreeProjection::FromLatLngToPixel(double lat, double lng, const int &zoom)
+{
+ Point ret;// = Point.Empty;
+
+ lat = Clip(lat, MinLatitude, MaxLatitude);
+ lng = Clip(lng, MinLongitude, MaxLongitude);
+
+ Size s = GetTileMatrixSizePixel(zoom);
+ double mapSizeX = s.Width();
+ double mapSizeY = s.Height();
+
+ double scale = 360.0 / mapSizeX;
+
+ ret.SetY((int) ((90.0 - lat) / scale));
+ ret.SetX((int) ((lng + 180.0) / scale));
+
+ return ret;
+
+}
+PointLatLng PlateCarreeProjection::FromPixelToLatLng(const int &x, const int &y, const int &zoom)
+{
+ PointLatLng ret;// = PointLatLng.Empty;
+
+ Size s = GetTileMatrixSizePixel(zoom);
+ double mapSizeX = s.Width();
+ double mapSizeY = s.Height();
+
+ double scale = 360.0 / mapSizeX;
+
+ ret.SetLat(90 - (y * scale));
+ ret.SetLng((x * scale) - 180);
+
+ return ret;
+}
+double PlateCarreeProjection::Clip(const double &n, const double &minValue, const double &maxValue) const
+{
+ return qMin(qMax(n, minValue), maxValue);
+}
+Size PlateCarreeProjection::TileSize() const
+{
+ return tileSize;
+}
+double PlateCarreeProjection::Axis() const
+{
+ return 6378137;
+}
+double PlateCarreeProjection::Flattening() const
+{
+ return (1.0 / 298.257223563);
+}
+Size PlateCarreeProjection::GetTileMatrixMaxXY(const int &zoom)
+{
+ int y = (int) pow(2, zoom);
+ return Size((2*y) - 1, y - 1);
+}
+
+Size PlateCarreeProjection::GetTileMatrixMinXY(const int &zoom)
+{
+ return Size(0, 0);
+}
+}
diff --git a/ground/src/libs/opmapcontrol/src/internals/projections/platecarreeprojection.h b/ground/src/libs/opmapcontrol/src/internals/projections/platecarreeprojection.h
new file mode 100644
index 000000000..61cb05cd4
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/projections/platecarreeprojection.h
@@ -0,0 +1,58 @@
+/**
+******************************************************************************
+*
+* @file platecarreeprojection.h
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#ifndef PLATECARREEPROJECTION_H
+#define PLATECARREEPROJECTION_H
+
+#include "../pureprojection.h"
+
+using namespace internals;
+
+namespace projections {
+class PlateCarreeProjection:public PureProjection
+{
+public:
+ PlateCarreeProjection();
+ virtual QString Type(){return "PlateCarreeProjection";}
+ virtual Size TileSize() const;
+ virtual double Axis() const;
+ virtual double Flattening()const;
+ virtual Point FromLatLngToPixel(double lat, double lng, int const& zoom);
+ virtual PointLatLng FromPixelToLatLng(const int &x,const int &y,const int &zoom);
+ virtual Size GetTileMatrixMinXY(const int &zoom);
+ virtual Size GetTileMatrixMaxXY(const int &zoom);
+private:
+ const double MinLatitude;
+ const double MaxLatitude;
+ const double MinLongitude;
+ const double MaxLongitude;
+
+ double Clip(double const& n, double const& minValue, double const& maxValue)const;
+ Size tileSize;
+};
+}
+#endif // PLATECARREEPROJECTION_H
diff --git a/ground/src/libs/opmapcontrol/src/internals/projections/platecarreeprojectionpergo.cpp b/ground/src/libs/opmapcontrol/src/internals/projections/platecarreeprojectionpergo.cpp
new file mode 100644
index 000000000..c4cec539a
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/projections/platecarreeprojectionpergo.cpp
@@ -0,0 +1,96 @@
+/**
+******************************************************************************
+*
+* @file platecarreeprojectionpergo.cpp
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#include "platecarreeprojectionpergo.h"
+
+
+namespace projections {
+PlateCarreeProjectionPergo::PlateCarreeProjectionPergo():MinLatitude(-85.05112878), MaxLatitude(85.05112878),MinLongitude(-180),
+MaxLongitude(180), tileSize(256, 256)
+{
+}
+Point PlateCarreeProjectionPergo::FromLatLngToPixel(double lat, double lng, const int &zoom)
+{
+ Point ret;// = Point.Empty;
+
+ lat = Clip(lat, MinLatitude, MaxLatitude);
+ lng = Clip(lng, MinLongitude, MaxLongitude);
+
+ Size s = GetTileMatrixSizePixel(zoom);
+ double mapSizeX = s.Width();
+ double mapSizeY = s.Height();
+
+ double scale = 360.0 / mapSizeX;
+
+ ret.SetY((int) ((90.0 - lat) / scale));
+ ret.SetX((int) ((lng + 180.0) / scale));
+
+ return ret;
+}
+PointLatLng PlateCarreeProjectionPergo::FromPixelToLatLng(const int &x, const int &y, const int &zoom)
+{
+ PointLatLng ret;// = PointLatLng.Empty;
+
+ Size s = GetTileMatrixSizePixel(zoom);
+ double mapSizeX = s.Width();
+ double mapSizeY = s.Height();
+
+ double scale = 360.0 / mapSizeX;
+
+ ret.SetLat(90 - (y * scale));
+ ret.SetLng((x * scale) - 180);
+
+ return ret;
+}
+
+double PlateCarreeProjectionPergo::Clip(const double &n, const double &minValue, const double &maxValue) const
+{
+ return qMin(qMax(n, minValue), maxValue);
+}
+Size PlateCarreeProjectionPergo::TileSize() const
+{
+ return tileSize;
+}
+double PlateCarreeProjectionPergo::Axis() const
+{
+ return 6378137;
+}
+double PlateCarreeProjectionPergo::Flattening() const
+{
+ return (1.0 / 298.257223563);
+}
+Size PlateCarreeProjectionPergo::GetTileMatrixMaxXY(const int &zoom)
+{
+ int y = (int) pow(2, zoom);
+ return Size((2*y) - 1, y - 1);
+}
+
+Size PlateCarreeProjectionPergo::GetTileMatrixMinXY(const int &zoom)
+{
+ return Size(0, 0);
+}
+}
diff --git a/ground/src/libs/opmapcontrol/src/internals/projections/platecarreeprojectionpergo.h b/ground/src/libs/opmapcontrol/src/internals/projections/platecarreeprojectionpergo.h
new file mode 100644
index 000000000..d808551cf
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/projections/platecarreeprojectionpergo.h
@@ -0,0 +1,58 @@
+/**
+******************************************************************************
+*
+* @file platecarreeprojectionpergo.h
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#ifndef PLATECARREEPROJECTIONPERGO_H
+#define PLATECARREEPROJECTIONPERGO_H
+
+#include "../pureprojection.h"
+
+using namespace internals;
+
+namespace projections {
+class PlateCarreeProjectionPergo:public PureProjection
+{
+public:
+ PlateCarreeProjectionPergo();
+ virtual QString Type(){return "PlateCarreeProjectionPergo";}
+ virtual Size TileSize() const;
+ virtual double Axis() const;
+ virtual double Flattening()const;
+ virtual Point FromLatLngToPixel(double lat, double lng, int const& zoom);
+ virtual PointLatLng FromPixelToLatLng(const int &x,const int &y,const int &zoom);
+ virtual Size GetTileMatrixMinXY(const int &zoom);
+ virtual Size GetTileMatrixMaxXY(const int &zoom);
+private:
+ const double MinLatitude;
+ const double MaxLatitude;
+ const double MinLongitude;
+ const double MaxLongitude;
+
+ double Clip(double const& n, double const& minValue, double const& maxValue)const;
+ Size tileSize;
+};
+}
+#endif // PLATECARREEPROJECTIONPERGO_H
diff --git a/ground/src/libs/opmapcontrol/src/internals/pureprojection.cpp b/ground/src/libs/opmapcontrol/src/internals/pureprojection.cpp
new file mode 100644
index 000000000..2e198705d
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/pureprojection.cpp
@@ -0,0 +1,208 @@
+/**
+******************************************************************************
+*
+* @file pureprojection.cpp
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#include "pureprojection.h"
+
+
+
+
+
+
+namespace internals {
+Point PureProjection::FromLatLngToPixel(const PointLatLng::PointLatLng &p,const int &zoom)
+ {
+ return FromLatLngToPixel(p.Lat(), p.Lng(), zoom);
+ }
+
+
+ PointLatLng PureProjection::FromPixelToLatLng(const Point &p,const int &zoom)
+ {
+ return FromPixelToLatLng(p.X(), p.Y(), zoom);
+ }
+
+ Point PureProjection::FromPixelToTileXY(const Point &p)
+ {
+ return Point((int) (p.X() / TileSize().Width()), (int) (p.Y() / TileSize().Height()));
+ }
+
+ Point PureProjection::FromTileXYToPixel(const Point &p)
+ {
+ return Point((p.X() * TileSize().Width()), (p.Y() * TileSize().Height()));
+ }
+
+ Size PureProjection::GetTileMatrixSizeXY(const int &zoom)
+ {
+ Size sMin = GetTileMatrixMinXY(zoom);
+ Size sMax = GetTileMatrixMaxXY(zoom);
+
+ return Size(sMax.Width() - sMin.Width() + 1, sMax.Height() - sMin.Height() + 1);
+ }
+ int PureProjection::GetTileMatrixItemCount(const int &zoom)
+ {
+ Size s = GetTileMatrixSizeXY(zoom);
+ return (s.Width() * s.Height());
+ }
+ Size PureProjection::GetTileMatrixSizePixel(const int &zoom)
+ {
+ Size s = GetTileMatrixSizeXY(zoom);
+ return Size(s.Width() * TileSize().Width(), s.Height() * TileSize().Height());
+ }
+ QList PureProjection::GetAreaTileList(const RectLatLng &rect,const int &zoom,const int &padding)
+ {
+ QList ret;
+
+ Point topLeft = FromPixelToTileXY(FromLatLngToPixel(rect.LocationTopLeft(), zoom));
+ Point rightBottom = FromPixelToTileXY(FromLatLngToPixel(rect.Bottom(), rect.Right(), zoom));
+
+ for(int x = (topLeft.X() - padding); x <= (rightBottom.X() + padding); x++)
+ {
+ for(int y = (topLeft.Y() - padding); y <= (rightBottom.Y() + padding); y++)
+ {
+ Point p = Point(x, y);
+ if(!ret.contains(p) && p.X() >= 0 && p.Y() >= 0)
+ {
+ ret.append(p);
+ }
+ }
+ }
+ //ret.TrimExcess();
+
+ return ret;
+ }
+ double PureProjection::GetGroundResolution(const int &zoom,const double &latitude)
+ {
+ return (cos(latitude * (PI / 180)) * 2 * PI * Axis()) / GetTileMatrixSizePixel(zoom).Width();
+ }
+
+ double PureProjection::Sign(const double &x)
+ {
+ if(x < 0.0)
+ return (-1);
+ else
+ return (1);
+ }
+
+ double PureProjection::AdjustLongitude(double x)
+ {
+ qlonglong count = 0;
+ while(true)
+ {
+ if(qAbs(x) <= PI)
+ break;
+ else
+ if(((qlonglong) qAbs(x / PI)) < 2)
+ x = x - (Sign(x) * TWO_PI);
+
+ else
+ if(((qlonglong) qAbs(x / TWO_PI)) < MAXLONG)
+ {
+ x = x - (((qlonglong) (x / TWO_PI)) * TWO_PI);
+ }
+ else
+ if(((qlonglong) qAbs(x / (MAXLONG * TWO_PI))) < MAXLONG)
+ {
+ x = x - (((qlonglong) (x / (MAXLONG * TWO_PI))) * (TWO_PI * MAXLONG));
+ }
+ else
+ if(((qlonglong) qAbs(x / (DBLLONG * TWO_PI))) < MAXLONG)
+ {
+ x = x - (((qlonglong) (x / (DBLLONG * TWO_PI))) * (TWO_PI * DBLLONG));
+ }
+ else
+ x = x - (Sign(x) * TWO_PI);
+ count++;
+ if(count > MAX_VAL)
+ break;
+ }
+ return (x);
+ }
+
+ void PureProjection::SinCos(const double &val, double &si, double &co)
+ {
+ si = sin(val);
+ co = cos(val);
+ }
+
+ double PureProjection::e0fn(const double &x)
+ {
+ return (1.0 - 0.25 * x * (1.0 + x / 16.0 * (3.0 + 1.25 * x)));
+ }
+
+ double PureProjection::e1fn(const double &x)
+ {
+ return (0.375 * x * (1.0 + 0.25 * x * (1.0 + 0.46875 * x)));
+ }
+
+ double PureProjection::e2fn(const double &x)
+ {
+ return (0.05859375 * x * x * (1.0 + 0.75 * x));
+ }
+
+ double PureProjection::e3fn(const double &x)
+ {
+ return (x * x * x * (35.0 / 3072.0));
+ }
+
+ double PureProjection::mlfn(const double &e0,const double &e1,const double &e2,const double &e3,const double &phi)
+ {
+ return (e0 * phi - e1 * sin(2.0 * phi) + e2 * sin(4.0 * phi) - e3 * sin(6.0 * phi));
+ }
+
+ qlonglong PureProjection::GetUTMzone(const double &lon)
+ {
+ return ((qlonglong) (((lon + 180.0) / 6.0) + 1.0));
+ }
+
+
+ void PureProjection::FromGeodeticToCartesian(double Lat,double Lng,const double &Height, double &X, double &Y, double &Z)
+ {
+ Lat = (PI / 180) * Lat;
+ Lng = (PI / 180) * Lng;
+
+ double B = Axis() * (1.0 - Flattening());
+ double ee = 1.0 - (B / Axis()) * (B / Axis());
+ double N = (Axis() / sqrt(1.0 - ee * sin(Lat) * sin(Lat)));
+
+ X = (N + Height) * cos(Lat) * cos(Lng);
+ Y = (N + Height) * cos(Lat) * sin(Lng);
+ Z = (N * (B / Axis()) * (B / Axis()) + Height) * sin(Lat);
+ }
+ void PureProjection::FromCartesianTGeodetic(const double &X,const double &Y,const double &Z, double &Lat, double &Lng)
+ {
+ double E = Flattening() * (2.0 - Flattening());
+ Lng = atan2(Y, X);
+
+ double P = sqrt(X * X + Y * Y);
+ double Theta = atan2(Z, (P * (1.0 - Flattening())));
+ double st = sin(Theta);
+ double ct = cos(Theta);
+ Lat = atan2(Z + E / (1.0 - Flattening()) * Axis() * st * st * st, P - E * Axis() * ct * ct * ct);
+
+ Lat /= (PI / 180);
+ Lng /= (PI / 180);
+ }
+}
diff --git a/ground/src/libs/opmapcontrol/src/internals/pureprojection.h b/ground/src/libs/opmapcontrol/src/internals/pureprojection.h
new file mode 100644
index 000000000..073e8b052
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/pureprojection.h
@@ -0,0 +1,111 @@
+/**
+******************************************************************************
+*
+* @file pureprojection.h
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#ifndef PUREPROJECTION_H
+#define PUREPROJECTION_H
+
+#include "../core/size.h"
+#include "../core/point.h"
+#include "../internals/pointlatlng.h"
+#include "pointlatlng.h"
+#include "cmath"
+#include "rectlatlng.h"
+
+using namespace core;
+
+namespace internals
+{
+
+class PureProjection
+{
+
+
+public:
+ virtual Size TileSize()const=0;
+
+ virtual double Axis()const=0;
+
+ virtual double Flattening()const=0;
+
+ virtual Point FromLatLngToPixel(double lat, double lng, int const& zoom)=0;
+
+ virtual PointLatLng FromPixelToLatLng(const int &x,const int &y,const int &zoom)=0;
+
+ virtual QString Type(){return "PureProjection";}
+ Point FromLatLngToPixel(const PointLatLng &p,const int &zoom);
+
+ PointLatLng FromPixelToLatLng(const Point &p,const int &zoom);
+ virtual Point FromPixelToTileXY(const Point &p);
+ virtual Point FromTileXYToPixel(const Point &p);
+ virtual Size GetTileMatrixMinXY(const int &zoom)=0;
+ virtual Size GetTileMatrixMaxXY(const int &zoom)=0;
+ virtual Size GetTileMatrixSizeXY(const int &zoom);
+ int GetTileMatrixItemCount(const int &zoom);
+ virtual Size GetTileMatrixSizePixel(const int &zoom);
+ QList GetAreaTileList(const RectLatLng &rect,const int &zoom,const int &padding);
+ virtual double GetGroundResolution(const int &zoom,const double &latitude);
+
+ double DegreesToRadians(const double °)const
+ {
+ return (D2R * deg);
+ }
+
+ double RadiansToDegrees(const double &rad)const
+ {
+ return (R2D * rad);
+ }
+ void FromGeodeticToCartesian(double Lat,double Lng,const double &Height, double &X, double &Y, double &Z);
+ void FromCartesianTGeodetic(const double &X,const double &Y,const double &Z, double &Lat, double &Lng);
+
+protected:
+
+ static const double PI = M_PI;
+ static const double HALF_PI = (M_PI * 0.5);
+ static const double TWO_PI= (M_PI * 2.0);
+ static const double EPSLoN= 1.0e-10;
+ static const double MAX_VAL= 4;
+ static const double MAXLONG= 2147483647;
+ static const double DBLLONG= 4.61168601e18;
+ static const double R2D=180/M_PI;
+ static const double D2R=M_PI/180;
+
+ static double Sign(const double &x);
+
+ static double AdjustLongitude(double x);
+ static void SinCos(const double &val, double &sin, double &cos);
+ static double e0fn(const double &x);
+ static double e1fn(const double &x);
+ static double e2fn(const double &x);
+ static double e3fn(const double &x);
+ static double mlfn(const double &e0,const double &e1,const double &e2,const double &e3,const double &phi);
+ static qlonglong GetUTMzone(const double &lon);
+
+};
+}
+
+
+#endif // PUREPROJECTION_H
diff --git a/ground/src/libs/opmapcontrol/src/internals/rectangle.cpp b/ground/src/libs/opmapcontrol/src/internals/rectangle.cpp
new file mode 100644
index 000000000..6e435dea3
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/rectangle.cpp
@@ -0,0 +1,80 @@
+/**
+******************************************************************************
+*
+* @file rectangle.cpp
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#include "rectangle.h"
+
+namespace internals {
+Rectangle Rectangle::Empty=Rectangle();
+Rectangle Rectangle::FromLTRB(int left, int top, int right, int bottom)
+ {
+ return Rectangle(left,
+ top,
+ right - left,
+ bottom - top);
+ }
+Rectangle Rectangle::Inflate(Rectangle rect, int x, int y)
+ {
+ Rectangle r = rect;
+ r.Inflate(x, y);
+ return r;
+ }
+Rectangle Rectangle::Intersect(Rectangle a, Rectangle b)
+ {
+ int x1 = std::max(a.X(), b.X());
+ int x2 = std::min(a.X() + a.Width(), b.X() + b.Width());
+ int y1 = std::max(a.Y(), b.Y());
+ int y2 = std::min(a.Y() + a.Height(), b.Y() + b.Height());
+
+ if(x2 >= x1
+ && y2 >= y1)
+ {
+
+ return Rectangle(x1, y1, x2 - x1, y2 - y1);
+ }
+ return Rectangle::Empty;
+ }
+Rectangle Rectangle::Union(const Rectangle &a,const Rectangle &b)
+ {
+ int x1 = std::min(a.x, b.x);
+ int x2 = std::max(a.x + a.width, b.x + b.width);
+ int y1 = std::min(a.y, b.y);
+ int y2 = std::max(a.y + a.height, b.y + b.height);
+
+ return Rectangle(x1, y1, x2 - x1, y2 - y1);
+ }
+bool operator==(Rectangle const& lhs,Rectangle const& rhs)
+{
+ return (lhs.x == rhs.x && lhs.y == rhs.y && lhs.width == rhs.width && lhs.height == rhs.height);
+}
+uint qHash(Rectangle const& rect)
+ {
+ return (int) ((quint32) rect.x ^
+ (((quint32) rect.y << 13) | ((quint32) rect.y >> 19)) ^
+ (((quint32) rect.width << 26) | ((quint32) rect.width >> 6)) ^
+ (((quint32) rect.height << 7) | ((quint32) rect.height >> 25)));
+ }
+}
diff --git a/ground/src/libs/opmapcontrol/src/internals/rectangle.h b/ground/src/libs/opmapcontrol/src/internals/rectangle.h
new file mode 100644
index 000000000..9ebdaafcb
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/rectangle.h
@@ -0,0 +1,159 @@
+/**
+******************************************************************************
+*
+* @file rectangle.h
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#ifndef RECTANGLE_H
+#define RECTANGLE_H
+//#include
+#include "../core/size.h"
+#include "math.h"
+using namespace core;
+namespace internals
+{
+struct Rectangle
+{
+
+ friend uint qHash(Rectangle const& rect);
+ friend bool operator==(Rectangle const& lhs,Rectangle const& rhs);
+public:
+ static Rectangle Empty;
+ static Rectangle FromLTRB(int left, int top, int right, int bottom);
+ Rectangle(){x=0; y=0; width=0; height=0; };
+ Rectangle(int x, int y, int width, int height)
+ {
+ this->x = x;
+ this->y = y;
+ this->width = width;
+ this->height = height;
+ }
+ Rectangle(Point location, Size size)
+ {
+ this->x = location.X();
+ this->y = location.Y();
+ this->width = size.Width();
+ this->height = size.Height();
+ }
+ Point GetLocation() {
+ return Point(x, y);
+ }
+ void SetLocation(const Point &value)
+ {
+ x = value.X();
+ y = value.Y();
+ }
+ int X(){return x;}
+ int Y(){return y;}
+ void SetX(const int &value){x=value;}
+ void SetY(const int &value){y=value;}
+ int Width(){return width;}
+ void SetWidth(const int &value){width=value;}
+ int Height(){return height;}
+ void SetHeight(const int &value){height=value;}
+ int Left(){return x;}
+ int Top(){return y;}
+ int Right(){return x+width;}
+ int Bottom(){return y+height;}
+ bool IsEmpty(){return (height==0 && width==0 && x==0 && y==0);}
+ bool operator==(const Rectangle &cSource)
+ {
+ return (cSource.x == x && cSource.y == y && cSource.width == width && cSource.height == height);
+ }
+
+
+ bool operator!=(const Rectangle &cSource){return !(*this==cSource);}
+ bool Contains(const int &x,const int &y)
+ {
+ return this->x<=x && xx+this->width && this->y<=y && yy+this->height;
+ }
+ bool Contains(const Point &pt)
+ {
+ return Contains(pt.X(),pt.Y());
+ }
+ bool Contains(const Rectangle &rect)
+ {
+ return (this->x <= rect.x) &&
+ ((rect.x + rect.width) <= (this->x + this->width)) &&
+ (this->y <= rect.y) &&
+ ((rect.y + rect.height) <= (this->y + this->height));
+ }
+
+
+ void Inflate(const int &width,const int &height)
+ {
+ this->x -= width;
+ this->y -= height;
+ this->width += 2*width;
+ this->height += 2*height;
+ }
+ void Inflate(Size &size)
+ {
+
+ Inflate(size.Width(), size.Height());
+ }
+ static Rectangle Inflate(Rectangle rect, int x, int y);
+
+ void Intersect(const Rectangle &rect)
+ {
+ Rectangle result = Rectangle::Intersect(rect, *this);
+
+ this->x = result.X();
+ this->y = result.Y();
+ this->width = result.Width();
+ this->height = result.Height();
+ }
+ static Rectangle Intersect(Rectangle a, Rectangle b);
+ bool IntersectsWith(const Rectangle &rect)
+ {
+ return (rect.x < this->x + this->width) &&
+ (this->x < (rect.x + rect.width)) &&
+ (rect.y < this->y + this->height) &&
+ (this->y < rect.y + rect.height);
+ }
+ static Rectangle Union(const Rectangle &a,const Rectangle &b);
+ void Offset(const Point &pos)
+ {
+ Offset(pos.X(), pos.Y());
+ }
+
+ void Offset(const int &x,const int &y)
+ {
+ this->x += x;
+ this->y += y;
+ }
+ QString ToString()
+ {
+ return "{X=" + QString::number(x) + ",Y=" + QString::number(y) +
+ ",Width=" + QString::number(width) +
+ ",Height=" +QString::number(height) +"}";
+ }
+private:
+ int x;
+ int y;
+ int width;
+ int height;
+};
+}
+#endif // RECTANGLE_H
diff --git a/ground/src/libs/opmapcontrol/src/internals/rectlatlng.cpp b/ground/src/libs/opmapcontrol/src/internals/rectlatlng.cpp
new file mode 100644
index 000000000..6c24c08a7
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/rectlatlng.cpp
@@ -0,0 +1,49 @@
+/**
+******************************************************************************
+*
+* @file rectlatlng.cpp
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#include "rectlatlng.h"
+
+
+
+namespace internals {
+RectLatLng RectLatLng::Empty=RectLatLng();
+uint qHash(RectLatLng const& rect)
+{
+ return (int) (((((uint) rect.Lng()) ^ ((((uint) rect.Lat()) << 13) | (((uint) rect.Lat()) >> 0x13))) ^ ((((uint) rect.WidthLng()) << 0x1a) | (((uint) rect.WidthLng()) >> 6))) ^ ((((uint) rect.HeightLat()) << 7) | (((uint) rect.HeightLat()) >> 0x19)));
+}
+
+bool operator==(RectLatLng const& left,RectLatLng const& right)
+{
+ return ((((left.Lng() == right.Lng()) && (left.Lat() == right.Lat())) && (left.WidthLng() == right.WidthLng())) && (left.HeightLat() == right.HeightLat()));
+}
+
+bool operator!=(RectLatLng const& left,RectLatLng const& right)
+{
+ return !(left == right);
+}
+
+}
diff --git a/ground/src/libs/opmapcontrol/src/internals/rectlatlng.h b/ground/src/libs/opmapcontrol/src/internals/rectlatlng.h
new file mode 100644
index 000000000..67b261da8
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/rectlatlng.h
@@ -0,0 +1,265 @@
+/**
+******************************************************************************
+*
+* @file rectlatlng.h
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#ifndef RECTLATLNG_H
+#define RECTLATLNG_H
+
+//#include "pointlatlng.h"
+#include "../internals/pointlatlng.h"
+#include "math.h"
+#include
+#include "sizelatlng.h"
+
+namespace internals {
+struct RectLatLng
+{
+public:
+ static RectLatLng Empty;
+ friend uint qHash(RectLatLng const& rect);
+ friend bool operator==(RectLatLng const& left,RectLatLng const& right);
+ friend bool operator!=(RectLatLng const& left,RectLatLng const& right);
+ RectLatLng(double const& lat, double const& lng, double const& widthLng, double const& heightLat)
+ {
+ this->lng = lng;
+ this->lat = lat;
+ this->widthLng = widthLng;
+ this->heightLat = heightLat;
+ isempty=false;
+ }
+ RectLatLng(PointLatLng const& location, SizeLatLng const& size)
+ {
+ this->lng = location.Lng();
+ this->lat = location.Lat();
+ this->widthLng = size.WidthLng();
+ this->heightLat = size.HeightLat();
+ isempty=false;
+ }
+ RectLatLng()
+ {
+ this->lng = 0;
+ this->lat = 0;
+ this->widthLng = 0;
+ this->heightLat = 0;
+ isempty=true;
+ }
+
+ static RectLatLng FromLTRB(double const& lng, double const& lat, double const& rightLng, double const& bottomLat)
+ {
+ return RectLatLng(lat, lng, rightLng - lng, lat - bottomLat);
+ }
+ PointLatLng LocationTopLeft()const
+ {
+ return PointLatLng(this->lat, this->lng);
+ }
+ void SetLocationTopLeft(PointLatLng const& value)
+ {
+ this->lng = value.Lng();
+ this->lat = value.Lat();
+ isempty=false;
+ }
+ PointLatLng LocationRightBottom()
+ {
+
+ PointLatLng ret = PointLatLng(this->lat, this->lng);
+ ret.Offset(HeightLat(), WidthLng());
+ return ret;
+ }
+ SizeLatLng Size()
+ {
+ return SizeLatLng(this->HeightLat(), this->WidthLng());
+ }
+ void SetSize(SizeLatLng const& value)
+ {
+ this->widthLng = value.WidthLng();
+ this->heightLat = value.HeightLat();
+ isempty=false;
+ }
+ double Lng()const
+ {
+ return this->lng;
+ }
+ void SetLng(double const& value)
+ {
+ this->lng = value;
+ isempty=false;
+ }
+
+
+ double Lat()const
+ {
+ return this->lat;
+ }
+ void SetLat(double const& value)
+ {
+ this->lat = value;
+ isempty=false;
+ }
+
+ double WidthLng()const
+ {
+ return this->widthLng;
+ }
+ void SetWidthLng(double const& value)
+ {
+ this->widthLng = value;
+ isempty=false;
+ }
+ double HeightLat()const
+ {
+ return this->heightLat;
+ }
+ void SetHeightLat(double const& value)
+ {
+ this->heightLat = value;
+ isempty=false;
+ }
+ double Left()const
+ {
+ return this->Lng();
+ }
+
+ double Top()const
+ {
+ return this->Lat();
+ }
+
+ double Right()const
+ {
+ return (this->Lng() + this->WidthLng());
+ }
+
+ double Bottom()const
+ {
+ return (this->Lat() - this->HeightLat());
+ }
+ bool IsEmpty()const
+ {
+ return isempty;
+ }
+ bool Contains(double const& lat, double const& lng)
+ {
+ return ((((this->Lng() <= lng) && (lng < (this->Lng() + this->WidthLng()))) && (this->Lat() >= lat)) && (lat > (this->Lat() - this->HeightLat())));
+ }
+
+ bool Contains(PointLatLng const& pt)
+ {
+ return this->Contains(pt.Lat(), pt.Lng());
+ }
+
+ bool Contains(RectLatLng const& rect)
+ {
+ return ((((this->Lng() <= rect.Lng()) && ((rect.Lng() + rect.WidthLng()) <= (this->Lng() + this->WidthLng()))) && (this->Lat() >= rect.Lat())) && ((rect.Lat() - rect.HeightLat()) >= (this->Lat() - this->HeightLat())));
+ }
+ void Inflate(double const& lat, double const& lng)
+ {
+ this->lng -= lng;
+ this->lat += lat;
+ this->widthLng += (double)2 * lng;
+ this->heightLat +=(double)2 * lat;
+ }
+
+ void Inflate(SizeLatLng const& size)
+ {
+ this->Inflate(size.HeightLat(), size.WidthLng());
+ }
+
+ static RectLatLng Inflate(RectLatLng const& rect, double const& lat, double const& lng)
+ {
+ RectLatLng ef = rect;
+ ef.Inflate(lat, lng);
+ return ef;
+ }
+
+ void Intersect(RectLatLng const& rect)
+ {
+ RectLatLng ef = Intersect(rect, *this);
+ this->lng = ef.Lng();
+ this->lat = ef.Lat();
+ this->widthLng = ef.WidthLng();
+ this->heightLat = ef.HeightLat();
+ }
+ static RectLatLng Intersect(RectLatLng const& a, RectLatLng const& b)
+ {
+ double lng = std::max(a.Lng(), b.Lng());
+ double num2 = std::min((double) (a.Lng() + a.WidthLng()), (double) (b.Lng() + b.WidthLng()));
+
+ double lat = std::max(a.Lat(), b.Lat());
+ double num4 = std::min((double) (a.Lat() + a.HeightLat()), (double) (b.Lat() + b.HeightLat()));
+
+ if((num2 >= lng) && (num4 >= lat))
+ {
+ return RectLatLng(lng, lat, num2 - lng, num4 - lat);
+ }
+ return Empty;
+ }
+ bool IntersectsWith(RectLatLng const& rect)
+ {
+ return ((((rect.Lng() < (this->Lng() + this->WidthLng())) && (this->Lng() < (rect.Lng() + rect.WidthLng()))) && (rect.Lat() < (this->Lat() + this->HeightLat()))) && (this->Lat() < (rect.Lat() + rect.HeightLat())));
+ }
+
+ static RectLatLng Union(RectLatLng const& a, RectLatLng const& b)
+ {
+ double lng = std::min(a.Lng(), b.Lng());
+ double num2 = std::max((double) (a.Lng() + a.WidthLng()), (double) (b.Lng() + b.WidthLng()));
+ double lat = std::min(a.Lat(), b.Lat());
+ double num4 = std::max((double) (a.Lat() + a.HeightLat()), (double) (b.Lat() + b.HeightLat()));
+ return RectLatLng(lng, lat, num2 - lng, num4 - lat);
+ }
+ void Offset(PointLatLng const& pos)
+ {
+ this->Offset(pos.Lat(), pos.Lng());
+ }
+
+ void Offset(double const& lat, double const& lng)
+ {
+ this->lng += lng;
+ this->lat -= lat;
+ }
+
+ QString ToString() const
+ {
+ return ("{Lat=" + QString::number(this->Lat()) + ",Lng=" + QString::number(this->Lng()) + ",WidthLng=" + QString::number(this->WidthLng()) + ",HeightLat=" + QString::number(this->HeightLat()) + "}");
+ }
+
+private:
+ double lng;
+ double lat;
+ double widthLng;
+ double heightLat;
+ bool isempty;
+};
+
+}
+#endif // RECTLATLNG_H
+
+
+
+// static RectLatLng()
+// {
+// Empty = new RectLatLng();
+// }
+// }
diff --git a/ground/src/libs/opmapcontrol/src/internals/sizelatlng.cpp b/ground/src/libs/opmapcontrol/src/internals/sizelatlng.cpp
new file mode 100644
index 000000000..0150a2c04
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/sizelatlng.cpp
@@ -0,0 +1,61 @@
+/**
+******************************************************************************
+*
+* @file sizelatlng.cpp
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#include "sizelatlng.h"
+#include "pointlatlng.h"
+
+namespace internals {
+SizeLatLng::SizeLatLng():heightLat(0),widthLng(0)
+{
+
+}
+SizeLatLng::SizeLatLng(PointLatLng const& pt)
+{
+ this->heightLat = pt.Lat();
+ this->widthLng = pt.Lng();
+}
+SizeLatLng operator+(SizeLatLng const& sz1, SizeLatLng const& sz2)
+{
+ return SizeLatLng::Add(sz1, sz2);
+}
+
+SizeLatLng operator-(SizeLatLng const& sz1, SizeLatLng const& sz2)
+{
+ return SizeLatLng::Subtract(sz1, sz2);
+}
+
+bool operator==(SizeLatLng const& sz1, SizeLatLng const& sz2)
+{
+ return ((sz1.WidthLng() == sz2.WidthLng()) && (sz1.HeightLat() == sz2.HeightLat()));
+}
+
+bool operator!=(SizeLatLng const& sz1, SizeLatLng const& sz2)
+{
+ return !(sz1 == sz2);
+}
+SizeLatLng SizeLatLng::Empty=SizeLatLng();
+}
diff --git a/ground/src/libs/opmapcontrol/src/internals/sizelatlng.h b/ground/src/libs/opmapcontrol/src/internals/sizelatlng.h
new file mode 100644
index 000000000..f34dbf224
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/sizelatlng.h
@@ -0,0 +1,137 @@
+/**
+******************************************************************************
+*
+* @file sizelatlng.h
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#ifndef SIZELATLNG_H
+#define SIZELATLNG_H
+
+
+#include
+
+
+namespace internals {
+struct PointLatLng;
+struct SizeLatLng
+{
+public:
+ SizeLatLng();
+ static SizeLatLng Empty;
+
+ SizeLatLng(SizeLatLng const& size)
+ {
+ this->widthLng = size.widthLng;
+ this->heightLat = size.heightLat;
+ }
+
+ SizeLatLng(PointLatLng const& pt);
+
+
+ SizeLatLng(double const& heightLat, double const& widthLng)
+ {
+ this->heightLat = heightLat;
+ this->widthLng = widthLng;
+ }
+
+ friend SizeLatLng operator+(SizeLatLng const& sz1, SizeLatLng const& sz2);
+ friend SizeLatLng operator-(SizeLatLng const& sz1, SizeLatLng const& sz2);
+ friend bool operator==(SizeLatLng const& sz1, SizeLatLng const& sz2);
+ friend bool operator!=(SizeLatLng const& sz1, SizeLatLng const& sz2);
+
+
+// static explicit operator PointLatLng(SizeLatLng size)
+// {
+// return new PointLatLng(size.HeightLat(), size.WidthLng());
+// }
+
+
+ bool IsEmpty()const
+ {
+ return ((this->widthLng == 0) && (this->heightLat == 0));
+ }
+
+ double WidthLng()const
+ {
+ return this->widthLng;
+ }
+ void SetWidthLng(double const& value)
+ {
+ this->widthLng = value;
+ }
+
+
+ double HeightLat()const
+ {
+ return this->heightLat;
+ }
+ void SetHeightLat(double const& value)
+ {
+ this->heightLat = value;
+ }
+
+ static SizeLatLng Add(SizeLatLng const& sz1, SizeLatLng const& sz2)
+ {
+ return SizeLatLng(sz1.HeightLat() + sz2.HeightLat(), sz1.WidthLng() + sz2.WidthLng());
+ }
+
+ static SizeLatLng Subtract(SizeLatLng const& sz1, SizeLatLng const& sz2)
+ {
+ return SizeLatLng(sz1.HeightLat() - sz2.HeightLat(), sz1.WidthLng() - sz2.WidthLng());
+ }
+
+// override bool Equals(object obj)
+// {
+// if(!(obj is SizeLatLng))
+// {
+// return false;
+// }
+// SizeLatLng ef = (SizeLatLng) obj;
+// return (((ef.WidthLng == this->WidthLng) && (ef.HeightLat == this->HeightLat)) && ef.GetType().Equals(base.GetType()));
+// }
+
+// override int GetHashCode()
+// {
+// return base.GetHashCode();
+// }
+
+// PointLatLng ToPointLatLng()
+// {
+// return (PointLatLng) this;
+// }
+
+ QString ToString()
+ {
+ return ("{WidthLng=" + QString::number(this->widthLng) + ", HeightLng=" + QString::number(this->heightLat) + "}");
+ }
+
+
+private:
+ double heightLat;
+ double widthLng;
+};
+
+}
+#endif // SIZELATLNG_H
+
diff --git a/ground/src/libs/opmapcontrol/src/internals/tile.cpp b/ground/src/libs/opmapcontrol/src/internals/tile.cpp
new file mode 100644
index 000000000..73887f47f
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/tile.cpp
@@ -0,0 +1,61 @@
+/**
+******************************************************************************
+*
+* @file tile.cpp
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#include "tile.h"
+
+
+namespace internals {
+Tile::Tile(int zoom, Point pos)
+{
+ this->zoom=zoom;
+ this->pos=pos;
+}
+void Tile::Clear()
+{
+#ifdef DEBUG_TILE
+ qDebug()<<"Tile:Clear Overlays";
+#endif //DEBUG_TILE
+ mutex.lock();
+ foreach(QByteArray img, Overlays)
+ {
+ img.~QByteArray();
+ }
+ Overlays.clear();
+ mutex.unlock();
+}
+Tile::Tile():zoom(0),pos(0,0)
+{
+
+}
+Tile& Tile::operator =(const Tile &cSource)
+{
+ this->zoom=cSource.zoom;
+ this->pos=cSource.pos;
+ return *this;
+}
+
+}
diff --git a/ground/src/libs/opmapcontrol/src/internals/tile.h b/ground/src/libs/opmapcontrol/src/internals/tile.h
new file mode 100644
index 000000000..ffe83cf09
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/tile.h
@@ -0,0 +1,68 @@
+/**
+******************************************************************************
+*
+* @file tile.h
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#ifndef TILE_H
+#define TILE_H
+
+#include "QList"
+#include
+#include "../core/point.h"
+#include
+#include
+#include "debugheader.h"
+using namespace core;
+namespace internals
+{
+class Tile
+{
+public:
+ Tile(int zoom,Point pos);
+ Tile();
+ void Clear();
+ int GetZoom(){return zoom;}
+ Point GetPos(){return pos;}
+ void SetZoom(const int &value){zoom=value;}
+ void SetPos(const Point &value){pos=value;}
+ Tile& operator= (const Tile &cSource);
+ Tile(const Tile &cSource)
+ {
+ this->zoom=cSource.zoom;
+ this->pos=cSource.pos;
+ }
+ bool HasValue(){return !(zoom==0);}
+ QList Overlays;
+protected:
+
+ QMutex mutex;
+private:
+ int zoom;
+ Point pos;
+
+
+};
+}
+#endif // TILE_H
diff --git a/ground/src/libs/opmapcontrol/src/internals/tilematrix.cpp b/ground/src/libs/opmapcontrol/src/internals/tilematrix.cpp
new file mode 100644
index 000000000..c6226979d
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/internals/tilematrix.cpp
@@ -0,0 +1,92 @@
+/**
+******************************************************************************
+*
+* @file tilematrix.cpp
+* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
+* @brief
+* @see The GNU Public License (GPL) Version 3
+* @defgroup OPMapWidget
+* @{
+*
+*****************************************************************************/
+/*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful, but
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+* for more details.
+*
+* You should have received a copy of the GNU General Public License along
+* with this program; if not, write to the Free Software Foundation, Inc.,
+* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+#include "tilematrix.h"
+
+
+namespace internals {
+TileMatrix::TileMatrix()
+{
+}
+void TileMatrix::Clear()
+{
+ mutex.lock();
+ foreach(Tile* t,matrix.values())
+ {
+ delete t;
+ t=0;
+ }
+ matrix.clear();
+ mutex.unlock();
+}
+
+void TileMatrix::ClearPointsNotIn(QListlist)
+{
+ removals.clear();
+ mutex.lock();
+ foreach(Point p, matrix.keys())
+ {
+ if(!list.contains(p))
+ {
+ removals.append(p);
+ }
+ }
+ mutex.unlock();
+ foreach(Point p,removals)
+ {
+ Tile* t=TileAt(p);
+ if(t!=0)
+ {
+ mutex.lock();
+ delete t;
+ t=0;
+ matrix.remove(p);
+ mutex.unlock();
+ }
+
+ }
+ removals.clear();
+}
+Tile* TileMatrix::TileAt(const Point &p)
+{
+
+#ifdef DEBUG_TILEMATRIX
+ qDebug()<<"TileMatrix:TileAt:"<
+#include "tile.h"
+#include
+#include "../core/point.h"
+#include "debugheader.h"
+namespace internals {
+class TileMatrix
+{
+public:
+ TileMatrix();
+ void Clear();
+ void ClearPointsNotIn(QList list);
+ Tile* TileAt(const Point &p);
+ void SetTileAt(const Point &p,Tile* tile);
+ int count()const{return matrix.count();}
+protected:
+ QHash matrix;
+ QList removals;
+ QMutex mutex;
+};
+
+}
+#endif // TILEMATRIX_H
diff --git a/ground/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.cpp b/ground/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.cpp
new file mode 100644
index 000000000..36a146b85
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.cpp
@@ -0,0 +1,377 @@
+#include "mapgraphicitem.h"
+namespace mapcontrol
+{
+ MapGraphicItem::MapGraphicItem(Core *core):core(core),MapRenderTransform(1), maxZoom(17),minZoom(2),zoomReal(0),isSelected(false),rotation(0)
+ {
+ EmptytileBrush = Qt::cyan;
+ MissingDataFont =QFont ("Times",10,QFont::Bold);
+ EmptyTileText = "We are sorry, but we don't\nhave imagery at this zoom\nlevel for this region.";
+ EmptyTileBorders = QPen(Qt::white);
+ ScalePen = QPen(Qt::blue);
+ SelectionPen = QPen(Qt::blue);
+ MapScaleInfoEnabled = true;
+ showTileGridLines=true;
+ DragButton = Qt::RightButton;
+ isMouseOverMarker=false;
+ maprect=QRectF(0,0,1022,680);
+ core->SetCurrentRegion(Rectangle(0, 0, maprect.width(), maprect.height()));
+ core->SetMapType(MapType::GoogleHybrid);
+ this->SetZoom(2);
+
+ connect(core,SIGNAL(OnNeedInvalidation()),this,SLOT(Core_OnNeedInvalidation()));
+
+
+ //resize();
+ }
+ void MapGraphicItem::start()
+ {
+ core->StartSystem();
+ }
+
+ void MapGraphicItem::resize(const QRectF &rect)
+ {
+
+ {
+ maprect=boundingBox(scene()->sceneRect(),rotation);
+ this->setTransform(QTransform().translate(-(maprect.width()-scene()->width())/2,-(maprect.height()-scene()->height())/2));
+ this->setTransformOriginPoint(maprect.center().x(),maprect.center().y());
+ this->setRotation(rotation);
+ }
+
+ core->OnMapSizeChanged(maprect.width(),maprect.height());
+ core->SetCurrentRegion(Rectangle(0, 0, maprect.width(), maprect.height()));
+ if(isVisible())
+ {
+ core->GoToCurrentPosition();
+ }
+ }
+
+ QRectF MapGraphicItem::boundingRect() const
+ {
+ const int Margin = 1;
+ return maprect.adjusted(-Margin, -Margin, +Margin, +Margin);
+ }
+ void MapGraphicItem::Core_OnNeedInvalidation()
+ {
+ this->update();
+ }
+ void MapGraphicItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+ {
+
+ if(MapRenderTransform!=1)
+ {
+ QTransform transform;
+ transform.scale(MapRenderTransform,MapRenderTransform);
+ painter->setWorldTransform(transform);
+ {
+ DrawMap2D(painter);
+ }
+ painter->resetTransform();
+ }
+ else
+ {
+ DrawMap2D(painter);
+ }
+ painter->drawRect(maprect);
+ }
+ void MapGraphicItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
+ {
+ if(core->IsDragging())
+ {
+ core->mouseCurrent.SetX(event->pos().x());
+ core->mouseCurrent.SetY(event->pos().y());
+
+ {
+ core->Drag(core->mouseCurrent);
+ }
+
+ }
+ }
+ void MapGraphicItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
+ {
+ if(!IsMouseOverMarker())
+ {
+ if(event->button() == DragButton && CanDragMap())
+ {
+ core->mouseDown.SetX(event->pos().x());
+ core->mouseDown.SetY(event->pos().y());
+
+
+ this->setCursor(Qt::SizeAllCursor);
+
+ core->BeginDrag(core->mouseDown);
+ this->update();
+
+ }
+ else if(!isSelected)
+ {
+ isSelected = true;
+ SetSelectedArea (RectLatLng::Empty);
+ selectionEnd = PointLatLng::Empty;
+ selectionStart = FromLocalToLatLng(event->pos().x(), event->pos().y());
+ }
+ }
+ }
+ void MapGraphicItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+ {
+ if(isSelected)
+ {
+ isSelected = false;
+ }
+
+ if(core->IsDragging())
+ {
+ core->EndDrag();
+
+ this->setCursor(Qt::ArrowCursor);
+ if(!BoundsOfMap.IsEmpty() && !BoundsOfMap.Contains(core->CurrentPosition()))
+ {
+ if(!core->LastLocationInBounds.IsEmpty())
+ {
+ core->SetCurrentPosition(core->LastLocationInBounds);
+ }
+ }
+ }
+ else
+ {
+ if(!selectionEnd.IsEmpty() && !selectionStart.IsEmpty())
+ {
+ if(!selectedArea.IsEmpty() && event->modifiers() == Qt::ShiftModifier)
+ {
+ // SetZoomToFitRect(SelectedArea());TODO
+ }
+ }
+
+ }
+ }
+ void MapGraphicItem::wheelEvent(QGraphicsSceneWheelEvent *event)
+ {
+ if(!IsMouseOverMarker() && !IsDragging())
+ {
+ if(core->GetmouseLastZoom().X() != event->pos().x() && core->mouseLastZoom.Y() != event->pos().y())
+ {
+ if(GetMouseWheelZoomType() == MouseWheelZoomType::MousePositionAndCenter)
+ {
+ core->SetCurrentPosition(FromLocalToLatLng(event->pos().x(), event->pos().y()));
+ }
+ else if(GetMouseWheelZoomType() == MouseWheelZoomType::ViewCenter)
+ {
+ core->SetCurrentPosition(FromLocalToLatLng((int) maprect.width()/2, (int) maprect.height()/2));
+ }
+ else if(GetMouseWheelZoomType() == MouseWheelZoomType::MousePositionWithoutCenter)
+ {
+ core->SetCurrentPosition(FromLocalToLatLng(event->pos().x(), event->pos().y()));
+
+ }
+
+ core->mouseLastZoom.SetX((event->pos().x()));
+ core->mouseLastZoom.SetY((event->pos().y()));
+ }
+
+ // set mouse position to map center
+ if(GetMouseWheelZoomType() != MouseWheelZoomType::MousePositionWithoutCenter)
+ {
+ {
+ // System.Drawing.Point p = PointToScreen(new System.Drawing.Point(Width/2, Height/2));
+ // Stuff.SetCursorPos((int) p.X, (int) p.Y);
+ }
+ }
+
+ core->MouseWheelZooming = true;
+
+ if(event->delta() > 0)
+ {
+ SetZoom(Zoom()+1);
+ }
+ else if(event->delta() < 0)
+ {
+ SetZoom(Zoom()-1);
+ }
+
+ core->MouseWheelZooming = false;
+ }
+ }
+ void MapGraphicItem::DrawMap2D(QPainter *painter)
+ {
+ // qDebug()<Matrix.count();
+ // painter.drawText(10,10,"TESTE");
+ for(int i = -core->GetsizeOfMapArea().Width(); i <= core->GetsizeOfMapArea().Width(); i++)
+ {
+ for(int j = -core->GetsizeOfMapArea().Height(); j <= core->GetsizeOfMapArea().Height(); j++)
+ {
+ core->SettilePoint (core->GetcenterTileXYLocation());
+ core->SettilePoint(Point(core->GettilePoint().X()+ i,core->GettilePoint().Y()+j));
+
+
+
+ {
+ Tile* t = core->Matrix.TileAt(core->GettilePoint());
+ //qDebug()<<"OPMapControl::DrawMap2D tile:"<GetPos().ToString()<<" as "<Overlays.count()<<" overlays";
+ //Tile t = core->Matrix[tileToDraw];
+ if(t!=0)
+ {
+ //qDebug()<< "opmapcontrol:draw2d TileHasValue:"<GetPos().ToString();
+ core->tileRect.SetX(core->GettilePoint().X()*core->tileRect.Width());
+ core->tileRect.SetY(core->GettilePoint().Y()*core->tileRect.Height());
+ core->tileRect.Offset(core->GetrenderOffset());
+
+ if(core->GetCurrentRegion().IntersectsWith(core->tileRect))
+ {
+ bool found = false;
+
+ // render tile
+ //lock(t.Overlays)
+ {
+ foreach(QByteArray img,t->Overlays)
+ {
+ if(img.count()!=0)
+ {
+ if(!found)
+ found = true;
+ {
+ painter->drawPixmap(core->tileRect.X(),core->tileRect.Y(), core->tileRect.Width(), core->tileRect.Height(),PureImageProxy::FromStream(img));
+
+ }
+ }
+ }
+ }
+
+ if(showTileGridLines)
+ {
+ painter->setPen(EmptyTileBorders);
+ painter->drawRect(core->tileRect.X(), core->tileRect.Y(), core->tileRect.Width(), core->tileRect.Height());
+ {
+ painter->setFont(MissingDataFont);
+ painter->setPen(Qt::red);
+ painter->drawText(QRectF(core->tileRect.X(), core->tileRect.Y(), core->tileRect.Width(), core->tileRect.Height()),Qt::AlignCenter,(core->GettilePoint() == core->GetcenterTileXYLocation()? "CENTER: " :"TILE: ")+core->GettilePoint().ToString());
+ //qDebug()<<"ShowTileGridLine:"<GettilePoint().ToString()<<"=="<GetcenterTileXYLocation().ToString();
+ }
+ }
+
+ // add text if tile is missing
+ if(!found)
+ {
+
+ painter->fillRect(QRectF(core->tileRect.X(), core->tileRect.Y(), core->tileRect.Width(), core->tileRect.Height()),EmptytileBrush);
+ painter->setFont(MissingDataFont);
+ painter->drawText(QRectF(core->tileRect.X(), core->tileRect.Y(), core->tileRect.Width(), core->tileRect.Height()),EmptyTileText);
+
+
+
+ painter->setPen(EmptyTileBorders);
+ painter->drawRect(core->tileRect.X(), core->tileRect.Y(), core->tileRect.Width(), core->tileRect.Height());
+
+ // raise error
+
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ PointLatLng MapGraphicItem::FromLocalToLatLng(int x, int y)
+ {
+ if(MapRenderTransform!=-1)
+ {
+ x = (int) (x * MapRenderTransform);
+ y = (int) (y * MapRenderTransform);
+ }
+ return core->FromLocalToLatLng(x, y);
+ }
+ double MapGraphicItem::Zoom()
+ {
+ return zoomReal;
+ }
+ void MapGraphicItem::SetZoom(double const& value)
+ {
+ if(zoomReal != value)
+ {
+ if(value > MaxZoom())
+ {
+ zoomReal = MaxZoom();
+ }
+ else
+ if(value < MinZoom())
+ {
+ zoomReal = MinZoom();
+ }
+ else
+ {
+ zoomReal = value;
+ }
+
+ float remainder = (float)std::fmod((float) value, (float) 1);
+ if(remainder != 0)
+ {
+ float scaleValue = remainder + 1;
+ {
+ MapRenderTransform = scaleValue;
+ }
+
+ SetZoomStep((qint32)(value - remainder));
+
+ this->update();
+
+ }
+ else
+ {
+
+ MapRenderTransform = 1;
+
+ SetZoomStep ((qint32)(value));
+ zoomReal = ZoomStep();
+ this->update();
+ }
+ }
+ }
+ int MapGraphicItem::ZoomStep()const
+ {
+ return core->Zoom();
+ }
+ void MapGraphicItem::SetZoomStep(int const& value)
+ {
+ if(value > MaxZoom())
+ {
+ core->SetZoom(MaxZoom());
+ emit zoomChanged(MaxZoom());
+ }
+ else if(value < MinZoom())
+ {
+ core->SetZoom(MinZoom());
+ emit zoomChanged(MinZoom());
+ }
+ else
+ {
+ core->SetZoom(value);
+ emit zoomChanged(value);
+ }
+
+ }
+
+ void MapGraphicItem::Offset(int const& x, int const& y)
+ {
+ core->DragOffset(Point(x, y));
+ }
+ void MapGraphicItem::mapRotate(qreal angle)
+ {
+ rotation=angle;
+ resize(scene()->sceneRect());
+ }
+ QRectF MapGraphicItem::boundingBox(const QRectF &rect, const qreal &angle)
+ {
+ QRectF ret(rect);
+ float c=cos(angle*2*M_PI/360);
+ float s=sin(angle*2*M_PI/360);
+ ret.setHeight(rect.height()*fabs(c)+rect.width()*fabs(s));
+ ret.setWidth(rect.width()*fabs(c)+rect.height()*fabs(s));
+ return ret;
+ }
+ QSize MapGraphicItem::sizeHint()const
+ {
+ core::Size size=core->projection->GetTileMatrixMaxXY(MinZoom());
+ core::Size tilesize=core->projection->TileSize();
+ QSize rsize((size.Width()+1)*tilesize.Width(),(size.Height()+1)*tilesize.Height());
+ return rsize;
+ }
+}
diff --git a/ground/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.h b/ground/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.h
new file mode 100644
index 000000000..cb68df353
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/mapwidget/mapgraphicitem.h
@@ -0,0 +1,91 @@
+#ifndef MAPGRAPHICITEM_H
+#define MAPGRAPHICITEM_H
+
+#include
+#include "../internals/core.h"
+#include
+#include
+#include
+#include
+#include
+#include
+namespace mapcontrol
+{
+ class OPMapWidget;
+class MapGraphicItem:public QObject,public QGraphicsItem
+{
+ friend class mapcontrol::OPMapWidget;
+ Q_OBJECT
+public:
+ MapGraphicItem(Core *core);
+ QRectF boundingRect() const;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+ QWidget *widget);
+
+ QSize sizeHint()const;
+
+
+protected:
+ void mouseMoveEvent ( QGraphicsSceneMouseEvent * event );
+ void mousePressEvent ( QGraphicsSceneMouseEvent * event );
+ void wheelEvent ( QGraphicsSceneWheelEvent * event );
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+ bool IsMouseOverMarker()const{return isMouseOverMarker;}
+ bool IsDragging()const{return core->IsDragging();}
+ int ZoomStep()const;
+ void SetZoomStep(int const& value);
+
+private:
+ Core *core;
+ bool showTileGridLines;
+ qreal MapRenderTransform;
+ void DrawMap2D(QPainter *painter);
+ QFont MissingDataFont;
+ int maxZoom;
+ int minZoom;
+ RectLatLng selectedArea;
+ PointLatLng selectionStart;
+ PointLatLng selectionEnd;
+ double zoomReal;
+ QRectF maprect;
+ bool isSelected;
+ bool isMouseOverMarker;
+ void SetIsMouseOverMarker(bool const& value){isMouseOverMarker = value;}
+ PointLatLng FromLocalToLatLng(int x, int y);
+ qreal rotation;
+ QRectF boundingBox(QRectF const& rect, qreal const& angle);
+
+ QBrush EmptytileBrush;
+ QString EmptyTileText;
+ QPen EmptyTileBorders;
+ QPen ScalePen;
+ QPen SelectionPen;
+ int MaxZoom()const{return maxZoom;}
+ int MinZoom()const{return minZoom;}
+ MouseWheelZoomType::Types GetMouseWheelZoomType(){return core->GetMouseWheelZoomType();}
+ QString GetMouseWheelZoomTypeStr(){return MouseWheelZoomType::TypesStrList().at((int)core->GetMouseWheelZoomType());}
+ bool MapScaleInfoEnabled;
+ Qt::MouseButton DragButton;
+ void SetSelectedArea(RectLatLng const& value){selectedArea = value;this->update();}
+ RectLatLng BoundsOfMap;
+ void Offset(int const& x, int const& y);
+ bool CanDragMap()const{return core->CanDragMap;}
+ void SetCanDragMap(bool const& value){core->CanDragMap = value;}
+ double Zoom();
+ void SetZoom(double const& value);
+ void mapRotate ( qreal angle );
+ void start();
+ void ReloadMap(){core->ReloadMap();}
+ GeoCoderStatusCode::Types SetCurrentPositionByKeywords(QString const& keys){return core->SetCurrentPositionByKeywords(keys);}
+ MapType::Types GetMapType(){return core->GetMapType();}
+ void SetMapType(MapType::Types const& value){core->SetMapType(value);}
+
+private slots:
+ void Core_OnNeedInvalidation();
+public slots:
+ void resize ( QRectF const &rect=QRectF() );
+signals:
+ void zoomChanged(double zoom);
+};
+}
+#endif // MAPGRAPHICITEM_H
diff --git a/ground/src/libs/opmapcontrol/src/mapwidget/mapresources.qrc b/ground/src/libs/opmapcontrol/src/mapwidget/mapresources.qrc
new file mode 100644
index 000000000..7646d2b36
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/mapwidget/mapresources.qrc
@@ -0,0 +1 @@
+
diff --git a/ground/src/libs/opmapcontrol/src/mapwidget/mapwidget.pro b/ground/src/libs/opmapcontrol/src/mapwidget/mapwidget.pro
new file mode 100644
index 000000000..a30f1ec6a
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/mapwidget/mapwidget.pro
@@ -0,0 +1,18 @@
+TEMPLATE = lib
+TARGET = OPMapWidget
+DEFINES += OPMAPWIDGET_LIBRARY
+
+include(../../../../openpilotgcslibrary.pri)
+
+SOURCES += opmapcontrol.cpp \
+ mapgraphicitem.cpp \
+ opmapwidget.cpp
+
+LIBS += -L../build -lcore -linternals -lcore
+HEADERS += opmapcontrol.h \
+ mapgraphicitem.h \
+ opmapwidget.h
+
+QT += opengl
+QT += network
+QT += sql
diff --git a/ground/src/libs/opmapcontrol/src/mapwidget/opmapcontrol.cpp b/ground/src/libs/opmapcontrol/src/mapwidget/opmapcontrol.cpp
new file mode 100644
index 000000000..6cce9716c
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/mapwidget/opmapcontrol.cpp
@@ -0,0 +1,366 @@
+#include "opmapcontrol.h"
+#include
+namespace mapcontrol
+{
+OPMapControl::OPMapControl(QWidget *parent):QWidget(parent),MapRenderTransform(1), maxZoom(17),minZoom(2),zoomReal(0),isSelected(false)
+{
+ EmptytileBrush = Qt::cyan;
+ MissingDataFont =QFont ("Times",10,QFont::Bold);
+ EmptyTileText = "We are sorry, but we don't\nhave imagery at this zoom\nlevel for this region.";
+ EmptyTileBorders = QPen(Qt::white);
+ ScalePen = QPen(Qt::blue);
+ SelectionPen = QPen(Qt::blue);
+ MapScaleInfoEnabled = true;
+ showTileGridLines=true;
+ DragButton = Qt::RightButton;
+ isMouseOverMarker=false;
+ core.SetCurrentRegion(Rectangle(-50, -50, this->width()+100, this->height()+100));
+ core.SetMapType(MapType::GoogleHybrid);
+ core.SetZoom(3);
+
+ connect(&core,SIGNAL(OnNeedInvalidation()),this,SLOT(Core_OnNeedInvalidation()));
+
+
+}
+void OPMapControl::showEvent(QShowEvent *event)
+{
+ QWidget::showEvent(event);
+ core.StartSystem();
+ resize();
+}
+
+void OPMapControl::Core_OnNeedInvalidation()
+{
+ this->repaint();
+}
+
+void OPMapControl::paintEvent(QPaintEvent* evnt)
+{
+ QWidget::paintEvent(evnt);
+ QPainter painter(this);
+ // painter.setBrush(palette().foreground().color());
+ // painter.fillRect(this->rect(),painter.background());
+ if(MapRenderTransform!=1)
+ {
+ QTransform transform;
+ transform.scale(MapRenderTransform,MapRenderTransform);
+ painter.setWorldTransform(transform);
+ {
+ DrawMap2D(painter);
+ }
+ painter.resetTransform();
+ }
+ else
+ {
+ DrawMap2D(painter);
+ }
+ // painter.drawText(10,10,"TESTE");
+}
+
+void OPMapControl::DrawMap2D(QPainter &painter)
+{
+ // qDebug()<GetPos().ToString()<<" as "<Overlays.count()<<" overlays";
+ //Tile t = Core.Matrix[tileToDraw];
+ if(t!=0)
+ {
+ //qDebug()<< "opmapcontrol:draw2d TileHasValue:"<GetPos().ToString();
+ core.tileRect.SetX(core.GettilePoint().X()*core.tileRect.Width());
+ core.tileRect.SetY(core.GettilePoint().Y()*core.tileRect.Height());
+ core.tileRect.Offset(core.GetrenderOffset());
+
+ if(core.GetCurrentRegion().IntersectsWith(core.tileRect))
+ {
+ bool found = false;
+
+ // render tile
+ //lock(t.Overlays)
+ {
+ foreach(QByteArray img,t->Overlays)
+ {
+ if(img.count()!=0)
+ {
+ if(!found)
+ found = true;
+ {
+ painter.drawImage(QRectF(core.tileRect.X(), core.tileRect.Y(), core.tileRect.Width(), core.tileRect.Height()),QImage::fromData(img));
+
+ }
+ }
+ }
+ }
+
+ if(showTileGridLines)
+ {
+ painter.setPen(EmptyTileBorders);
+ painter.drawRect(core.tileRect.X(), core.tileRect.Y(), core.tileRect.Width(), core.tileRect.Height());
+ {
+ painter.setFont(MissingDataFont);
+ painter.setPen(Qt::red);
+ painter.drawText(QRectF(core.tileRect.X(), core.tileRect.Y(), core.tileRect.Width(), core.tileRect.Height()),Qt::AlignCenter,(core.GettilePoint() == core.GetcenterTileXYLocation()? "CENTER: " :"TILE: ")+core.GettilePoint().ToString());
+ //qDebug()<<"ShowTileGridLine:"<button() == DragButton && core.CanDragMap)
+ {
+ core.mouseDown.SetX(evnt->x());
+ core.mouseDown.SetY(evnt->y());
+
+
+ this->setCursor(Qt::SizeAllCursor);
+
+ core.BeginDrag(core.mouseDown);
+ this->repaint();
+
+ }
+ else if(!isSelected)
+ {
+ isSelected = true;
+ SetSelectedArea (RectLatLng::Empty);
+ selectionEnd = PointLatLng::Empty;
+ selectionStart = FromLocalToLatLng(evnt->x(), evnt->y());
+ }
+ }
+
+ QWidget::mousePressEvent(evnt);
+}
+PointLatLng OPMapControl::FromLocalToLatLng(int x, int y)
+{
+ if(MapRenderTransform!=-1)
+ {
+ x = (int) (x * MapRenderTransform);
+ y = (int) (y * MapRenderTransform);
+ }
+ return core.FromLocalToLatLng(x, y);
+}
+void OPMapControl::mouseReleaseEvent ( QMouseEvent* evnt )
+{
+ QWidget::mouseReleaseEvent(evnt);
+
+ if(isSelected)
+ {
+ isSelected = false;
+ }
+
+ if(core.IsDragging())
+ {
+ core.EndDrag();
+
+ this->setCursor(Qt::ArrowCursor);
+ if(!BoundsOfMap.IsEmpty() && !BoundsOfMap.Contains(core.CurrentPosition()))
+ {
+ if(!core.LastLocationInBounds.IsEmpty())
+ {
+ core.SetCurrentPosition(core.LastLocationInBounds);
+ }
+ }
+ }
+ else
+ {
+ if(!selectionEnd.IsEmpty() && !selectionStart.IsEmpty())
+ {
+ if(!selectedArea.IsEmpty() && evnt->modifiers() == Qt::ShiftModifier)
+ {
+ // SetZoomToFitRect(SelectedArea());TODO
+ }
+ }
+
+ }
+
+}
+
+void OPMapControl::mouseMoveEvent ( QMouseEvent* evnt )
+{
+ if(core.IsDragging())
+ {
+ core.mouseCurrent.SetX(evnt->x());
+ core.mouseCurrent.SetY(evnt->y());
+
+ {
+ core.Drag(core.mouseCurrent);
+ }
+
+ }
+}
+void OPMapControl::resizeEvent ( QResizeEvent * event )
+{
+ QWidget::resizeEvent(event);
+ resize();
+}
+void OPMapControl::resize()
+{
+
+ core.OnMapSizeChanged(this->width(),this->height());
+ core.SetCurrentRegion(Rectangle(-50, -50, this->width()+100, this->height()+100));
+ if(isVisible())
+ {
+ core.GoToCurrentPosition();
+ }
+}
+void OPMapControl::wheelEvent(QWheelEvent *event)
+{
+ QWidget::wheelEvent(event);
+
+ if(!IsMouseOverMarker() && !IsDragging())
+ {
+ if(core.GetmouseLastZoom().X() != event->pos().x() && core.mouseLastZoom.Y() != event->pos().y())
+ {
+ if(GetMouseWheelZoomType() == MouseWheelZoomType::MousePositionAndCenter)
+ {
+ core.SetCurrentPosition(FromLocalToLatLng(event->pos().x(), event->pos().y()));
+ }
+ else if(GetMouseWheelZoomType() == MouseWheelZoomType::ViewCenter)
+ {
+ core.SetCurrentPosition(FromLocalToLatLng((int) width()/2, (int) height()/2));
+ }
+ else if(GetMouseWheelZoomType() == MouseWheelZoomType::MousePositionWithoutCenter)
+ {
+ core.SetCurrentPosition(FromLocalToLatLng(event->pos().x(), event->pos().y()));
+
+ }
+
+ core.mouseLastZoom.SetX((event->pos().x()));
+ core.mouseLastZoom.SetY((event->pos().y()));
+ }
+
+ // set mouse position to map center
+ if(GetMouseWheelZoomType() != MouseWheelZoomType::MousePositionWithoutCenter)
+ {
+ {
+// System.Drawing.Point p = PointToScreen(new System.Drawing.Point(Width/2, Height/2));
+// Stuff.SetCursorPos((int) p.X, (int) p.Y);
+ }
+ }
+
+ core.MouseWheelZooming = true;
+
+ if(event->delta() > 0)
+ {
+ SetZoom(Zoom()+1);
+ }
+ else if(event->delta() < 0)
+ {
+ SetZoom(Zoom()-1);
+ }
+
+ core.MouseWheelZooming = false;
+ }
+}
+double OPMapControl::Zoom()
+{
+
+
+ return zoomReal;
+}
+void OPMapControl::SetZoom(double const& value)
+{
+ if(zoomReal != value)
+ {
+ if(value > MaxZoom())
+ {
+ zoomReal = MaxZoom();
+ }
+ else
+ if(value < MinZoom())
+ {
+ zoomReal = MinZoom();
+ }
+ else
+ {
+ zoomReal = value;
+ }
+
+ float remainder = (float)std::fmod((float) value, (float) 1);
+ if(remainder != 0)
+ {
+ float scaleValue = remainder + 1;
+ {
+ MapRenderTransform = scaleValue;
+ }
+
+ SetZoomStep((qint32)(value - remainder));
+
+ this->repaint();
+
+ }
+ else
+ {
+
+ MapRenderTransform = 1;
+
+ SetZoomStep ((qint32)(value));
+ zoomReal = ZoomStep();
+ this->repaint();
+ }
+ }
+}
+int OPMapControl::ZoomStep()const
+{
+ return core.Zoom();
+}
+void OPMapControl::SetZoomStep(int const& value)
+{
+ if(value > MaxZoom())
+ {
+ core.SetZoom(MaxZoom());
+ }
+ else if(value < MinZoom())
+ {
+ core.SetZoom(MinZoom());
+ }
+ else
+ {
+ core.SetZoom(value);
+ }
+}
+
+void OPMapControl::Offset(int const& x, int const& y)
+{
+ core.DragOffset(Point(x, y));
+}
+void OPMapControl::closeEvent(QCloseEvent *event)
+{
+ core.OnMapClose();
+ event->accept();
+}
+}
diff --git a/ground/src/libs/opmapcontrol/src/mapwidget/opmapcontrol.h b/ground/src/libs/opmapcontrol/src/mapwidget/opmapcontrol.h
new file mode 100644
index 000000000..c5923d20a
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/mapwidget/opmapcontrol.h
@@ -0,0 +1,94 @@
+#ifndef OPMAPCONTROL_H
+#define OPMAPCONTROL_H
+
+#include "../internals/core.h"
+#include
+#include
+#include
+#include
+#include
+
+namespace mapcontrol
+{
+
+using namespace core;
+//using namespace internals;
+
+class internals::Core;
+
+class OPMapControl:public QWidget
+{
+
+ Q_OBJECT
+
+// Q_PROPERTY(int MaxZoom READ MaxZoom WRITE SetMaxZoom)
+// Q_PROPERTY(int MinZoom READ MinZoom WRITE SetMinZoom)
+// Q_PROPERTY(internals::MouseWheelZoomType::Types MouseWheelZoom READ GetMouseWheelZoomType WRITE SetMouseWheelZoomType)
+// Q_PROPERTY(QString MouseWheelZoomStr READ GetMouseWheelZoomTypeStr WRITE SetMouseWheelZoomTypeByStr)
+// Q_PROPERTY(bool ShowTileGridLines READ ShowTileGridLines WRITE SetShowTileGridLines)
+// Q_PROPERTY(double Zoom READ Zoom WRITE SetZoom)
+public:
+ OPMapControl(QWidget *parent=0);
+
+protected:
+ void paintEvent ( QPaintEvent* evnt );
+ void mousePressEvent ( QMouseEvent* evnt );
+ void mouseReleaseEvent ( QMouseEvent* evnt );
+ void mouseMoveEvent ( QMouseEvent* evnt );
+ void resizeEvent ( QResizeEvent * event );
+ void showEvent ( QShowEvent * event );
+ void closeEvent ( QCloseEvent * event );
+ bool IsDragging()const{return core.IsDragging();}
+ bool IsMouseOverMarker()const{return isMouseOverMarker;}
+ void wheelEvent ( QWheelEvent * event );
+ int ZoomStep()const;
+ void SetZoomStep(int const& value);
+private:
+ QBrush EmptytileBrush;
+ QString EmptyTileText;
+ QPen EmptyTileBorders;
+ QPen ScalePen;
+ QPen SelectionPen;
+// bool ShowTileGridLines()const {return showTileGridLines;}
+// void SetShowTileGridLines(bool const& value){showTileGridLines=value;this->repaint();}
+ int MaxZoom()const{return maxZoom;}
+// void SetMaxZoom(int const& value){maxZoom = value;}
+ int MinZoom()const{return minZoom;}
+// void SetMinZoom(int const& value){minZoom = value;}
+ MouseWheelZoomType::Types GetMouseWheelZoomType(){return core.GetMouseWheelZoomType();}
+// void SetMouseWheelZoomType(MouseWheelZoomType::Types const& value){core.SetMouseWheelZoomType(value);}
+// void SetMouseWheelZoomTypeByStr(const QString &value){core.SetMouseWheelZoomType(MouseWheelZoomType::TypeByStr(value));}
+ QString GetMouseWheelZoomTypeStr(){return MouseWheelZoomType::TypesStrList().at((int)core.GetMouseWheelZoomType());}
+ bool MapScaleInfoEnabled;
+ Qt::MouseButton DragButton;
+// RectLatLng SelectedArea()const{return selectedArea;}
+ void SetSelectedArea(RectLatLng const& value){selectedArea = value;this->update();}
+ RectLatLng BoundsOfMap;
+ void Offset(int const& x, int const& y);
+ bool CanDragMap()const{return core.CanDragMap;}
+ void SetCanDragMap(bool const& value){core.CanDragMap = value;}
+// PointLatLng CurrentPosition()const{return core.CurrentPosition();}
+// void SetCurrentPosition(PointLatLng const& value){core.SetCurrentPosition(value);}
+ double Zoom();
+ void SetZoom(double const& value);
+ bool showTileGridLines;
+ Core core;
+ qreal MapRenderTransform;
+ void DrawMap2D(QPainter &painter);
+ QFont MissingDataFont;
+ void resize();
+ int maxZoom;
+ int minZoom;
+ RectLatLng selectedArea;
+ PointLatLng selectionStart;
+ PointLatLng selectionEnd;
+ double zoomReal;
+ bool isSelected;
+ bool isMouseOverMarker;
+ void SetIsMouseOverMarker(bool const& value){isMouseOverMarker = value;}
+ PointLatLng FromLocalToLatLng(int x, int y);
+private slots:
+ void Core_OnNeedInvalidation();
+};
+}
+#endif // OPMAPCONTROL_H
diff --git a/ground/src/libs/opmapcontrol/src/mapwidget/opmapwidget.cpp b/ground/src/libs/opmapcontrol/src/mapwidget/opmapwidget.cpp
new file mode 100644
index 000000000..ab1655a99
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/mapwidget/opmapwidget.cpp
@@ -0,0 +1,64 @@
+#include "opmapwidget.h"
+#include
+#include
+namespace mapcontrol
+{
+ OPMapWidget::OPMapWidget(QWidget *parent):QGraphicsView(parent),useOpenGL(false)
+ {
+ setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
+
+ core=new Core;
+ map=new MapGraphicItem(core);
+ //text.setZValue(20);
+ //QGraphicsTextItem *t=new QGraphicsTextItem(map);
+ // t->setPos(10,10);
+ mscene.addItem(map);
+ map->setZValue(-1);
+ //t->setZValue(10);
+ this->setScene(&mscene);
+ this->adjustSize();
+ // t->setFlag(QGraphicsItem::ItemIsMovable,true);
+ connect(&mscene,SIGNAL(sceneRectChanged(QRectF)),map,SLOT(resize(QRectF)));
+ connect(map,SIGNAL(zoomChanged(double)),this,SIGNAL(zoomChanged(double)));
+ QMetaObject metaObject = this->staticMetaObject;
+ QMetaEnum metaEnum= metaObject.enumerator( metaObject.indexOfEnumerator("internals::MouseWheelZoomType::Types"));
+ QString s=metaEnum.valueToKey(1);
+ QString ss=s;
+ }
+ void OPMapWidget::resizeEvent(QResizeEvent *event)
+ {
+ if (scene())
+ scene()->setSceneRect(
+ QRect(QPoint(0, 0), event->size()));
+ QGraphicsView::resizeEvent(event);
+ }
+ QSize OPMapWidget::sizeHint() const
+ {
+ return map->sizeHint();
+ }
+ void OPMapWidget::showEvent(QShowEvent *event)
+ {
+ map->start();
+ QGraphicsView::showEvent(event);
+ }
+ OPMapWidget::~OPMapWidget()
+ {
+ delete map;
+ delete core;
+ }
+ void OPMapWidget::closeEvent(QCloseEvent *event)
+ {
+ core->OnMapClose();
+ event->accept();
+ }
+ void OPMapWidget::SetUseOpenGL(const bool &value)
+ {
+ useOpenGL=value;
+ if (useOpenGL)
+ setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
+ else
+ setupViewport(new QWidget());
+ update();
+ }
+
+}
diff --git a/ground/src/libs/opmapcontrol/src/mapwidget/opmapwidget.h b/ground/src/libs/opmapcontrol/src/mapwidget/opmapwidget.h
new file mode 100644
index 000000000..cfc24604e
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/mapwidget/opmapwidget.h
@@ -0,0 +1,87 @@
+#ifndef OPMAPWIDGET_H
+#define OPMAPWIDGET_H
+
+#include "../mapwidget/mapgraphicitem.h"
+#include "../core/geodecoderstatus.h"
+#include "../core/maptype.h"
+
+#include
+#include
+namespace mapcontrol
+{
+ class Helper
+ {
+ public:
+ static MapType::Types MapTypeFromString(QString const& value){return MapType::TypeByStr(value);}
+ static QString StrFromMapType(MapType::Types const& value){return MapType::StrByType(value);}
+ static QStringList MapTypes(){return MapType::TypesList();}
+ static GeoCoderStatusCode::Types GeoCoderStatusCodeFromString(QString const& value){return GeoCoderStatusCode::TypeByStr(value);}
+ static QString StrFromGeoCoderStatusCode(GeoCoderStatusCode::Types const& value){return GeoCoderStatusCode::StrByType(value);}
+ };
+
+ class OPMapWidget:public QGraphicsView
+ {
+ Q_OBJECT
+
+ Q_PROPERTY(int MaxZoom READ MaxZoom WRITE SetMaxZoom)
+ Q_PROPERTY(int MinZoom READ MinZoom WRITE SetMinZoom)
+ Q_PROPERTY(internals::MouseWheelZoomType::Types MouseWheelZoom READ GetMouseWheelZoomType WRITE SetMouseWheelZoomType)
+ Q_PROPERTY(QString MouseWheelZoomStr READ GetMouseWheelZoomTypeStr WRITE SetMouseWheelZoomTypeByStr)
+ Q_PROPERTY(bool ShowTileGridLines READ ShowTileGridLines WRITE SetShowTileGridLines)
+ Q_PROPERTY(double Zoom READ Zoom WRITE SetZoom)
+ Q_PROPERTY(qreal Rotate READ Rotate WRITE SetRotate)
+ Q_ENUMS(internals::MouseWheelZoomType::Types)
+ Q_ENUMS(internals::GeoCoderStatusCode::Types)
+ public:
+ // GeoCoderStatusCode x;
+ // MapType y;
+ QSize sizeHint() const;
+ OPMapWidget(QWidget *parent=0);
+ ~OPMapWidget();
+ bool ShowTileGridLines()const {return map->showTileGridLines;}
+ void SetShowTileGridLines(bool const& value){map->showTileGridLines=value;map->update();}
+ int MaxZoom()const{return map->maxZoom;}
+ void SetMaxZoom(int const& value){map->maxZoom = value;}
+ int MinZoom()const{return map->minZoom;}
+ void SetMinZoom(int const& value){map->minZoom = value;}
+ MouseWheelZoomType::Types GetMouseWheelZoomType(){return map->core->GetMouseWheelZoomType();}
+ void SetMouseWheelZoomType(MouseWheelZoomType::Types const& value){map->core->SetMouseWheelZoomType(value);}
+ void SetMouseWheelZoomTypeByStr(const QString &value){map->core->SetMouseWheelZoomType(MouseWheelZoomType::TypeByStr(value));}
+ QString GetMouseWheelZoomTypeStr(){return map->GetMouseWheelZoomTypeStr();}
+ RectLatLng SelectedArea()const{return map->selectedArea;}
+ void SetSelectedArea(RectLatLng const& value){ map->selectedArea = value;this->update();}
+ bool CanDragMap()const{return map->CanDragMap();}
+ void SetCanDragMap(bool const& value){map->SetCanDragMap(value);}
+ PointLatLng CurrentPosition()const{return map->core->CurrentPosition();}
+ void SetCurrentPosition(PointLatLng const& value){map->core->SetCurrentPosition(value);}
+ double Zoom(){return map->Zoom();}
+ void SetZoom(double const& value){map->SetZoom(value);}
+ qreal Rotate(){return map->rotation;}
+ void SetRotate(qreal const& value){map->mapRotate(value);}
+ void ReloadMap(){map->ReloadMap(); map->resize();;}
+ GeoCoderStatusCode::Types SetCurrentPositionByKeywords(QString const& keys){return map->SetCurrentPositionByKeywords(keys);}
+ bool UseOpenGL(){return useOpenGL;}
+ void SetUseOpenGL(bool const& value);
+ MapType::Types GetMapType(){return map->core->GetMapType();}
+ void SetMapType(MapType::Types const& value){map->core->SetMapType(value);}
+ bool isStarted(){return map->core->isStarted();}
+ void X(){map->core->GoToCurrentPosition();}
+ private:
+ Core *core;
+ MapGraphicItem *map;
+ QGraphicsScene mscene;
+ bool useOpenGL;
+ GeoCoderStatusCode x;
+ MapType y;
+ protected:
+ void resizeEvent(QResizeEvent *event);
+ void showEvent ( QShowEvent * event );
+ void closeEvent(QCloseEvent *event);
+ // private slots:
+ signals:
+ void zoomChanged(double zoom);
+
+
+ };
+}
+#endif // OPMAPWIDGET_H
diff --git a/ground/src/libs/opmapcontrol/src/src.pro b/ground/src/libs/opmapcontrol/src/src.pro
new file mode 100644
index 000000000..f62a6c7da
--- /dev/null
+++ b/ground/src/libs/opmapcontrol/src/src.pro
@@ -0,0 +1,6 @@
+TEMPLATE = subdirs
+CONFIG += ordered
+SUBDIRS = core
+SUBDIRS += internals
+SUBDIRS += mapwidget
+SUBDIRS+=finaltest