Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
colorEagleStdio
qplanetosm
提交
b6ec4a2d
qplanetosm
项目概览
colorEagleStdio
/
qplanetosm
通知
120
Star
10
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
qplanetosm
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b6ec4a2d
编写于
1月 08, 2016
作者:
丁劲犇
😸
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add comments, change pow approad to 1<<X approach.
上级
bb63f4e2
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
87 addition
and
39 deletion
+87
-39
qtviewer_planetosm/osmtiles/tilesviewer.cpp
qtviewer_planetosm/osmtiles/tilesviewer.cpp
+39
-39
qtvplugin_geomarker/geographicsellipseitem.cpp
qtvplugin_geomarker/geographicsellipseitem.cpp
+4
-0
qtvplugin_geomarker/geographicslineitem.cpp
qtvplugin_geomarker/geographicslineitem.cpp
+4
-0
qtvplugin_geomarker/geographicspolygonitem.cpp
qtvplugin_geomarker/geographicspolygonitem.cpp
+4
-0
qtvplugin_geomarker/geographicsrectitem.cpp
qtvplugin_geomarker/geographicsrectitem.cpp
+4
-0
qtvplugin_geomarker/geographicsscene.cpp
qtvplugin_geomarker/geographicsscene.cpp
+11
-0
qtvplugin_geomarker/geographicsscene.h
qtvplugin_geomarker/geographicsscene.h
+14
-0
qtvplugin_geomarker/geoitembase.h
qtvplugin_geomarker/geoitembase.h
+7
-0
未找到文件。
qtviewer_planetosm/osmtiles/tilesviewer.cpp
浏览文件 @
b6ec4a2d
...
...
@@ -655,13 +655,13 @@ namespace QTVOSM{
double
dperx
=
dMx
/
(
cProjectionMercator
::
pi
*
cProjectionMercator
::
R
*
2
);
double
dpery
=
-
dMy
/
(
cProjectionMercator
::
pi
*
cProjectionMercator
::
R
*
2
);
double
dCurrImgSize
=
pow
(
2.0
,
m_nLevel
)
*
256
;
int
nCurrImgSize
=
(
1
<<
m_nLevel
)
*
256
;
//!3.Calculat the World pixel coordinats
double
dTarX
=
dperx
*
dCurrImgSize
+
d
CurrImgSize
/
2
;
double
dTarY
=
dpery
*
dCurrImgSize
+
d
CurrImgSize
/
2
;
double
dTarX
=
dperx
*
nCurrImgSize
+
n
CurrImgSize
/
2
;
double
dTarY
=
dpery
*
nCurrImgSize
+
n
CurrImgSize
/
2
;
//!4.Calculat the World pixel coordinats of current view-center point
double
dCurrX
=
dCurrImgSize
*
m_dCenterX
+
d
CurrImgSize
/
2
;
double
dCurrY
=
dCurrImgSize
*
m_dCenterY
+
d
CurrImgSize
/
2
;
double
dCurrX
=
nCurrImgSize
*
m_dCenterX
+
n
CurrImgSize
/
2
;
double
dCurrY
=
nCurrImgSize
*
m_dCenterY
+
n
CurrImgSize
/
2
;
//!5.Calculat the World pixel coordinats of current view-left-top point
double
nOffsetLT_x
=
(
dCurrX
-
width
()
/
2.0
);
double
nOffsetLT_y
=
(
dCurrY
-
height
()
/
2.0
);
...
...
@@ -689,13 +689,13 @@ namespace QTVOSM{
return
false
;
//!1.Current World Pixel Size, connected to nLevel
double
dCurrImgSize
=
pow
(
2.0
,
m_nLevel
)
*
256
;
int
nCurrImgSize
=
(
1
<<
m_nLevel
)
*
256
;
//!2.current DP according to center
double
dx
=
X
-
(
width
()
/
2.0
);
double
dy
=
Y
-
(
height
()
/
2.0
);
//!3.Percentage -0.5 ~ 0.5 coord
double
dImgX
=
dx
/
d
CurrImgSize
+
m_dCenterX
;
double
dImgY
=
dy
/
d
CurrImgSize
+
m_dCenterY
;
double
dImgX
=
dx
/
n
CurrImgSize
+
m_dCenterX
;
double
dImgY
=
dy
/
n
CurrImgSize
+
m_dCenterY
;
//!4.to Mercator
double
Mercator_x
=
cProjectionMercator
::
pi
*
cProjectionMercator
::
R
*
2
*
dImgX
;
double
Mercator_y
=
-
cProjectionMercator
::
pi
*
cProjectionMercator
::
R
*
2
*
dImgY
;
...
...
@@ -747,7 +747,7 @@ namespace QTVOSM{
/*!
\brief convert Mercator to World. World Points is according to current level,
point(0,0) stay at the left-top, point (SZ,SZ) in bottom-right
SZ = pow(2.0,m_nLevel)
*256, m_nLevel between 0 and 18
the pixel size is 2^m_nLevel
*256, m_nLevel between 0 and 18
This approach is devided into several steps, and it is LEVEL RELATED!
\fn tilesviewer::CV_MK2World
...
...
@@ -764,11 +764,11 @@ namespace QTVOSM{
double
dperx
=
mx
/
(
cProjectionMercator
::
pi
*
cProjectionMercator
::
R
*
2
);
double
dpery
=
-
my
/
(
cProjectionMercator
::
pi
*
cProjectionMercator
::
R
*
2
);
double
dCurrImgSize
=
pow
(
2.0
,
m_nLevel
)
*
256
;
int
nCurrImgSize
=
(
1
<<
m_nLevel
)
*
256
;
//!2.Calculat the World pixel coordinats
*
px
=
dperx
*
dCurrImgSize
+
d
CurrImgSize
/
2
;
*
py
=
dpery
*
dCurrImgSize
+
d
CurrImgSize
/
2
;
*
px
=
dperx
*
nCurrImgSize
+
n
CurrImgSize
/
2
;
*
py
=
dpery
*
nCurrImgSize
+
n
CurrImgSize
/
2
;
return
true
;
}
...
...
@@ -776,7 +776,7 @@ namespace QTVOSM{
/*!
\brief convert World to Mercator. World Points is according to current level,
point(0,0) stay at the left-top, point (SZ,SZ) in bottom-right
SZ = pow(2.0,m_nLevel)
*256, m_nLevel between 0 and 18
the pixel size is 2^m_nLevel
*256, m_nLevel between 0 and 18
This approach is devided into several steps, and it is LEVEL RELATED!
\fn tilesviewer::CV_World2MK
...
...
@@ -790,10 +790,10 @@ namespace QTVOSM{
{
if
(
!
pmx
||!
pmy
)
return
false
;
//!1.Current World Pixel Size, connected to nLevel
double
dCurrImgSize
=
pow
(
2.0
,
m_nLevel
)
*
256
;
int
nCurrImgSize
=
(
1
<<
m_nLevel
)
*
256
;
//!2.Percentage -0.5 ~ 0.5 coord
double
dImgX
=
x
/
d
CurrImgSize
-
.5
;
double
dImgY
=
y
/
d
CurrImgSize
-
.5
;
double
dImgX
=
x
/
n
CurrImgSize
-
.5
;
double
dImgY
=
y
/
n
CurrImgSize
-
.5
;
//!3.to Mercator
*
pmx
=
cProjectionMercator
::
pi
*
cProjectionMercator
::
R
*
2
*
dImgX
;
*
pmy
=
-
cProjectionMercator
::
pi
*
cProjectionMercator
::
R
*
2
*
dImgY
;
...
...
@@ -804,7 +804,7 @@ namespace QTVOSM{
/*!
\brief convert LLA to world. World Points is according to current level,
point(0,0) stay at the left-top, point (SZ,SZ) in bottom-right
SZ = pow(2.0,m_nLevel)
*256, m_nLevel between 0 and 18
the pixel size is 2^m_nLevel
*256, m_nLevel between 0 and 18
This approach is devided into several steps, and it is LEVEL RELATED!
\fn tilesviewer::CV_LLA2World
...
...
@@ -825,17 +825,17 @@ namespace QTVOSM{
double
dperx
=
dMx
/
(
cProjectionMercator
::
pi
*
cProjectionMercator
::
R
*
2
);
double
dpery
=
-
dMy
/
(
cProjectionMercator
::
pi
*
cProjectionMercator
::
R
*
2
);
double
dCurrImgSize
=
pow
(
2.0
,
m_nLevel
)
*
256
;
int
nCurrImgSize
=
(
1
<<
m_nLevel
)
*
256
;
//!3.Calculat the World pixel coordinats
*
px
=
dperx
*
dCurrImgSize
+
d
CurrImgSize
/
2
;
*
py
=
dpery
*
dCurrImgSize
+
d
CurrImgSize
/
2
;
*
px
=
dperx
*
nCurrImgSize
+
n
CurrImgSize
/
2
;
*
py
=
dpery
*
nCurrImgSize
+
n
CurrImgSize
/
2
;
return
true
;
}
/*!
\brief convert world to LLA. World Points is according to current level,
point(0,0) stay at the left-top, point (SZ,SZ) in bottom-right
SZ = pow(2.0,m_nLevel)
*256, m_nLevel between 0 and 18
the pixel size is 2^m_nLevel
*256, m_nLevel between 0 and 18
This approach is devided into several steps, and it is LEVEL RELATED!
\fn tilesviewer::CV_World2LLA
...
...
@@ -849,10 +849,10 @@ namespace QTVOSM{
{
if
(
!
plat
||!
plon
)
return
false
;
//!1.Current World Pixel Size, connected to nLevel
double
dCurrImgSize
=
pow
(
2.0
,
m_nLevel
)
*
256
;
int
nCurrImgSize
=
(
1
<<
m_nLevel
)
*
256
;
//!2.Percentage -0.5 ~ 0.5 coord
double
dImgX
=
x
/
d
CurrImgSize
-
.5
;
double
dImgY
=
y
/
d
CurrImgSize
-
.5
;
double
dImgX
=
x
/
n
CurrImgSize
-
.5
;
double
dImgY
=
y
/
n
CurrImgSize
-
.5
;
//!3.to Mercator
double
mkx
=
cProjectionMercator
::
pi
*
cProjectionMercator
::
R
*
2
*
dImgX
;
double
mky
=
-
cProjectionMercator
::
pi
*
cProjectionMercator
::
R
*
2
*
dImgY
;
...
...
@@ -867,7 +867,7 @@ namespace QTVOSM{
\brief convert Device Points to World. Device Points is according to current viewport,
point(0,0) stay at the top-left, point (width-1,height-1) in bottom-right. World Points is according
to current level, point(0,0) stay at the left-top, point (SZ,SZ) in bottom-right,
SZ = pow(2.0,m_nLevel)
*256, m_nLevel between 0 and 18
the pixel size is 2^m_nLevel
*256, m_nLevel between 0 and 18
This approach is devided into several steps, and it is LEVEL RELATED!
\fn tilesviewer::CV_DP2World
...
...
@@ -881,16 +881,16 @@ namespace QTVOSM{
{
if
(
!
px
||!
py
)
return
false
;
//!1.Current World Pixel Size, connected to nLevel
double
dCurrImgSize
=
pow
(
2.0
,
m_nLevel
)
*
256
;
int
nCurrImgSize
=
(
1
<<
m_nLevel
)
*
256
;
//!2.current DP according to center
double
dx
=
dX
-
(
width
()
/
2.0
);
double
dy
=
dY
-
(
height
()
/
2.0
);
//!3.Percentage -0.5 ~ 0.5 coord
double
dImgX
=
dx
/
d
CurrImgSize
+
m_dCenterX
;
double
dImgY
=
dy
/
d
CurrImgSize
+
m_dCenterY
;
double
dImgX
=
dx
/
n
CurrImgSize
+
m_dCenterX
;
double
dImgY
=
dy
/
n
CurrImgSize
+
m_dCenterY
;
//!4.Calculat the World pixel coordinats
*
px
=
dImgX
*
dCurrImgSize
+
d
CurrImgSize
/
2
;
*
py
=
dImgY
*
dCurrImgSize
+
d
CurrImgSize
/
2
;
*
px
=
dImgX
*
nCurrImgSize
+
n
CurrImgSize
/
2
;
*
py
=
dImgY
*
nCurrImgSize
+
n
CurrImgSize
/
2
;
return
true
;
}
...
...
@@ -899,7 +899,7 @@ namespace QTVOSM{
\brief convert World to Device Points. Device Points is according to current viewport,
point(0,0) stay at the top-left, point (width-1,height-1) in bottom-right. World Points is according
to current level, point(0,0) stay at the left-top, point (SZ,SZ) in bottom-right,
SZ = pow(2.0,m_nLevel)
*256, m_nLevel between 0 and 18
the pixel size is 2^m_nLevel
*256, m_nLevel between 0 and 18
This approach is devided into several steps, and it is LEVEL RELATED!
\fn tilesviewer::CV_World2DP
...
...
@@ -914,11 +914,11 @@ namespace QTVOSM{
if
(
!
pdX
||!
pdY
)
return
false
;
//!1.Current World Pixel Size, connected to nLevel
double
dCurrImgSize
=
pow
(
2.0
,
m_nLevel
)
*
256
;
int
nCurrImgSize
=
(
1
<<
m_nLevel
)
*
256
;
//!2.Calculat the World pixel coordinats of current view-center point
double
dCurrX
=
dCurrImgSize
*
m_dCenterX
+
d
CurrImgSize
/
2
;
double
dCurrY
=
dCurrImgSize
*
m_dCenterY
+
d
CurrImgSize
/
2
;
double
dCurrX
=
nCurrImgSize
*
m_dCenterX
+
n
CurrImgSize
/
2
;
double
dCurrY
=
nCurrImgSize
*
m_dCenterY
+
n
CurrImgSize
/
2
;
//!3.Calculat the World pixel coordinats of current view-left-top point
double
nOffsetLT_x
=
(
dCurrX
-
width
()
/
2.0
);
double
nOffsetLT_y
=
(
dCurrY
-
height
()
/
2.0
);
...
...
@@ -932,7 +932,7 @@ namespace QTVOSM{
/*!
\brief convert percentage coord to world. World Points is according
to current level, point(0,0) stay at the left-top, point (SZ,SZ) in bottom-right,
SZ = pow(2.0,m_nLevel)
*256, m_nLevel between 0 and 18. Percentage coord is a
the pixel size is 2^m_nLevel
*256, m_nLevel between 0 and 18. Percentage coord is a
level-unretated coord, take a range -0.5~0.5, the world center in 0,0, -0.5.-0.5
at top-left, 0.5,0.5 at bottom-right
This approach is LEVEL RELATED!
...
...
@@ -959,7 +959,7 @@ namespace QTVOSM{
/*!
\brief convert world to percentage coord. World Points is according
to current level, point(0,0) stay at the left-top, point (SZ,SZ) in bottom-right,
SZ = pow(2.0,m_nLevel)
*256, m_nLevel between 0 and 18. Percentage coord is a
the pixel size is 2^m_nLevel
*256, m_nLevel between 0 and 18. Percentage coord is a
level-unretated coord, take a range -0.5~0.5, the world center in 0,0, -0.5.-0.5
at top-left, 0.5,0.5 at bottom-right
This approach is LEVEL RELATED!
...
...
@@ -976,10 +976,10 @@ namespace QTVOSM{
if
(
!
px
||
!
py
)
return
false
;
//Current World Pixel Size, connected to nLevel
double
dCurrImgSize
=
pow
(
2.0
,
m_nLevel
)
*
256
;
int
nCurrImgSize
=
(
1
<<
m_nLevel
)
*
256
;
//Percentage -0.5 ~ 0.5 coord
*
px
=
nx
/
d
CurrImgSize
-
.5
;
*
py
=
ny
/
d
CurrImgSize
-
.5
;
*
px
=
nx
/
n
CurrImgSize
-
.5
;
*
py
=
ny
/
n
CurrImgSize
-
.5
;
return
true
;
}
...
...
qtvplugin_geomarker/geographicsellipseitem.cpp
浏览文件 @
b6ec4a2d
...
...
@@ -29,6 +29,10 @@ namespace QTVP_GEOMARKER{
{
if
(
vi
()
&&
nNewLevel
!=
level
())
{
/** Since the map is zooming from level() to current level,
* the map size zoom ratio can be calculated using pow below.
* We can get new coord for current zoom level by multiplicative.
*/
double
ratio
=
pow
(
2.0
,(
nNewLevel
-
level
()));
QRectF
rect
=
this
->
rect
();
QPointF
center
=
rect
.
center
();
...
...
qtvplugin_geomarker/geographicslineitem.cpp
浏览文件 @
b6ec4a2d
...
...
@@ -51,6 +51,10 @@ namespace QTVP_GEOMARKER{
{
if
(
vi
()
&&
nNewLevel
!=
level
())
{
/** Since the map is zooming from level() to current level,
* the map size zoom ratio can be calculated using pow below.
* We can get new coord for current zoom level by multiplicative.
*/
double
ratio
=
pow
(
2.0
,(
nNewLevel
-
level
()));
QLineF
l1
=
this
->
line
();
setLine
(
l1
.
x1
()
*
ratio
,
l1
.
y1
()
*
ratio
,
l1
.
x2
()
*
ratio
,
l1
.
y2
()
*
ratio
);
...
...
qtvplugin_geomarker/geographicspolygonitem.cpp
浏览文件 @
b6ec4a2d
...
...
@@ -51,6 +51,10 @@ namespace QTVP_GEOMARKER{
{
if
(
vi
()
&&
nNewLevel
!=
level
())
{
/** Since the map is zooming from level() to current level,
* the map size zoom ratio can be calculated using pow below.
* We can get new coord for current zoom level by multiplicative.
*/
double
ratio
=
pow
(
2.0
,(
nNewLevel
-
level
()));
QPolygonF
p
=
this
->
polygon
();
int
sz
=
p
.
size
();
...
...
qtvplugin_geomarker/geographicsrectitem.cpp
浏览文件 @
b6ec4a2d
...
...
@@ -31,6 +31,10 @@ namespace QTVP_GEOMARKER{
{
if
(
vi
()
&&
ncurrLevel
!=
level
())
{
/** Since the map is zooming from level() to current level,
* the map size zoom ratio can be calculated using pow below.
* We can get new coord for current zoom level by multiplicative.
*/
double
ratio
=
pow
(
2.0
,(
ncurrLevel
-
level
()));
QRectF
rect
=
this
->
rect
();
QPointF
center
=
rect
.
center
();
...
...
qtvplugin_geomarker/geographicsscene.cpp
浏览文件 @
b6ec4a2d
...
...
@@ -61,6 +61,13 @@ namespace QTVP_GEOMARKER{
}
/**
* @brief sequentially call virtual function geoItemBase::adjust_coords for every geoItemBase object.
*
* Since the scene coord will be zoomed in / out together with level change, all graphics items' coords should
* be recalculated in time. the method adjust_item_coords will do this automatically,
* @param newLevel the level to which current map is zoomed.
*/
void
geoGraphicsScene
::
adjust_item_coords
(
int
newLevel
)
{
QList
<
QGraphicsItem
*
>
it
=
this
->
items
();
...
...
@@ -69,7 +76,11 @@ namespace QTVP_GEOMARKER{
geoItemBase
*
base
=
dynamic_cast
<
geoItemBase
*>
(
t
);
if
(
base
)
{
//when this function is called, base->level() is the old level from which
// current map is zoomed.
base
->
adjust_coords
(
newLevel
);
//After adjust_coords above, the item "base" is considered to
// have a valid coord corresponds to current newLevel
base
->
setLevel
(
newLevel
);
}
}
...
...
qtvplugin_geomarker/geographicsscene.h
浏览文件 @
b6ec4a2d
...
...
@@ -5,6 +5,20 @@
#include <QMap>
namespace
QTVP_GEOMARKER
{
class
geoItemBase
;
/**
* @brief geoGraphicsScene shield the common item operations, such as addEllipse
* addPolygon, and so on. It provide user several new polymorphism method,
* for special geoItemBase classes. Item name will be indexed using a QMap object m_map_items
* so that user can get item pointers as soon as possible.
*
* The scene uses World Pixel Coordinate system, which has a commection between zoom level.
* You can learn more principle about coordinates in the comments of class viewer_interface. in zoom level 0,
* world pixel size is 256x256, level 1 is 512x512, level 18 is 67108864 x 67108864
* Since the scene coord will be zoomed in / out together with level change, all graphics items' coords should
* be recalculated in time. the method adjust_item_coords will do this automatically,
* and in this function, virtual function geoItemBase::adjust_coords will be called sequentially.
*
*/
class
geoGraphicsScene
:
public
QGraphicsScene
{
Q_OBJECT
...
...
qtvplugin_geomarker/geoitembase.h
浏览文件 @
b6ec4a2d
...
...
@@ -32,6 +32,13 @@ namespace QTVP_GEOMARKER{
}
class
geoGraphicsScene
;
/**
* @brief class geoItemBase is the root base class for all geoGraphicsItems.
* this class has several function, include:
* 1.provide properties system, include name, font, color, user-defined props using key-value mapping.
* 2.provide a LABEL mechanism, which is tooking use of by geoGraphicsScene to display props on map.
* 3.defines 2 interface, for Inheritance classes, give them optunities to maintain coordinates change when zooming.
*/
class
geoItemBase
{
friend
class
geoGraphicsScene
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录