Create Your Own Application in Super GIS Desktop

  • Slides: 46
Download presentation
Create Your Own Application in Super. GIS Desktop Presented by : Olivia Lin

Create Your Own Application in Super. GIS Desktop Presented by : Olivia Lin

Outline • Preparation works – What software do I need? • Source of sample

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

Preparation works • Developed by – Microsoft Visual Studio – Language : C #

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

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

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

r 5

r 5

In SGDN, you’ll find more: 6

In SGDN, you’ll find more: 6

GET STARTING FROM SGDN 7

GET STARTING FROM SGDN 7

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

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

Example Simple Map Information Sample 9

Example Simple Map Information Sample 9

Simple Map Information Sample • Step 1 Search and download the code from SGDN

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

Simple Map Information Sample • Step 2 Set Start Action for application debugging –

Simple Map Information Sample • Step 2 Set Start Action for application debugging – Select Super. GIS. exe for Start external program • C: Program FilesSupergeoSuper. GIS DesktopSuper. GIS. exe (32 -bit) • C: Program Files (x 86)SupergeoSuper. GIS DesktopSuper. GIS. exe (64 -bit) 11

Simple Map Information Sample • Step 3 Start to debug this application • In

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

Live demonstration 13

Live demonstration 13

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

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

Modify sample codes - Add a spatial query tool to toolbar • Drag a

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

Important Factors in Designing Spatial Query • Add a class to inherit ITool &

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

Add a class 17

Add a class 17

Add a class 18

Add a class 18

Add reference • Add reference – SGData. Acess – SGMap – Super. Geo User

Add reference • Add reference – SGData. Acess – SGMap – Super. Geo User Interface 1. 0 Type Library – using System. Runtime. Interop. Services; – using System. Drawing 19

 • Set the class to visible – [Com. Visible(true)] • query is a

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

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

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

Design this tool 22

Design this tool 22

SGCore. ITrack. Target • Detect user’s action by SGCore. ITrack. Target Tk. Tgt; •

SGCore. ITrack. Target • Detect user’s action by SGCore. ITrack. Target Tk. Tgt; • The track can be a circle, a linestring, a polygon or a rectangle. 23

SGCore. ICommand. Target • Set the button’s target map object • SGCore. ICommand. Target

SGCore. ICommand. Target • Set the button’s target map object • SGCore. ICommand. Target p. Map. Tgt; 24

