MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




Enjoy Mobile GIS (2) Using C# to edit the electronic map in your mobile phone

This is a discussion on Enjoy Mobile GIS (2) Using C# to edit the electronic map in your mobile phone within the Other Mapping Platforms forums, part of the Map Forums category; Foreword: This article is the extension of << Enjoy Mobile GIS(1) Using C# to create a GIS program of mobile ...


Go Back   MapPoint Forums > Map Forums > Other Mapping Platforms

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read



Click here to register

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-18-2008
dyh dyh is offline
Junior Member
White Belt
 
Join Date: Nov 2008
Posts: 2
Smile Enjoy Mobile GIS (2) Using C# to edit the electronic map in your mobile phone

Foreword: This article is the extension of <<Enjoy Mobile GIS(1) Using C# to create a GIS program of mobile phone>>. It will show how to using C# edit the .shp map file of ESRI based on HiMap.
Some download for this article: code: myHiMapAdvanced.zip , map file: maps.zip , demo animation: myHiMapVideo2.gif .
I. System requirements.
Development Environment:: Windows XP, .NET Compact Framework 2.0, Windows Mobile 5 SDK, HiMap Beta1 runtime
Run-time Environment: DOPOD D600 mobile phone(ARM CPU) (Windows Mobile 5.0)
II.Function List:
1. Draw Geometry
2. Edit Geometry
3. Delete Geometry
4. Edit Property



III.About the realization:
First, we will have a brief introduction of these basic function. For more description of functions, please consult <<HiMap Help>>
//1.Create a new feature
//Get a layer
IFeatureLayer lyr = (IFeatureLayer)mapControl1.Map.GetLayer(0);
//Get a featureClass of the layer
IFeatureClass cls = (IFeatureClass)lyr.Class;
//Create a feature for this featureClass
IFeature feat = cls.CreateFeature();
//Save the change
feat.Save();
//2.Delete a feature
//Get a layer
IFeatureLayer lyr = (IFeatureLayer)mapControl1.Map.GetLayer(0);
//Get a featureClass of layer
IFeatureClass cls = (IFeatureClass)lyr.Class;
//Create a query filter of featureClass
IQueryFilter qf=new QueryFilterClass();
//Setup query condition
qf.WhereClause="id =1";
//Query data
IFeatureCursor cur = cls.Search(qf);
//Get the feature of query result
IFeature feat = cur.Next();
//Delete a feature
if (feat != null)
{
cls.DeleteFeature(feat);
}
//3.Update the value of a feature
//First of all, get a layer
IFeatureLayer lyr = (IFeatureLayer)mapControl1.Map.GetLayer(0);
//Get a featureClass
IFeatureClass cls = (IFeatureClass)lyr.Class;
//Create a filter of query
IQueryFilter qf=new QueryFilterClass();
//Setup the condition of query
qf.WhereClause="id =1";
//Query data
IFeatureCursor cur = cls.Search(qf);
//Get the feature of query result
IFeature feat = cur.Next();
if (feat != null)
{
//update the value "test data" to the field "name"
feat.SetValue(cls.Fields.FindField("name"), "test data");
//save change
feat.Save();
}
//4.Update the geometry of a feature

//Get a layer first
IFeatureLayer lyr = (IFeatureLayer)mapControl1.Map.GetLayer(0);
//Get a featureClass
IFeatureClass cls = (IFeatureClass)lyr.Class;
//Create a query filter
IQueryFilter qf=new QueryFilterClass();
//Setup query condition
qf.WhereClause="id =1";
//Query data
IFeatureCursor cur = cls.Search(qf);
//Get the feature of query result
IFeature feat = cur.Next();
if (feat != null)
{
//Because the layer is a line type layer, so we use the IPolyling to get the geometry
HiMap.Geometry.IPolyline line = (HiMap.Geometry.IPolyline)feat.Shape;
IPointCollection chline = (IPointCollection)line;
//Create some points(the LGT and LTT are for test only)
IPoint pt1 = new PointClass();
pt1.X = "111.2345556";
pt1.Y = "23.2345556";
IPoint pt2 = new PointClass();
pt2.X = "112.2345556";
pt2.Y = "23.3345556";
//Add points to the line
chline.AddPoint(pt1);
chline.AddPoint(pt2);
//Give the shape value of updated to the feature
feat.Shape = (IGeometry)line;
//Save change
feat.Save();
}
//5.Add parts to ployline and polygon

//Get a layer
IFeatureLayer lyr = (IFeatureLayer)mapControl1.Map.GetLayer(0);
//Get a featureClass
IFeatureClass cls = (IFeatureClass)lyr.Class;
//Create a query filter
IQueryFilter qf=new QueryFilterClass();
//Setup condition of query filter
qf.WhereClause="id =1";
//Query data
IFeatureCursor cur = cls.Search(qf);
//Get a feature by query
IFeature feat = cur.Next();
if (feat != null)
{
//Because the layer is a line type layer, so we use the IPolyling to get the geometry
HiMap.Geometry.IPolyline line = (HiMap.Geometry.IPolyline)feat.Shape;
//Create a new line
IPointCollection chline = new PolylineClass();
//Create points for new the line(test data too)
IPoint pt1 = new PointClass();
pt1.X = "111.2345556";
pt1.Y = "23.2345556";
IPoint pt2 = new PointClass();
pt2.X = "112.2345556";
pt2.Y = "23.3345556";
//Add points to the new line
chline.AddPoint(pt1);
chline.AddPoint(pt2);
HiMap.Geometry.IGeometryCollection geoColl = (HiMap.Geometry.IGeometryCollection)line;
//Add the new line to original line
geoColl.AddGeometry((IGeometry)chline);
//Give the value of geometry to feature
feat.Shape = (IGeometry)line;
//Save change
feat.Save();
}
IV.Sample animation and code:
Download the demo animation: myHiMapVideo2.gif
Download the sample code: myHiMapAdvanced.zip
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
edit, electronic, enjoy, gis, himap, k-work, map, mobile, mobile gis, phone


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
using C# to create a GIS program of mobile phone dyh Other Mapping Platforms 0 11-02-2008 09:13 PM
Tracking your GPS-enabled Mobile Phone Johannes Kebeck's Blog Virtual Earth Blogs 0 03-26-2008 04:00 PM
Help me choose my next mobile phone VE Team Virtual Earth Blogs 0 12-18-2007 09:01 PM
Innovative scenarios for mobile learning at the Seriously Mobile Workshop Eric Frost Press Releases 0 05-08-2007 07:30 PM
Sprint Launches First Phone With Windows Mobile 5.0 Platform Eric Frost News and Announcements 0 09-18-2005 10:41 AM


All times are GMT -5. The time now is 05:44 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
MP2K Magazine
Visitor Map


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55