Monthly Archives: July 2011

augmented reality api

Qualcomm (for iOS and Android)
http://developer.qualcomm.com/dev/augmented-reality

Great blog on smart phone AR libraries
http://jwill.pixnet.net/blog/category/1364150

Advertisements

Good tutorial of using Flot

Flot is a very efficient JQuery library for plotting graphs.
Here is a great tutorial, by Bob Cravens:

http://blog.bobcravens.com/2011/01/web-charts-using-jquery-flot/

Getting started with jQuery:
http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery

Wiring events in arcGIS VB.NET 10 and VBA

In VB.NET:
http://www.esri.com/news/arcuser/1005/files/eventdriven.pdf

 

 

 

http://edndoc.esri.com/arcobjects/9.2/NET/ViewCodePages/e9d3cad8-0770-466a-a62d-6cd9d059c464Form1.vb.htm

 
Public Class Form1

‘ ***** SECTION (Start): Declare Event Handlers

‘ Notes:
‘ Variables are prefixed with an ‘m_’ denoting that they are member variables.
‘ This means they are global in scope for this class.

‘ The different IActiveViewEvents_XXXXXXXXX are ‘hidden types’ and do not show
‘ up using intellisense in VB.NET of Visaul Studio 2005. You can see them
‘ however using the Object Browser.
Private m_ActiveViewEventsAfterDraw As ESRI.ArcGIS.Carto.IActiveViewEvents_AfterDrawEventHandler
Private m_ActiveViewEventsAfterItemDraw As ESRI.ArcGIS.Carto.IActiveViewEvents_AfterItemDrawEventHandler
Private m_ActiveViewEventsContentsChanged As ESRI.ArcGIS.Carto.IActiveViewEvents_ContentsChangedEventHandler
Private m_ActiveViewEventsContentsCleared As ESRI.ArcGIS.Carto.IActiveViewEvents_ContentsClearedEventHandler
Private m_ActiveViewEventsFocusMapChanged As ESRI.ArcGIS.Carto.IActiveViewEvents_FocusMapChangedEventHandler
Private m_ActiveViewEventsItemAdded As ESRI.ArcGIS.Carto.IActiveViewEvents_ItemAddedEventHandler
Private m_ActiveViewEventsItemDeleted As ESRI.ArcGIS.Carto.IActiveViewEvents_ItemDeletedEventHandler
Private m_ActiveViewEventsItemReordered As ESRI.ArcGIS.Carto.IActiveViewEvents_ItemReorderedEventHandler
Private m_ActiveViewEventsSelectionChanged As ESRI.ArcGIS.Carto.IActiveViewEvents_SelectionChangedEventHandler
Private m_ActiveViewEventsSpatialReferenceChanged As ESRI.ArcGIS.Carto.IActiveViewEvents_SpatialReferenceChangedEventHandler
Private m_ActiveViewEventsViewRefreshed As ESRI.ArcGIS.Carto.IActiveViewEvents_ViewRefreshedEventHandler
‘ ***** SECTION (End): Declare Event Handlers

Private Sub btnStep1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStep1.Click

‘ map is set by referencing the public shared member variable (m_map) in the
‘ CommandWiringEvents class. This is one way to pass variables between classes in an application.
Dim map As ESRI.ArcGIS.Carto.IMap = CommandWiringEvents.m_map

TextBox3.Clear()

‘ ***** SECTION (Start): Set up the event handlers for all of the IActiveViewEvents

‘ Notes:
‘ You set the member IActiveViewEvents_XXXXXXXXX variables to the EventHandler
‘ for the specific events you want to capture. VB.NET uses the AddressOf
‘ operator to emulate ‘C++’ pointer like functionality.

‘ Create an instance of the delegate, add it to AfterDraw event
m_ActiveViewEventsAfterDraw = New ESRI.ArcGIS.Carto.IActiveViewEvents_AfterDrawEventHandler(AddressOf OnActiveViewEventsAfterDraw)
AddHandler CType(map, ESRI.ArcGIS.Carto.IActiveViewEvents_Event).AfterDraw, m_ActiveViewEventsAfterDraw

‘ Create an instance of the delegate, add it to AfterItemDraw event
m_ActiveViewEventsAfterItemDraw = New ESRI.ArcGIS.Carto.IActiveViewEvents_AfterItemDrawEventHandler(AddressOf OnActiveViewEventsItemDraw)
AddHandler CType(map, ESRI.ArcGIS.Carto.IActiveViewEvents_Event).AfterItemDraw, m_ActiveViewEventsAfterItemDraw

‘ Create an instance of the delegate, add it to ContentsChanged event
m_ActiveViewEventsContentsChanged = New ESRI.ArcGIS.Carto.IActiveViewEvents_ContentsChangedEventHandler(AddressOf OnActiveViewEventsContentsChanged)
AddHandler CType(map, ESRI.ArcGIS.Carto.IActiveViewEvents_Event).ContentsChanged, m_ActiveViewEventsContentsChanged