Start to design • public Int. Ptr Cursor //mouse cursor style • { •

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

 • public bool On. Context. Menu(int x, int y) • { • return

• public bool On. Context. Menu(int x, int y) • { • return true; • } • public void On. Dbl. Click() • { • throw new Not. Implemented. Exception(); • } • • public void On. Hook(SGCore. ITrack. Target Hook) { Tk. Tgt = Hook; } 26

 • public void On. Key. Down(short Key. Code, short Shift) • { •

• public void On. Key. Down(short Key. Code, short Shift) • { • throw new Not. Implemented. Exception(); • } • public void On. Key. Up(short Key. Code, short Shift) • { • throw new Not. Implemented. Exception(); • } 27

 • public void On. Mouse. Down(short Button, short Shift, int x, int y)

• public void On. Mouse. Down(short Button, short Shift, int x, int y) • { • // Edit the command here • } • public void On. Mouse. Move(short Button, short Shift, int x, int y) • { • throw new Not. Implemented. Exception(); • } • public void On. Mouse. Up(short Button, short Shift, int x, int y) • { • throw new Not. Implemented. Exception(); 28 • }

public void On. Mouse. Down(short Button, short Shift, int x, int y) { SGCore.

public void On. Mouse. Down(short Button, short Shift, int x, int y) { SGCore. ILayer. Group LG = ((Super. Objects 2. IMap. Ctrl)p. Map. Tgt). Map as SGCore. ILayer. Group; SGMap. Feature. Layer plyr; plyr = (SGMap. Feature. Layer)LG. Layer[0]; //the tool for drag a rectangle SGUser. Interface. Track. Feedback. New. Envelope tk = new SGUser. Interface. Track. Feedback. New. Envelope(); SGSFCOMS. IGeometry p. Geo; p. Geo = Tk. Tgt. Track((SGCore. ITrack. Feedback)tk); //built the spatial query with intersect relationship SGData. Access. Binary. Spatial. Operator p. Sp. Qry = new SGData. Access. Binary. Spatial. Operator(); p. Sp. Qry. Operator. Type = SGData. Access. SGOBinary. Spatial. Operator. Type. SGO_BSOT_Intersects; p. Sp. Qry. Geometry = p. Geo; SGCore. IFeature. Cursor p. Cur; SGCore. IFeature p. Fea; p. Cur = ((SGCore. IFeature. Layer)plyr). Feature. Class. Search((SGCore. IFeature. Filter)p. Sp. Qry); p. Fea = p. Cur. Next. Feature(); while (!(p. Fea == null)) { System. Windows. Forms. Message. Box. Show(p. Fea[3]. To. String()); //Indicate the field to display p. Fea = p. Cur. Next. Feature(); } } 29

public void On. Mouse. Down(short Button, short Shift, int x, int y) { SGCore.

public void On. Mouse. Down(short Button, short Shift, int x, int y) { SGCore. ILayer. Group LG = ((Super. Objects 2. IMap. Ctrl)p. Map. Tgt). Map as SGCore. ILayer. Group; SGMap. Feature. Layer plyr; plyr = (SGMap. Feature. Layer)LG. Layer[0]; Define the map and the target layer //the tool for drag a rectangle SGUser. Interface. Track. Feedback. New. Envelope tk = new SGUser. Interface. Track. Feedback. New. Envelope(); SGSFCOMS. IGeometry p. Geo; p. Geo = Tk. Tgt. Track((SGCore. ITrack. Feedback)tk); //built the spatial query with intersect relationship SGData. Access. Binary. Spatial. Operator p. Sp. Qry = new SGData. Access. Binary. Spatial. Operator(); p. Sp. Qry. Operator. Type = SGData. Access. SGOBinary. Spatial. Operator. Type. SGO_BSOT_Intersects; p. Sp. Qry. Geometry = p. Geo; SGCore. IFeature. Cursor p. Cur; SGCore. IFeature p. Fea; p. Cur = ((SGCore. IFeature. Layer)plyr). Feature. Class. Search((SGCore. IFeature. Filter)p. Sp. Qry); p. Fea = p. Cur. Next. Feature(); while (!(p. Fea == null)) { System. Windows. Forms. Message. Box. Show(p. Fea[3]. To. String()); //Indicate the field to display p. Fea = p. Cur. Next. Feature(); } } 30

public void On. Mouse. Down(short Button, short Shift, int x, int y) { SGCore.

public void On. Mouse. Down(short Button, short Shift, int x, int y) { SGCore. ILayer. Group LG = ((Super. Objects 2. IMap. Ctrl)p. Map. Tgt). Map as SGCore. ILayer. Group; SGMap. Feature. Layer plyr; plyr = (SGMap. Feature. Layer)LG. Layer[0]; //the tool for drag a rectangle SGUser. Interface. Track. Feedback. New. Envelope tk = new SGUser. Interface. Track. Feedback. New. Envelope(); SGSFCOMS. IGeometry p. Geo; Decide the queried shape p. Geo = Tk. Tgt. Track((SGCore. ITrack. Feedback)tk); //built the spatial query with intersect relationship SGData. Access. Binary. Spatial. Operator p. Sp. Qry = new SGData. Access. Binary. Spatial. Operator(); p. Sp. Qry. Operator. Type = SGData. Access. SGOBinary. Spatial. Operator. Type. SGO_BSOT_Intersects; p. Sp. Qry. Geometry = p. Geo; SGCore. IFeature. Cursor p. Cur; SGCore. IFeature p. Fea; p. Cur = ((SGCore. IFeature. Layer)plyr). Feature. Class. Search((SGCore. IFeature. Filter)p. Sp. Qry); p. Fea = p. Cur. Next. Feature(); while (!(p. Fea == null)) { System. Windows. Forms. Message. Box. Show(p. Fea[3]. To. String()); //Indicate the field to display p. Fea = p. Cur. Next. Feature(); } } 31

public void On. Mouse. Down(short Button, short Shift, int x, int y) { SGCore.

public void On. Mouse. Down(short Button, short Shift, int x, int y) { SGCore. ILayer. Group LG = ((Super. Objects 2. IMap. Ctrl)p. Map. Tgt). Map as SGCore. ILayer. Group; SGMap. Feature. Layer plyr; plyr = (SGMap. Feature. Layer)LG. Layer[0]; //the tool for drag a rectangle SGUser. Interface. Track. Feedback. New. Envelope tk = new SGUser. Interface. Track. Feedback. New. Envelope(); SGSFCOMS. IGeometry p. Geo; p. Sp. Qry is a query object p. Geo = Tk. Tgt. Track((SGCore. ITrack. Feedback)tk); //built the spatial query with intersect relationship SGData. Access. Binary. Spatial. Operator p. Sp. Qry = new SGData. Access. Binary. Spatial. Operator(); p. Sp. Qry. Operator. Type = SGData. Access. SGOBinary. Spatial. Operator. Type. SGO_BSOT_Intersects; p. Sp. Qry. Geometry = p. Geo; SGCore. IFeature. Cursor p. Cur; SGCore. IFeature p. Fea; p. Cur = ((SGCore. IFeature. Layer)plyr). Feature. Class. Search((SGCore. IFeature. Filter)p. Sp. Qry); p. Fea = p. Cur. Next. Feature(); Set the query action while (!(p. Fea == null)) { System. Windows. Forms. Message. Box. Show(p. Fea[3]. To. String()); //Indicate the field to display p. Fea = p. Cur. Next. Feature(); } } 32

public void On. Mouse. Down(short Button, short Shift, int x, int y) { SGCore.

public void On. Mouse. Down(short Button, short Shift, int x, int y) { SGCore. ILayer. Group LG = ((Super. Objects 2. IMap. Ctrl)p. Map. Tgt). Map as SGCore. ILayer. Group; SGMap. Feature. Layer plyr; plyr = (SGMap. Feature. Layer)LG. Layer[0]; //the tool for drag a rectangle SGUser. Interface. Track. Feedback. New. Envelope tk = new SGUser. Interface. Track. Feedback. New. Envelope(); SGSFCOMS. IGeometry p. Geo; p. Geo = Tk. Tgt. Track((SGCore. ITrack. Feedback)tk); //built the spatial query with intersect relationship SGData. Access. Binary. Spatial. Operator p. Sp. Qry = new SGData. Access. Binary. Spatial. Operator(); p. Sp. Qry. Operator. Type = SGData. Access. SGOBinary. Spatial. Operator. Type. SGO_BSOT_Intersects; p. Sp. Qry. Geometry = p. Geo; SGCore. IFeature. Cursor p. Cur; SGCore. IFeature p. Fea; p. Cur = ((SGCore. IFeature. Layer)plyr). Feature. Class. Search((SGCore. IFeature. Filter)p. Sp. Qry); p. Fea = p. Cur. Next. Feature(); while (!(p. Fea == null)) { System. Windows. Forms. Message. Box. Show(p. Fea[3]. To. String()); //Indicate the field to display p. Fea = p. Cur. Next. Feature(); Execute Spatial Query } } 33

 • public void On. Mouse. Down(short Button, short Shift, int x, int y)

• public void On. Mouse. Down(short Button, short Shift, int x, int y) • { • // Edit the command here • } • public void On. Mouse. Move(short Button, short Shift, int x, int y) • { • throw new Not. Implemented. Exception(); • } • public void On. Mouse. Up(short Button, short Shift, int x, int y) • { • throw new Not. Implemented. Exception(); 34 • }

 • • • public bool Query. Deactivate() { Tk. Tgt = null; return

• • • public bool Query. Deactivate() { Tk. Tgt = null; return true; } 35

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

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

Start to design • public string Caption • { • get { return "Spatial

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

 • public bool Enabled • { • get { return true; } •

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

 • • public Int. Ptr Image { get { return m_Icon. Handle; }

• • public Int. Ptr Image { get { return m_Icon. Handle; } } Declare Icon m_Icon = null; • public int Help. Topic. ID • { • get { return 0; } • public string Name • { • get { return "Spatial Query"; } • } 39

 • public void On. Command(SGCore. ICommand. Target Parent) • { • p. Map.

• public void On. Command(SGCore. ICommand. Target Parent) • { • p. Map. Tgt = Parent; • // The button of the target map • // Use p. Map. Tgt (ICommand. Target) to catch Parent • } • • public string Tool. Tip { get { return "Spatial Query"; } } 40

Add to the Toolbar • //In Simple. Map. Info. Toolbar. cs, add query •

Add to the Toolbar • //In Simple. Map. Info. Toolbar. cs, add query • Query query. Btn = new Query(); • m_Cmd. Add(query. Btn); 41

Run this project 42

Run this project 42

Live demonstration 43

Live demonstration 43

Unregister this application • In Windows Command Prompt, under C: WINDOWSMicrosoft. NETFrameworkv 2. 0.

Unregister this application • In Windows Command Prompt, under C: WINDOWSMicrosoft. NETFrameworkv 2. 0. 5072 7 – For C# > Reg. Asm. exe /u “<path>/<filename>. dll” – For C++ > Regsvr 32 /u “<path>/<filename>. dll” 44

Live demonstration 45

Live demonstration 45

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

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