地图函数结构Word格式文档下载.docx

上传人:b****4 文档编号:7929277 上传时间:2023-05-09 格式:DOCX 页数:15 大小:17.64KB
下载 相关 举报
地图函数结构Word格式文档下载.docx_第1页
第1页 / 共15页
地图函数结构Word格式文档下载.docx_第2页
第2页 / 共15页
地图函数结构Word格式文档下载.docx_第3页
第3页 / 共15页
地图函数结构Word格式文档下载.docx_第4页
第4页 / 共15页
地图函数结构Word格式文档下载.docx_第5页
第5页 / 共15页
地图函数结构Word格式文档下载.docx_第6页
第6页 / 共15页
地图函数结构Word格式文档下载.docx_第7页
第7页 / 共15页
地图函数结构Word格式文档下载.docx_第8页
第8页 / 共15页
地图函数结构Word格式文档下载.docx_第9页
第9页 / 共15页
地图函数结构Word格式文档下载.docx_第10页
第10页 / 共15页
地图函数结构Word格式文档下载.docx_第11页
第11页 / 共15页
地图函数结构Word格式文档下载.docx_第12页
第12页 / 共15页
地图函数结构Word格式文档下载.docx_第13页
第13页 / 共15页
地图函数结构Word格式文档下载.docx_第14页
第14页 / 共15页
地图函数结构Word格式文档下载.docx_第15页
第15页 / 共15页
亲,该文档总共15页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

地图函数结构Word格式文档下载.docx

《地图函数结构Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《地图函数结构Word格式文档下载.docx(15页珍藏版)》请在冰点文库上搜索。

地图函数结构Word格式文档下载.docx

QStringStrTemp="

"

;

intok=mapFile.open(QIODevice:

:

ReadOnly);

if(ok)

{

QTextStreamt(&

mapFile);

while(StrTemp!

="

Data"

t>

>

StrTemp;

}

while(!

t.atEnd())

while(StrTemp!

Pline"

t>

StrTemp;

vertexs;

//读线段段数

//qDebug()<

<

vertexs="

vertexs;

//调试时输出顶点数

for(inti=0;

i<

i++)

{

long>

lat;

longs.append(long);

lats.append(lat);

}

charTemp;

while(charTemp!

='

('

penwidth>

charTemp>

penpattern>

pencolor>

//读线宽,风格,颜色。

pen.setWidth(penwidth);

//设线宽

pen.setStyle(Qt:

SolidLine);

//设画线风格为实线

pen.setColor(pencolor);

//设画笔颜色

if(longs.count()>

0&

&

(longs.count()==lats.count()))

{

mappolyline=newMap_PolyLine();

}

else

return;

//函数结束,不执行后面的语句

for(i=0;

longs.count()-1;

line=newQGraphicsLineItem();

line->

setLine(QLineF(convertCoord(longs.at(i),lats.at(i)),convertCoord(longs.at(i+1),lats.at(i+1))));

//line->

setLine(QLineF(convertCoord(lats.at(i),longs.at(i)),convertCoord(lats.at(i+1),longs.at(i+1))));

setPen(pen);

mappolyline->

mapPolyLine.append(line);

mapPolyLines.append(mappolyline);

//添加一个折线对象进折线链表

}

}

 

//读区域函数

voidMap_Layer:

GetRegion(mitab_featurefeature,QStringList&

fields)

Map_Region*region;

//定义指向区域类的指针

QPolygonF*polygon;

//

Map_Field*field;

//定义指向结构体的指针

intparts;

//线段数量

//顶点数量

//暂存经度

intpencolor;

QPenpen;

intbrushcolor;

//区域填充颜色

intbrushpattern;

//填充风格

//QBrushbrush(QColor(Qt:

black));

//这里比较ds奇怪,必须这样,后面的setColor才起作用

block.mif"

Region1"

//读区域顶点数量

//设画笔颜色,风格为实线,线宽

pen.setColor(pencolor);

pen.setStyle(Qt:

pen.setWidth(penwidth);

//pen.setBrush(QBrush(QColor(Qt:

blue)));

/*if(penpattern==2)

{

}

else

DashLine);

}*/

brushcolor=mitab_c_get_brush_fgcolor(feature);

//读取填充颜色

//qDebug()<

fgbrushcolor="

brushcolor;

brushpattern=mitab_c_get_brush_pattern(feature);

brushpattern="

brushpattern;

brush.setColor(QColor(brushcolor));

region=newMap_Region();