‘ Create an instance of the delegate, add it to ContentsCleared event
m_ActiveViewEventsContentsCleared = New ESRI.ArcGIS.Carto.IActiveViewEvents_ContentsClearedEventHandler(AddressOf OnActiveViewEventsContentsCleared)
AddHandler CType(map, ESRI.ArcGIS.Carto.IActiveViewEvents_Event).ContentsCleared, m_ActiveViewEventsContentsCleared

‘ Create an instance of the delegate, add it to FocusMapChanged event
m_ActiveViewEventsFocusMapChanged = New ESRI.ArcGIS.Carto.IActiveViewEvents_FocusMapChangedEventHandler(AddressOf OnActiveViewEventsFocusMapChanged)
AddHandler CType(map, ESRI.ArcGIS.Carto.IActiveViewEvents_Event).FocusMapChanged, m_ActiveViewEventsFocusMapChanged

‘ Create an instance of the delegate, add it to ItemAdded event
m_ActiveViewEventsItemAdded = New ESRI.ArcGIS.Carto.IActiveViewEvents_ItemAddedEventHandler(AddressOf OnActiveViewEventsItemAdded)
AddHandler CType(map, ESRI.ArcGIS.Carto.IActiveViewEvents_Event).ItemAdded, m_ActiveViewEventsItemAdded

‘ Create an instance of the delegate, add it to ItemDeleted event
m_ActiveViewEventsItemDeleted = New ESRI.ArcGIS.Carto.IActiveViewEvents_ItemDeletedEventHandler(AddressOf OnActiveViewEventsItemDeleted)
AddHandler CType(map, ESRI.ArcGIS.Carto.IActiveViewEvents_Event).ItemDeleted, m_ActiveViewEventsItemDeleted

‘ Create an instance of the delegate, add it to ItemReordered event
m_ActiveViewEventsItemReordered = New ESRI.ArcGIS.Carto.IActiveViewEvents_ItemReorderedEventHandler(AddressOf OnActiveViewEventsItemReordered)
AddHandler CType(map, ESRI.ArcGIS.Carto.IActiveViewEvents_Event).ItemReordered, m_ActiveViewEventsItemReordered

‘ Create an instance of the delegate, add it to SelectionChanged event
m_ActiveViewEventsSelectionChanged = New ESRI.ArcGIS.Carto.IActiveViewEvents_SelectionChangedEventHandler(AddressOf OnActiveViewEventsSelectionChanged)
AddHandler CType(map, ESRI.ArcGIS.Carto.IActiveViewEvents_Event).SelectionChanged, m_ActiveViewEventsSelectionChanged

‘ Create an instance of the delegate, add it to SpatialReferenceChanged event
m_ActiveViewEventsSpatialReferenceChanged = New ESRI.ArcGIS.Carto.IActiveViewEvents_SpatialReferenceChangedEventHandler(AddressOf OnActiveViewEventsSpatialReferenceChanged)
AddHandler CType(map, ESRI.ArcGIS.Carto.IActiveViewEvents_Event).SpatialReferenceChanged, m_ActiveViewEventsSpatialReferenceChanged

‘ Create an instance of the delegate, add it to ViewRefreshed event
m_ActiveViewEventsViewRefreshed = New ESRI.ArcGIS.Carto.IActiveViewEvents_ViewRefreshedEventHandler(AddressOf OnActiveViewEventsViewRefreshed)
AddHandler CType(map, ESRI.ArcGIS.Carto.IActiveViewEvents_Event).ViewRefreshed, m_ActiveViewEventsViewRefreshed
‘ ***** SECTION (End): Set up the event handlers for all of the IActiveViewEvents

End Sub

Private Sub btnStep3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStep3.Click

‘ map is set by referencing the public shared member variable (m_map) in the
‘ CommandWiringEvents class. This is one way to pass variables between classes in an application.
Dim map As ESRI.ArcGIS.Carto.IMap = CommandWiringEvents.m_map

‘ ***** SECTION (Start): Remove Event Handlers
RemoveHandler CType(map, ESRI.ArcGIS.Carto.IActiveViewEvents_Event).AfterDraw, m_ActiveViewEventsAfterDraw

RemoveHandler CType(map, ESRI.ArcGIS.Carto.IActiveViewEvents_Event).AfterItemDraw, m_ActiveViewEventsAfterItemDraw

RemoveHandler CType(map, ESRI.ArcGIS.Carto.IActiveViewEvents_Event).ContentsChanged, m_ActiveViewEventsContentsChanged

RemoveHandler CType(map, ESRI.ArcGIS.Carto.IActiveViewEvents_Event).ContentsCleared, m_ActiveViewEventsContentsCleared

