MapObject shape数据操作
利用MO 的GeoDataset 、DataConnection Recordset 进行数据操作
在MO中。使用GeoDataset对象和DataConnection 对象来连接和读取地理数据。
GeoDataset: 是表达一个图层的地利数据的对象
DatasetConnection对象指定一个和地理数据文件的连接,用Database 属性表示数据文件的地址。
Recordset 是Geodataset的记录集合或者查询后的数据集合
下面给一段 他们的使用 主要用于加载shp数据集并通过遍历获取线的每个节点
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MapObjects2; namespace mo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public MapObjects2.MapLayer AddShape(string basepath, string fileName, bool mHasMeasure)
{
DataConnection dCon = new DataConnection();
GeoDataset gSet;
mHasMeasure = false; dCon.Database = basepath; if (dCon.Connect())
{
gSet = dCon.FindGeoDataset(fileName);
if (gSet == null)
{
MessageBox.Show("打开shape文件异常");
return null;
}
else
{
MapLayer newLayer = new MapLayer();
newLayer.GeoDataset = gSet;
mHasMeasure = gSet.HasMeasure;
dCon = null;
gSet = null;
MessageBox.Show(newLayer.Records.Count.ToString());
return newLayer;
}
}
else
{
dCon = null;
gSet = null;
return null;
}
} private void Form1_Load(object sender, EventArgs e)
{ }
// h获取 图层中的每个节点
public void getLine(string mPath, string Name,bool fea)
{
Application.DoEvents();
string txt = null;
MapObjects2.MapLayer mLay;
MapObjects2.Recordset mrec;
Line mline = new Line();
MapObjects2.Point mpt = new MapObjects2.Point(); ;
mLay = AddShape(mPath, Name, false);
mrec = mLay.Records;
do
{
//从第一条数据开始处理
//MessageBox.Show(mrec.Fields.Item("shape").);
mline = mrec.Fields.Item("shape").Value ;
MessageBox.Show(mline.Parts.Count.ToString()); String mlxdm = mrec.Fields.Item("roadcode").Value.ToString();
MessageBox.Show(mlxdm);
if (mline.Parts.Count < 1)
{
MessageBox.Show("line is nothing");
break;
}
for (int i = 0; i < mline.Parts.Count; i++)
{
MapObjects2.Points pt= mline.Parts.Item(i) as MapObjects2.Points; for (int j = 0; j < pt.Count;j++ )
{
richTextBox1.Text = "x=" + pt.Item(j).X.ToString() + " y=" + pt.Item(j).Y.ToString() + " z=" + pt.Item(j).Z.ToString() + "\n" +richTextBox1.Text ;
//MessageBox.Show("x=" + pt.Item(i).X.ToString() + " y=" + pt.Item(i).Y.ToString() + " z=" + pt.Item(i).Z.ToString());
// MessageBox.Show( pt.ToString());
} }
mrec.MoveNext();
} while (!mrec.EOF);
} private void button1_Click(object sender, EventArgs e)
{
getLine(Application.StartupPath + "\\layerdata", "nmg_route", true);
}
}
}
MapObject shape数据操作的更多相关文章
- python数据结构:pandas(2)数据操作
一.Pandas的数据操作 0.DataFrame的数据结构 1.Series索引操作 (0)Series class Series(base.IndexOpsMixin, generic.NDFra ...
- pytorch 数据操作
数据操作 在深度学习中,我们通常会频繁地对数据进行操作.作为动手学深度学习的基础,本节将介绍如何对内存中的数据进行操作. 在PyTorch中,torch.Tensor是存储和变换数据的主要工具.如果你 ...
- StackExchange.Redis帮助类解决方案RedisRepository封装(字符串类型数据操作)
本文版权归博客园和作者本人共同所有,转载和爬虫请注明原文链接 http://www.cnblogs.com/tdws/tag/NoSql/ 目录 一.基础配置封装 二.String字符串类型数据操作封 ...
- hive数据操作
mdl是数据操作类的语言,包括向数据表加载文件,写查询结果等操作 hive有四种导入数据的方式 >从本地加载数据 LOAD DATA LOCAL INPATH './examples/files ...
- Dapper 数据操作框架
数据操作DapperFrom NuGet:Install-Package DapperorInstall-Package Dapper.StrongName微型ORM:PetaPoco获得PetaPo ...
- Django数据操作F和Q、model多对多操作、Django中间件、信号、读数据库里的数据实现分页
models.tb.objects.all().using('default'),根据using来指定在哪个库里查询,default是settings中配置的数据库的连接名称. 外话:django中引 ...
- coreData数据操作
// 1. 建立模型文件// 2. 建立CoreDataStack// 3. 设置AppDelegate 接着 // // CoreDataStack.swift // CoreDataStackDe ...
- Entity Framework 5.0系列之数据操作
Entity Framework将概念模型中定义的实体和关系映射到数据源,利用实体框架可以将数据源返回的数据具体化为对象:跟踪对象所做的更改:并发处理:将对象更改传播到数据源等.今天我们就一起讨论如何 ...
- 数据操作语言DML与运算符
数据操作语言DML(添加,修改,删除) 1.添加数据 insert into insert into 表名 (字段列表) values (值列表),值列表要和字段列表按顺序匹配. insert int ...
随机推荐
- adodb配置与使用
=========================================php100:80:ADODB PHP数据库万能引擎类 ADODB PHP数据库介绍与特点 ADODB 是一种兼容的各 ...
- Memcache,Redis
Memcache Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态.数据库驱动网站的速度. ...
- bitVector@ java bit自我practice##Q&A:为何int 来初始化size of bitVector?long,甚至是BigInteger等策略
/* * BitSets are packed into arrays of "words." Currently a word is * a long, which consis ...
- PinchEvent QML Type
PinchEvent类型在QtQuick 1.1中被添加进来.center, startCenter, previousCenter属性保存了两个触摸点之间的中心位置.scale and previo ...
- Linux内存映射(mmap)系列(1)
看到同事的代码中出现了mmap.所以自己私下学习学习,研究研究..... http://www.cnblogs.com/lknlfy/archive/2012/04/27/2473804.html ( ...
- iOS 中KVC、KVO、NSNotification、delegate 总结及区别-b
1.KVC,即是指 NSKeyValueCoding,一个非正式的Protocol,提供一种机制来间接访问对象的属性.而不是通过调用Setter.Getter方法访问.KVO 就是基于 KVC 实现的 ...
- JDK下sun.net.www.protocol.http.HttpURLConnection类-----Http客户端实现类的实现分析
HttpClient类是进行TCP连接的实现类, package sun.net.www.http; import java.io.*; import java.net.*; import java. ...
- 同步的HTTP请求
代码: #import <Foundation/Foundation.h> void request(NSString *urlString) { NSLog(@"BEGIN&q ...
- bzoj 1014: [JSOI2008]火星人prefix hash && splay
1014: [JSOI2008]火星人prefix Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 3154 Solved: 948[Submit][ ...
- Codeforces 713 C Sonya and Problem Wihtout a Legend
Description Sonya was unable to think of a story for this problem, so here comes the formal descript ...