查看完整版本: supermap特别应用问题

black560 2006-6-27 14:10

supermap特别应用问题

  在做地图平移操作时,如果双击操作则做地图查询
代码下载
距离量算时,每一次点击都显示距离.
代码下载
做鼠标事件时,在鼠标旁显示操作提示
代码下载
车辆跟踪
前提说明
       实际应用中还应考虑以下功能
自定义引擎实现外挂属性专题图
前提说明
       思路
       实现外挂属性表,首先要知道object是如何外挂属性表的。
       了解了以上过程,把两者结合一下,就可以实现题目的功能了。
       结果截图
       程序下载
地图显示范围为查询出来的所有点。
程序
多点求距离小于指定值的点
程序
IS .net 5 页面实时显示鼠标位置信息
程序及截图

black560 2006-6-27 14:12

在做地图平移操作时,如果双击操作则做地图查询
问:代码下载
答isnet5_dblquerypan.rar

black560 2006-6-27 14:13

距离量算时,每一次点击都显示距离.
问:代码下载
答:isnet5_discpointview.rar

black560 2006-6-27 14:19

做鼠标事件时,在鼠标旁显示操作提示
问:代码下载
答:isnet5_actiontip.rar

black560 2006-6-27 14:20

车辆跟踪
问:实际应用中还应考虑以下功能
答:定位车辆
单台车定位时出了显示范围是否自动改变范围
单台车定位是否需要实时居中
单台车定位是否需要可选上面的两种定位方式
多台车监控时出了显示范围是否自动改变范围
轨迹回放
是否需要轨迹回放功能
是否需要画出轨迹线
是否需要多台车轨迹同时回放
显示回放范围大小的地图,还是地图随车移动
性能
刷新时间是否由用户自己设置(还是固定)
车辆定位的刷新时间是多少
同时监控车辆的人数(客户端)可能有多少

black560 2006-6-27 14:22

自定义引擎实现外挂属性专题图
问:前提说明
答:开发环境 is .net 5.0.2
请先在自定义引擎开发文档里了解is .net 5 的引擎开发方式。
在调好引擎开发环境后做下面工作。
目前object支持单值和范围分段专题图的外挂属性
问:思路
答:由于5.0.2还不能在服务器上自动保存CustomParam,所以需要事先设置提交参数,用hashtable保存。
而在做其它生成图片前,取一下用户设置的参数,做相应操作。
客户端测试代码
MapParam mp = MapControl1.GetCurrentMapParam();
mp.CustomParams = string.Empty;
MapControl1.CustomInvoke(mp);
服务器端改写的代码
private System.Collections.Hashtable m_mp = new System.Collections.Hashtable();
public override MapImage CustomInvoke(MapParam mapParam)
{
if(!m_mp.ContainsKey(mapParam.UserToken.UserID))
{
   m_mp.Add(mapParam.UserToken.UserID,mapParam.CustomParams);
}
return base.CustomInvoke (mapParam);
}
protected override MapImage HandleBeforeCommand(ref MapParam mapParam, ref bool bCancel)//出图前做的事情
{
if(m_mp.ContainsKey(mapParam.UserToken.UserID))
{
   SetMap(m_mp[mapParam.UserToken.UserID].ToString());
}
return base.HandleBeforeCommand (ref mapParam, ref bCancel);
}
private void SetMap(string str)
{
//这里可以调用引擎里的supermap做相应的事了
//this.m_axSuperMap     
//this.m_axSuperWorkspace
}
把这些先调通再做下面的做专题图操作。
问:实现外挂属性表,首先要知道object是如何外挂属性表的。
答:可以用object示例程序先试一下如何外挂属性表
以单值专题图为例,在SuperWkspManager的C#示例里加如下代码
Code:
private void button2_Click(object sender, System.EventArgs e)
{
string str = "1:a,2:b,3:c,4:a,5:b,6:c,7:c";
      char[] split = new Char[] {','};
      string[] strValue = str.Split(split);// "1:50,2:60,3:40"
SuperMapLib.soStyle themeStyle = new SuperMapLib.soStyleClass();
      SuperMapLib.soLayer themeLayer = axSuperMap1.Layers[1];
      SuperMapLib.soThemeUnique themeUnique = themeLayer.ThemeUnique;
      themeUnique.Field = "smid";
      int i;
themeUnique.IsForeignValue = 2;
      themeUnique.ValueCount = 3;
      for(i=0; i<strValue.Length; i++)
      {
             char[] splitNew = new Char[] {':'};
             string[] strNewValue = strValue[i].Split(splitNew);
             themeUnique.set_ForeignValue(strNewValue[0], strNewValue[1]);
      }
themeUnique.set_Value(1, "a");
      themeUnique.set_Value(2, "b");
      themeUnique.set_Value(3, "c");
      themeStyle.PenColor  = ColorToRGB(System.Drawing.Color.Red);
      themeStyle.SymbolSize=100;
      themeUnique.set_Style(1, themeStyle);
      themeStyle.PenColor  = ColorToRGB(System.Drawing.Color.Green);
      themeStyle.SymbolSize=200;
      themeUnique.set_Style(2, themeStyle);
      themeStyle.PenColor  = ColorToRGB(System.Drawing.Color.Blue );
      themeStyle.SymbolSize=300;
      themeUnique.set_Style(3, themeStyle);
themeUnique.Enable = true;
      axSuperMap1.CtlRefresh();
}
private uint ColorToRGB(Color mycolor)
{
      uint tempcolor = (uint)(mycolor.R | (mycolor.G << 8) | (mycolor.B << 16));
      return tempcolor;
}
根据这个string str = "1:a,2:b,3:c,4:a,5:b,6:c,7:c";
smid为1的对应外挂属性为a,2->b,3->c,4->a...
指定用外挂属性做专题.
themeUnique.IsForeignValue = 2;
问:了解了以上过程,把两者结合一下,就可以实现题目的功能了。
答:客户端测试代码
private void Button4_Click(object sender, System.EventArgs e)
{
   MapParam mp = MapControl1.GetCurrentMapParam();
   //外挂属性
   mp.CustomParams = "1:a,2:b,3:c,4:a,5:b,6:c,7:c";
   MapControl1.CustomInvoke(mp);
   MapControl1.ViewEntire();
}
服务器端改写的代码,把SetMap做如下修改
Code:
private void SetMap(string str)
{
      char[] split = new Char[] {','};
      string[] strValue = str.Split(split);// "1:50,2:60,3:40"
//制作专题图
SuperMapLib.soStyle themeStyle = new SuperMapLib.soStyleClass();
      SuperMapLib.soLayer themeLayer = m_axSuperMap.Layers[1];
      SuperMapLib.soThemeUnique themeUnique = themeLayer.ThemeUnique;
      themeUnique.Field = "smid";
      int i;
themeUnique.IsForeignValue = 2;
      themeUnique.ValueCount = 3;
      for(i=0; i<strValue.Length; i++)
      {
             char[] splitNew = new Char[] {':'};
             string[] strNewValue = strValue[i].Split(splitNew);// "1:50,2:60,3:40"
             themeUnique.set_ForeignValue(strNewValue[0], strNewValue[1]);
      }
themeUnique.set_Value(1, "a");
      themeUnique.set_Value(2, "b");
      themeUnique.set_Value(3, "c");
      themeStyle.PenColor  = ColorToRGB(System.Drawing.Color.Red);
      themeStyle.SymbolSize=100;
      themeUnique.set_Style(1, themeStyle);
      themeStyle.PenColor  = ColorToRGB(System.Drawing.Color.Green);
      themeStyle.SymbolSize=200;
      themeUnique.set_Style(2, themeStyle);
      themeStyle.PenColor  = ColorToRGB(System.Drawing.Color.Blue );
      themeStyle.SymbolSize=300;
      themeUnique.set_Style(3, themeStyle);
themeUnique.Enable = true;
}
问:结果截图
答:
问:程序下载
答:is5_customengine_themeunique.rar
自定义引擎,单值专题图引擎下载,只提供DownloadEngine.cs,覆盖原来的文件就可以了