RemoveHandler CType(map, ESRI.ArcGIS.Carto.IActiveViewEvents_Event).FocusMapChanged, m_ActiveViewEventsFocusMapChanged

RemoveHandler CType(map, ESRI.ArcGIS.Carto.IActiveViewEvents_Event).ItemAdded, m_ActiveViewEventsItemAdded

RemoveHandler CType(map, ESRI.ArcGIS.Carto.IActiveViewEvents_Event).ItemDeleted, m_ActiveViewEventsItemDeleted

RemoveHandler CType(map, ESRI.ArcGIS.Carto.IActiveViewEvents_Event).ItemReordered, m_ActiveViewEventsItemReordered

RemoveHandler CType(map, ESRI.ArcGIS.Carto.IActiveViewEvents_Event).SelectionChanged, m_ActiveViewEventsSelectionChanged

RemoveHandler CType(map, ESRI.ArcGIS.Carto.IActiveViewEvents_Event).SpatialReferenceChanged, m_ActiveViewEventsSpatialReferenceChanged

RemoveHandler CType(map, ESRI.ArcGIS.Carto.IActiveViewEvents_Event).ViewRefreshed, m_ActiveViewEventsViewRefreshed
‘ ***** SECTION (End): Remove Event Handlers

End Sub

‘ ***** SECTION (Start): Custom Functions that you write to add additionaly functionality for the events
‘ Event handler
Private Sub OnActiveViewEventsAfterDraw(ByVal Display As ESRI.ArcGIS.Display.IDisplay, ByVal phase As ESRI.ArcGIS.Carto.esriViewDrawPhase)
‘ Add your code here
‘ System.Windows.Forms.MessageBox.Show(“AfterDraw”)
TextBox3.Text = TextBox3.Text + vbCrLf + “AfterDraw”
End Sub

‘ Event handler
Private Sub OnActiveViewEventsItemDraw(ByVal Index As Short, ByVal Display As ESRI.ArcGIS.Display.IDisplay, ByVal phase As ESRI.ArcGIS.esriSystem.esriDrawPhase)
‘ Add your code here
‘ System.Windows.Forms.MessageBox.Show(“ItemDraw”)
TextBox3.Text = TextBox3.Text + vbCrLf + “ItemDraw”
End Sub

‘ Event handler
Private Sub OnActiveViewEventsContentsChanged()
‘ Add your code here
‘ System.Windows.Forms.MessageBox.Show(“ContentsChanged”)
TextBox3.Text = TextBox3.Text + vbCrLf + “ContentsChanged”
End Sub

‘ Event handler
Private Sub OnActiveViewEventsContentsCleared()
‘ Add your code here
‘ System.Windows.Forms.MessageBox.Show(“ContentsCleared”)
TextBox3.Text = TextBox3.Text + vbCrLf + “ContentsCleared”
End Sub

‘ Event handler
Private Sub OnActiveViewEventsFocusMapChanged()
‘ Add your code here
‘ System.Windows.Forms.MessageBox.Show(“FocusMapChanged”)
TextBox3.Text = TextBox3.Text + vbCrLf + “FocusMapChanged”
End Sub

‘ Event handler
Private Sub OnActiveViewEventsItemAdded(ByVal Item As Object)
‘ Add your code here
‘ System.Windows.Forms.MessageBox.Show(“ItemAdded”)
TextBox3.Text = TextBox3.Text + vbCrLf + “ItemAdded”
End Sub

‘ Event handler
Private Sub OnActiveViewEventsItemDeleted(ByVal Item As Object)
‘ Add your code here
‘ System.Windows.Forms.MessageBox.Show(“ItemDeleted”)
TextBox3.Text = TextBox3.Text + vbCrLf + “ItemDeleted”
End Sub

‘ Event handler
Private Sub OnActiveViewEventsItemReordered(ByVal Item As Object, ByVal toIndex As Integer)
‘ Add your code here
‘ System.Windows.Forms.MessageBox.Show(“ItemReordered”)
TextBox3.Text = TextBox3.Text + vbCrLf + “ItemReordered”
End Sub

‘ Event handler
Private Sub OnActiveViewEventsSelectionChanged()
‘ Add your code here
‘ System.Windows.Forms.MessageBox.Show(“SelectionChanged”)
TextBox3.Text = TextBox3.Text + vbCrLf + “SelectionChanged”
End Sub

‘ Event handler
Private Sub OnActiveViewEventsSpatialReferenceChanged()
‘ Add your code here
‘ System.Windows.Forms.MessageBox.Show(“SpatialReferenceChanged”)
TextBox3.Text = TextBox3.Text + vbCrLf + “SpatialReferenceChanged”
End Sub

