1 / 46

Create Your Own Application in SuperGIS Desktop

Create Your Own Application in SuperGIS Desktop. Presented by : Olivia Lin. Outline. Preparation works What software do I need? Source of sample codes Online source: Supergeo Developer Network (SGDN) Modify sample codes Add a spatial query tool Unregister this application.

gunter
Download Presentation

Create Your Own Application in SuperGIS Desktop

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Create Your Own Application in SuperGIS Desktop Presented by : Olivia Lin

  2. Outline • Preparation works • What software do I need? • Source of sample codes • Online source: Supergeo Developer Network (SGDN) • Modify sample codes • Add a spatial query tool • Unregister this application

  3. Preparation works • Developed by • Microsoft Visual Studio • Language : C # , C ++ • COM architecture • SuperGIS Desktop

  4. Source of Sample Code • Supergeo Developer Network (SGDN) • http://sgdn.supergeotek.com/

  5. r

  6. In SGDN, you’ll find more:

  7. Get starting from SGDN

  8. Example-Simple Map Information Sample • This sample contains: • Toolbar • Combo box • Drop-down menu • Button

  9. Example -Simple Map Information Sample

  10. Simple Map Information Sample • Step 1 Search and download the code from SGDN • Resource Center > Supergeo Samples • Products: SuperGIS Desktop, SuperGIS Extension • Languages & Platforms: C # • Key words : map information

  11. Simple Map Information Sample • Step 2 Set Start Action for application debugging • Select SuperGIS.exe for Start external program • C:\Program Files\Supergeo\SuperGIS Desktop\SuperGIS.exe (32-bit) • C:\Program Files (x86)\Supergeo\SuperGIS Desktop\SuperGIS.exe (64-bit)

  12. Simple Map Information Sample • Step 3 Start to debug this application • In SuperGIS Desktop, you’ll see

  13. Live demonstration

  14. Modify sample codes- Add a spatial query tool to toolbar

  15. Modify sample codes- Add a spatial query tool to toolbar • Drag a rectangle over features and then retrieve the attribute in a message window.

  16. Important Factors in Designing Spatial Query • Add a class to inherit ITool & ICommand • Perform the main action of Spatial Query tool in SGCore.ITool.OnMouseDown

  17. Add a class

  18. Add a class

  19. Add reference • Add reference • SGDataAcess • SGMap • SuperGeo User Interface 1.0 Type Library • using System.Runtime.InteropServices; • using System.Drawing

  20. Set the class to visible • [ComVisible(true)] • query is a public class • Inherit ITool, Icommand

  21. Implement ITool • Click on “SGCore” > Select “Implement interface SGCore.ITool”

  22. Design this tool

  23. SGCore.ITrackTarget • Detect user’s action by SGCore.ITrackTarget TkTgt; • The track can be a circle, a linestring, a polygon or a rectangle.

  24. SGCore.ICommandTarget • Set the button’s target map object • SGCore.ICommandTarget pMapTgt;

  25. Start to design • public IntPtr Cursor //mouse cursor style • { • get • { • System.Windows.Forms.Cursor m_cursor; • m_cursor = System.Windows.Forms.Cursors.Cross; • return (IntPtr)m_cursor.Handle; • } • }

  26. public bool OnContextMenu(int x, int y) • { • return true; • } • public void OnDblClick() • { • throw new NotImplementedException(); • } • public void OnHook(SGCore.ITrackTarget Hook) • { • TkTgt = Hook; • }

  27. public void OnKeyDown(short KeyCode, short Shift) • { • throw new NotImplementedException(); • } • public void OnKeyUp(short KeyCode, short Shift) • { • throw new NotImplementedException(); • }

  28. public void OnMouseDown(short Button, short Shift, int x, int y) • { • // Edit the command here • } • public void OnMouseMove(short Button, short Shift, int x, int y) • { • throw new NotImplementedException(); • } • public void OnMouseUp(short Button, short Shift, int x, int y) • { • throw new NotImplementedException(); • }

  29. public void OnMouseDown(short Button, short Shift, int x, int y) { SGCore.ILayerGroup LG = ((SuperObjects2.IMapCtrl)pMapTgt).Map as SGCore.ILayerGroup; SGMap.FeatureLayer plyr; plyr = (SGMap.FeatureLayer)LG.Layer[0]; //the tool for drag a rectangle SGUserInterface.TrackFeedbackNewEnvelope tk = new SGUserInterface.TrackFeedbackNewEnvelope(); SGSFCOMS.IGeometry pGeo; pGeo = TkTgt.Track((SGCore.ITrackFeedback)tk); //built the spatial query with intersect relationship SGDataAccess.BinarySpatialOperator pSpQry = new SGDataAccess.BinarySpatialOperator(); pSpQry.OperatorType = SGDataAccess.SGOBinarySpatialOperatorType.SGO_BSOT_Intersects; pSpQry.Geometry = pGeo; SGCore.IFeatureCursor pCur; SGCore.IFeature pFea; pCur = ((SGCore.IFeatureLayer)plyr).FeatureClass.Search((SGCore.IFeatureFilter)pSpQry); pFea = pCur.NextFeature(); while (!(pFea == null)) { System.Windows.Forms.MessageBox.Show(pFea[3].ToString()); //Indicate the field to display pFea = pCur.NextFeature(); } }

  30. public void OnMouseDown(short Button, short Shift, int x, int y) { SGCore.ILayerGroup LG = ((SuperObjects2.IMapCtrl)pMapTgt).Map as SGCore.ILayerGroup; SGMap.FeatureLayer plyr; plyr = (SGMap.FeatureLayer)LG.Layer[0]; //the tool for drag a rectangle SGUserInterface.TrackFeedbackNewEnvelope tk = new SGUserInterface.TrackFeedbackNewEnvelope(); SGSFCOMS.IGeometry pGeo; pGeo = TkTgt.Track((SGCore.ITrackFeedback)tk); //built the spatial query with intersect relationship SGDataAccess.BinarySpatialOperator pSpQry = new SGDataAccess.BinarySpatialOperator(); pSpQry.OperatorType = SGDataAccess.SGOBinarySpatialOperatorType.SGO_BSOT_Intersects; pSpQry.Geometry = pGeo; SGCore.IFeatureCursor pCur; SGCore.IFeature pFea; pCur = ((SGCore.IFeatureLayer)plyr).FeatureClass.Search((SGCore.IFeatureFilter)pSpQry); pFea = pCur.NextFeature(); while (!(pFea == null)) { System.Windows.Forms.MessageBox.Show(pFea[3].ToString()); //Indicate the field to display pFea = pCur.NextFeature(); } } Define the map and the target layer

  31. public void OnMouseDown(short Button, short Shift, int x, int y) { SGCore.ILayerGroup LG = ((SuperObjects2.IMapCtrl)pMapTgt).Map as SGCore.ILayerGroup; SGMap.FeatureLayer plyr; plyr = (SGMap.FeatureLayer)LG.Layer[0]; //the tool for drag a rectangle SGUserInterface.TrackFeedbackNewEnvelope tk = new SGUserInterface.TrackFeedbackNewEnvelope(); SGSFCOMS.IGeometry pGeo; pGeo = TkTgt.Track((SGCore.ITrackFeedback)tk); //built the spatial query with intersect relationship SGDataAccess.BinarySpatialOperator pSpQry = new SGDataAccess.BinarySpatialOperator(); pSpQry.OperatorType = SGDataAccess.SGOBinarySpatialOperatorType.SGO_BSOT_Intersects; pSpQry.Geometry = pGeo; SGCore.IFeatureCursor pCur; SGCore.IFeature pFea; pCur = ((SGCore.IFeatureLayer)plyr).FeatureClass.Search((SGCore.IFeatureFilter)pSpQry); pFea = pCur.NextFeature(); while (!(pFea == null)) { System.Windows.Forms.MessageBox.Show(pFea[3].ToString()); //Indicate the field to display pFea = pCur.NextFeature(); } } Decide the queried shape

  32. public void OnMouseDown(short Button, short Shift, int x, int y) { SGCore.ILayerGroup LG = ((SuperObjects2.IMapCtrl)pMapTgt).Map as SGCore.ILayerGroup; SGMap.FeatureLayer plyr; plyr = (SGMap.FeatureLayer)LG.Layer[0]; //the tool for drag a rectangle SGUserInterface.TrackFeedbackNewEnvelope tk = new SGUserInterface.TrackFeedbackNewEnvelope(); SGSFCOMS.IGeometry pGeo; pGeo = TkTgt.Track((SGCore.ITrackFeedback)tk); //built the spatial query with intersect relationship SGDataAccess.BinarySpatialOperator pSpQry = new SGDataAccess.BinarySpatialOperator(); pSpQry.OperatorType = SGDataAccess.SGOBinarySpatialOperatorType.SGO_BSOT_Intersects; pSpQry.Geometry = pGeo; SGCore.IFeatureCursor pCur; SGCore.IFeature pFea; pCur = ((SGCore.IFeatureLayer)plyr).FeatureClass.Search((SGCore.IFeatureFilter)pSpQry); pFea = pCur.NextFeature(); while (!(pFea == null)) { System.Windows.Forms.MessageBox.Show(pFea[3].ToString()); //Indicate the field to display pFea = pCur.NextFeature(); } } pSpQry is a query object Set the query action

  33. public void OnMouseDown(short Button, short Shift, int x, int y) { SGCore.ILayerGroup LG = ((SuperObjects2.IMapCtrl)pMapTgt).Map as SGCore.ILayerGroup; SGMap.FeatureLayer plyr; plyr = (SGMap.FeatureLayer)LG.Layer[0]; //the tool for drag a rectangle SGUserInterface.TrackFeedbackNewEnvelope tk = new SGUserInterface.TrackFeedbackNewEnvelope(); SGSFCOMS.IGeometry pGeo; pGeo = TkTgt.Track((SGCore.ITrackFeedback)tk); //built the spatial query with intersect relationship SGDataAccess.BinarySpatialOperator pSpQry = new SGDataAccess.BinarySpatialOperator(); pSpQry.OperatorType = SGDataAccess.SGOBinarySpatialOperatorType.SGO_BSOT_Intersects; pSpQry.Geometry = pGeo; SGCore.IFeatureCursor pCur; SGCore.IFeature pFea; pCur = ((SGCore.IFeatureLayer)plyr).FeatureClass.Search((SGCore.IFeatureFilter)pSpQry); pFea = pCur.NextFeature(); while (!(pFea == null)) { System.Windows.Forms.MessageBox.Show(pFea[3].ToString()); //Indicate the field to display pFea = pCur.NextFeature(); } } Execute Spatial Query

  34. public void OnMouseDown(short Button, short Shift, int x, int y) • { • // Edit the command here • } • public void OnMouseMove(short Button, short Shift, int x, int y) • { • throw new NotImplementedException(); • } • public void OnMouseUp(short Button, short Shift, int x, int y) • { • throw new NotImplementedException(); • }

  35. public bool QueryDeactivate() • { • TkTgt = null; • return true; • }

  36. Implement ICommand • Click on “SGCore” > Select “Implement interface SGCore.ICommand”

  37. Start to design • public string Caption • { • get { return "Spatial Query"; } • } • public bool Checked • { • get { return (TkTgt != null); } • }

  38. public bool Enabled • { • get { return true; } • } • public string HelpFile • { • get { return "NO Help"; } • }

  39. public IntPtr Image • { • get { return m_Icon.Handle; } • } • public int HelpTopicID • { • get { return 0; } • } • public string Name • { • get { return "Spatial Query"; } • } Declare Icon m_Icon = null;

  40. public void OnCommand(SGCore.ICommandTarget Parent) • { • pMapTgt = Parent; • // The button of the target map • // Use pMapTgt (ICommandTarget) to catch Parent • } • public string ToolTip • { • get { return "Spatial Query"; } • }

  41. Add to the Toolbar • //In SimpleMapInfoToolbar.cs, add query • Query queryBtn = new Query(); • m_Cmd.Add(queryBtn);

  42. Run this project

  43. Live demonstration

  44. Unregister this application • In Windows Command Prompt, under C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ • For C# > RegAsm.exe /u“<path>/<filename>.dll” • For C++ > Regsvr32 /u “<path>/<filename>.dll”

  45. Live demonstration

  46. Supergeo Technologies Inc.www.supergeotek.com THANK YOU FOR JOINING THIS COURSE

More Related