black560 2006-6-27 14:22

地图显示范围为查询出来的所有点。
问:程序
答:目前IS .net 5没有直接的方法,求bounds只能自己算一下.
Code:
      recordCount = curRecordset.Records.Length;
      Record curRecord;
      int valueCount;
      double dMaxX = curRecordset.Records[0].Center.X;
      double dMaxY = curRecordset.Records[0].Center.Y;
      double dMinX = curRecordset.Records[0].Center.X;
      double dMinY = curRecordset.Records[0].Center.Y;
      for(int j=1;j<recordCount;j++) {
             dMinX = Math.Min(dMinX,curRecord.Center.X);
             dMinY = Math.Min(dMinY,curRecord.Center.Y);
             dMaxX = Math.Max(dMaxX,curRecord.Center.X);
             dMaxY = Math.Max(dMaxY,curRecord.Center.Y);
      }
MapCoord rightTop = new MapCoord(dMaxX,dMaxY);
      MapCoord leftButtom = new MapCoord(dMinX,dMinY);
MapRect mapRect = new MapRect(leftButtom,rightTop);
      this.MapControl1.ViewByBounds(mapRect);

black560 2006-6-27 14:23

多点求距离小于指定值的点
问:程序
答:
Code:
private void PointList()
             {
                    //用程序把点位置取出存在数组里
                    Point[] p = new Point[5];
p[0] = new Point(100,200);
                    p[1] = new Point(300,200);                    
                    p[2] = new Point(400,200);                    
                    p[3] = new Point(100,500);                    
                    p[4] = new Point(600,200);       
                    //建一个同长度字符串
                    int len = p.Length ;
                    string[] pinfo = new string[len];
for(int i=0;i<len-1;i++)
                    {
                           pinfo[i] = i.ToString() + ":";
                           for(int j=i+1;j<len;j++)//不做重复统计
                           {
                                  if(PointToPoint(p[i],p[j],300))
                                  {
                                         pinfo[i]  += j.ToString()+";";
                                  }
                           }
                    }
             }
private bool PointToPoint(Point a,Point b ,double m)
             {
                    if((Math.Abs(a.X - b.X)>m)||(Math.Abs(a.Y - b.Y)>m))//先只做大体范围查询
                    {
                           return true;
                    }
                    if(Math.Sqrt(Math.Pow((a.X  - b.X ),2) + Math.Pow((x.Y - b.Y ),2))>m)
                    {       
                           return true;
                    }
                    else
                    {
                           return false;
                    }
             }

black560 2006-6-27 14:24

IS .net 5 页面实时显示鼠标位置信息
问:程序及截图
答:开发环境IS 5.0.1
使用车辆跟踪的数据
demo_cartrack.rar
实时显示鼠标位置信息
is5_mouseposition.rar

peter1985 2006-8-16 17:54

谢谢提供!

wxhanshan 2006-8-16 20:50

邮件通知

smxcxh 2006-9-16 09:20

不会呀

hai7692 2006-9-16 10:01

好代码

supermap制图交流

[size=12px]群:22858901[/size]
页: [1]
查看完整版本: supermap特别应用问题