‘ Event handler
Private Sub OnActiveViewEventsViewRefreshed(ByVal view As ESRI.ArcGIS.Carto.IActiveView, ByVal phase As ESRI.ArcGIS.Carto.esriViewDrawPhase, ByVal data As Object, ByVal envelope As ESRI.ArcGIS.Geometry.IEnvelope)
‘ Add your code here
‘ System.Windows.Forms.MessageBox.Show(“ViewRefreshed”)
TextBox3.Text = TextBox3.Text + vbCrLf + “ViewRefreshed”
End Sub
‘ ***** SECTION (End): Custom Functions that you write to add additionaly functionality for the events

End Class

Include PDF file in vbproj

       Add the pdf file in Resources 

        Dim pdf As Byte() = My.Resources.Help
        Using tmp As New FileStream("Help.pdf", FileMode.Create)
            tmp.Write(pdf, 0, pdf.Length)
        End Using
        Process.Start("Help.pdf")

How to start developing Mixare iOS

After downloading:

Build Settings, Architecture section, Valid Architectures option, click grey arrow to expand, double-click on right of Debug, after “armv6 armv7” add “i386”.

Excel Number Formats

http://peltiertech.com/Excel/NumberFormats.html

PhoneGap

To implement GPS and map functionality on a mobile device (say Iphone), you can do:

1. Use MapViewUI with iOS in Xcode

2. Use BingMap with ArcGIS Mobile iOS API

3. Use HTML with Dreamweaver (which uses PhoneGap)

4. Use PhoneGap on Xcode

The easiest way is 1. But if you want immediate cross-mobile platforms functionality, use PhoneGap.

If you want to use maps on your arcServer, use 2.

Understanding VB .NET Code Part 2

1. Backcolor

VB.Net: Drawing.Color.White

VBA: http://mc-computing.com/languages/Colors.htm

2. Calling Form Actions

VB.NET: function_click(Nothing, Nothing)

VBA: function_click:()

3. ComboBox

VB.NET: ByVal cbo As System.Windows.Forms.ComboBox;

cbo.Item.Clear

cbo.Item.Add

VBA: cbo As ComboBox

cbo.Clear

cbo.AddItem

Reference: http://msdn.microsoft.com/en-us/library/system.windows.forms.combobox.aspx

4. OpenSchema

VB.NET: RecordSet = Conn.OpenSchema(ADODB.SchemaEnum.adSchemaTables, New Object() {Nothing, Nothing, tableToFind, “table”})

VBA: Set RecordSet = Conn.OpenSchema(adSchemaTables, Array(Empty, Empty, tableToFind, “TABLE”))

Open Excel with ArcGIS VBA

To open Excel with ArcGIS VBA,

First, add Microsoft Object Library 12.0 in Tools>Reference.

Then use this code:

‘vba
Dim ExcelApp As Object
On Error Resume Next

Set ExcelApp = GetObject(, “Excel.Application”)

If ExcelApp Is Nothing Then ‘Excel isn’t already open
Set ExcelApp = CreateObject(“Excel.Application”)
End If

ExcelApp.Workbooks.Open (“C:\temp\New Microsoft Office Excel Worksheet.xls”)

ExcelApp.Visible = True

 

ExcelApp.Range(“A1”).value = 100

Understanding VB.NET Code

1. Option Explicit: Used at file level to force explicit declaration of all variables in that file.

When Option Explicit appears in a file, you must explicitly declare all variables using the Dim, Private, Public, or ReDim statements. If you attempt to use an undeclared variable name, an error occurs at compile time.

If you don’t use the Option Explicit statement, all undeclared variables are of Object type.

VBA: Option Explicit

VB.NET: Option Explicit On

Reference: http://msdn.microsoft.com/en-us/library/y9341s4f(v=vs.71).aspx

2. Declare Statement: Used at module level to declare references to external procedures in a dynamic-link library (DLL).

[Public | Private] Declare Function name Lib “libname” [Alias “aliasname”] [([arglist])] [As type]

Reference: http://msdn.microsoft.com/en-us/library/aa243324(v=vs.60).aspx

VBA: ByVal field As Any

VB.Net: ByVal field As Object

Reference: http://social.msdn.microsoft.com/Forums/en/vbinterop/thread/2c87df7c-48ad-4ab8-a6b8-e0e277eb74ec

3. Radio Buttons (or Option Buttons)

VBA: RadioButton.Value

VB.NET: RadioButton.Checked

When grouped under a GroupBox, users will only be able to select one radio button.

4. Common Dialogue

FileOpenDialog.Filter

VBA:  .. +  “Microstation files (*.dgn)|*.DGN|”

VB.NET:   .. + “Microstation files (*.dgn)|*.DGN”

Note that vb.net does not allow a vertical bar at the end of the very last one of the Filter Options

5. Left and Right Function

In VB.NET, add:

Imports VBStrings = Microsoft.VisualBasic.Strings

and use

VBStrings.Left