Download presentation
Presentation is loading. Please wait.
Published byCordelia Parrish Modified over 9 years ago
1
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 2
3
Preparation works Developed by –Microsoft Visual Studio –Language : C #, C ++ –COM architecture SuperGIS Desktop 3
4
Source of Sample Code Supergeo Developer Network (SGDN)SGDN –http://sgdn.supergeotek.com/ 4
5
r 5
6
In SGDN, you’ll find more: 6
7
Get starting from SGDN 7
8
Example- Simple Map Information Sample This sample contains: Toolbar Combo box Drop-down menu Button 8
9
Example - Simple Map Information Sample 9
10
Simple Map Information Sample Step 1 Search and download the code from SGDN –R–Resource Center > Supergeo Samples –P–Products: SuperGIS Desktop, SuperGIS Extension –L–Languages & Platforms: C # –K–Key words : map information 10
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) 11
12
Simple Map Information Sample Step 3 Start to debug this application In SuperGIS Desktop, you’ll see 12
13
Live demonstration 13
14
14 Modify sample codes - Add a spatial query tool to toolbar
15
Drag a rectangle over features and then retrieve the attribute in a message window. 15
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 16
17
Add a class 17
18
Add a class 18
19
Add reference –SGDataAcess –SGMap –SuperGeo User Interface 1.0 Type Library –using System.Runtime.InteropServices; –using System.Drawing 19
20
Set the class to visible –[ComVisible(true)] query is a public class Inherit ITool, Icommand 20
21
Implement ITool Click on “SGCore” > Select “Implement interface SGCore.ITool” 21
22
Design this tool 22
23
SGCore.ITrackTarget Detect user’s action by SGCore.ITrackTarget TkTgt; The track can be a circle, a linestring, a polygon or a rectangle. 23
24
SGCore.ICommandTarget Set the button’s target map object SGCore.ICommandTarget pMapTgt; 24
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; } 25
26
public bool OnContextMenu(int x, int y) { return true; } public void OnDblClick() { throw new NotImplementedException(); } public void OnHook(SGCore.ITrackTarget Hook) { TkTgt = Hook; } 26
27
public void OnKeyDown(short KeyCode, short Shift) { throw new NotImplementedException(); } public void OnKeyUp(short KeyCode, short Shift) { throw new NotImplementedException(); } 27
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(); } 28
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(); } 29
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 30
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 31
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(); } Set the query action pSpQry is a query object 32
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 33
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(); } 34
35
public bool QueryDeactivate() { TkTgt = null; return true; } 35
36
Implement ICommand Click on “SGCore” > Select “Implement interface SGCore.ICommand” 36
37
Start to design public string Caption { get { return "Spatial Query"; } } public bool Checked { get { return (TkTgt != null); } } 37
38
public bool Enabled { get { return true; } } public string HelpFile { get { return "NO Help"; } } 38
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; Declare Icon m_Icon = null; 39
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"; } } 40
41
Add to the Toolbar //In SimpleMapInfoToolbar.cs, add query Query queryBtn = new Query(); m_Cmd.Add(queryBtn); 41
42
Run this project 42
43
43 Live demonstration
44
Unregister this application In Windows Command Prompt, under C:\WINDOWS\Microsoft.NET\Framework\v2.0.5072 7\ –For C# > RegAsm.exe /u “ /.dll” –For C++ > Regsvr32 /u “ /.dll” 44
45
45 Live demonstration
46
Supergeo Technologies Inc. www.supergeotek.com THANK YOU FOR JOINING THIS COURSE 46
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.