for(i=0;

fields.count();

field=newMap_Field;

//开地图区域结构体保存区域名,区域填充

field->

fieldName=fields.at(i);

//读区域名

fieldContent=mitab_c_get_field_as_string(feature,i);

//

qDebug()<

fieldNameis"

field->

fieldName<

fieldcontentis"

fieldContent;

region->

mapFields.append(field);

if(field->

fieldName=="

Name"

regionName->

setPlainText(field->

fieldContent);

parts=mitab_c_get_parts(feature);

//读对象折线段数量

parts="

parts;

vertexs=mitab_c_get_vertex_count(feature,i);

//读顶点数

for(j=0;

j<

j++)

longs.append(mitab_c_get_vertex_x(feature,i,j));

lats.append(mitab_c_get_vertex_y(feature,i,j));

if(longs.count()>

//region=newMap_Region();

polygon=newQPolygonF();

return;

count="

longs;

longs.count();

{

polygon->

append(QPointF(convertCoord(longs.at(i),lats.at(i))));

if(polygon->

count()>

0)

X="

polygon->

boundingRect().center().x()<

Y="

boundingRect().center().y();

//region->

setX(polygon->

boundingRect().center().x());

setY(polygon->

boundingRect().center().y());

mapPolygon->

setBrush(brush);

setPolygon(*polygon);

mapRegions.append(region);

//另外的读取方法(一个图元的显示)

if(graphicsName=="

Region"

laton>

count>

count;

//记录区域顶点数

for(inti=0;

laton>

x>

y;

//x存放经度,y存放纬度

point=newQPointF(((x-x1)/wx)*w-w/2,((y1-y)/hy)*h-h/2);

//把经纬度转为QGraphicsSense坐标后存到point中

pointfRegion<

*point;

//把转换后的点存进pointfRegion容器中

pPolygonF=newQPolygonF(pointfRegion);

//创建多边形

pPolygonItem=newQGraphicsPolygonItem(*pPolygonF);

//创建多边形图元

if(graphicsAttribute=="

Pen"

)//一个图元的点描述后就是该图元的边界画笔,用Pen表示

latlon>

penColor;

sColor.append(penColor);

pen.setColor(QColor(sColor.section("

"

2,2),remove(Qchar('

)'

),Qt:

CaseInsensitive).toDouble()));

//获取画笔颜色

pPolygonItem->

//设置图元边界颜色

Brush"

)//该图元的边界画笔描述完,继续用Brush表示填充颜色

brushColor;

sColor.append(brushColor);

brush.setColor(sColor.section("

1,1).toDouble);

pPolygonItem->

//对图元进行颜色填充

scene->

addIten(pPolygonItem);

//最后把图元添加到画布上

classMapTextItem

public:

MapTextItem(QStringstr);

MapTextItem();

virtual~MapTextItem(void);

QGraphicsTextItem*mapTextItem;

//存放当前QGraphicsTextItem的地址

MapTextItem*nextTextItem;

//存放下一个QgraphicsTextItem的地址

};

通过对数据的处理而获取所有地图中文本图元。

当检测到一个图元是就添加到链表的末端,直到没有为止。

if(graphicsName=="

Text"

latlon>

graphicsName;

//获取文本信息

x>

mapText=newMapTextItem(graphicsName);

mapText->

mapTextItem->

setPos(((x-x1)/wx)*w-w/2,((y1-y)/hy)*h-h/2);

addItem(mapText->

mapTextItem);

//在地图上面显示

nextTextItem=mapTextItem->

nextTextItem;

mapTextItem->

nextTextItem=mapText;

//连接到链表中

voidreadMap()

null"

if(!

while()

x1>

y1>

x2>

y2;

map.load(mapName);

if(map.isNull())

printf("

mapisnull"

平面点a(x1,y1),b(x2,y2)

距离l=sqrt((x1-x2)(平方)+(y1-y2)(平方))

typedefstruct

intId1;

QList<

int>

overIds;

}overlapPoints;

QList<

overlapPoints>

overPointList;

overlapPointspointTemp;

for(inti=0;

i<

nodeList.length();

i++)

pointTemp.Id1=nodeList.at(i).nodeId;

for(intj=i+1;

j<

j++)

if(nodeList.at(j).latlon.longitude==nodeList.at(i).latlon.longitude&

nodeList.at(j).latlon.latitude==nodeList.at(i).latlon.latitude)

inttemp=nodeList.at(j).nodeId;

pointTemp.overIds.append(temp);

nodeList.removeAt(j);

j--;

if(pointTemp.overIds.count()>

=1)

overPointList.append(pointTemp);

intk;

k=nodeList.at(i).nodeId;

nodeList.at(i).nodeId=i;

for(intj=0;

overPointList.count();

if(overPointList.at(j).Id1==k)

if(roadList.at(k/2).startId==k)

roadList.at(k/2).startId=i;

else

roadList.at(k/2).endId=i;

for(intm=0;

m<

overPointList.at(j).overIds.count();

m++)

inttemp=overPointList.at(j).overIds.at(m);

if(roadList.at(temp/2).startId==temp)

roadList.at(temp/2).startId=i;

roadList.at(temp/2).endId=i;

overPointList.removeAt(j);

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 自然科学 > 物理

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2