MgFeatureProperty is for object properties (ie. You have a feature class that has another nested class definition)
As for the process of adding points. It basically is
1. Create your feature source
1.1 Create a feature class definition for the feature source
1.2 Add any properties to the feature class
1.3 Set the geometry type of the feature class to points
1.4 Save this to a session resource.
1.5 Set the spatial context equal to the SRS of the current MgMap, otherwise the points you insert may not be where you think they are.
2. Create a layer definition that references the created feature source
2.1 Create or load the xml content for this layer definition
2.2 Save this to a session resource.
3. Create an MgInsertFeatures command
3.1 Set the first parameter className = name of your created feature class
3.2 Create a property collection
3.2.1 Fill the property collection with the values you want to insert. Each value corresponds to a property in your feature class.
3.2.2 For the point feature, insert a MgGeometryProperty object. As a MgGeometryProperty requires a MgByteReader for the geometry value, use a MgGeometryFactory to create your MgGeometry object and convert it to a MgByteReader with a MgAgfReaderWriter instance.
3.3 Add this MgInsertFeatures command to your MgFeatureCommandCollection
3.4 Finally, pass this MgFeatureCommandCollection to the UpdateFeatures() method of your MgFeatureService. Also give it the resource id of the feature source you created.
3.5 You may need to close any open MgFeatureReaders in the result of UpdateFeatures(), this is what the code you posted is trying to do.
4. Finally refresh the map on the client side (manual or programmatically) and the point should be there.
That's a high level overview of it all. There may be a few bits that are slightly incorrect, but that is the general process flow.
2011年4月27日 星期三
2011年4月26日 星期二
Virtual PC LoopBack網卡應用
在上一篇文章中提到 Guest 的網路卡設定可以是對外的(直接使用Host的網卡或使用NAT方式)或是對內的(自建一個私有網路環境),但是如果使用者想自建一個只能與 Host 透過網路溝通且不對外公開的 Guest 環境,那麼不管選擇對外的網路卡或是對內的私有網路都無法達到這樣的需求。這樣的需求通常應用在服務上線前的自我測試環境。
解決這個問題可透過微軟所提供的 Loop Back 網路卡 方式來解決,作業程序如下:
1. 在 Host 作業系統安裝微軟 Loop Back 網卡。
1.1透過 開始-->執行功能執行 hdwwiz.exe 指令開啟新增硬體精靈。
1.2在新增硬體精靈視窗歡迎畫面按 下一步 按鈕。
1.3在精靈協助您安裝其他硬體畫面點選 安裝我從清單中手動選取的硬體(進階選項)(M) 後按 下一步 按鈕。
1.4在一般硬體類型清單中點選 網路介面卡 後按 下一步 按鈕。
1.5在網路介面卡 製造商 清單中點選 Microsoft ,接著在右邊的 網路介面卡 清單中點選 Microsoft Loopback Adapter 後按 下一步 按鈕。
1.6在 要安裝的硬體 畫面按 下一步 按鈕。
1.7在完成新增硬體精靈畫面按 完成 按鈕。此時可查看 Windows 7 控制台-->網路和網際網路-->網路連線的網路連線 會多出一個 區域連線x 無法識別的網路 Microsoft Loopback Adapter 的網路卡圖示。
2.規劃好 Loop Back 網卡使用的虛擬網段(通常使用172, 192,168 等私有網段)及 Host 與 Guest 的虛擬 IP 位址。
3.依規劃設定 Host 作業系統下的 Loop Back 網路卡的 IP 位址及 網路遮罩 (預設匣道器與DNS主機可以不用設)。
4.在 Host 作業系統下將 Guest 的網路卡設定為剛剛所建的 Loopback 網路介面卡,然後在進到 Guest 作業系統中設定該網路卡的 IP 位址(只要設 IP 位址 與 網路遮罩 資料即可)。
解決這個問題可透過微軟所提供的 Loop Back 網路卡 方式來解決,作業程序如下:
1. 在 Host 作業系統安裝微軟 Loop Back 網卡。
1.1透過 開始-->執行功能執行 hdwwiz.exe 指令開啟新增硬體精靈。
1.2在新增硬體精靈視窗歡迎畫面按 下一步 按鈕。
1.3在精靈協助您安裝其他硬體畫面點選 安裝我從清單中手動選取的硬體(進階選項)(M) 後按 下一步 按鈕。
1.4在一般硬體類型清單中點選 網路介面卡 後按 下一步 按鈕。
1.5在網路介面卡 製造商 清單中點選 Microsoft ,接著在右邊的 網路介面卡 清單中點選 Microsoft Loopback Adapter 後按 下一步 按鈕。
1.6在 要安裝的硬體 畫面按 下一步 按鈕。
1.7在完成新增硬體精靈畫面按 完成 按鈕。此時可查看 Windows 7 控制台-->網路和網際網路-->網路連線的網路連線 會多出一個 區域連線x 無法識別的網路 Microsoft Loopback Adapter 的網路卡圖示。
2.規劃好 Loop Back 網卡使用的虛擬網段(通常使用172, 192,168 等私有網段)及 Host 與 Guest 的虛擬 IP 位址。
3.依規劃設定 Host 作業系統下的 Loop Back 網路卡的 IP 位址及 網路遮罩 (預設匣道器與DNS主機可以不用設)。
4.在 Host 作業系統下將 Guest 的網路卡設定為剛剛所建的 Loopback 網路介面卡,然後在進到 Guest 作業系統中設定該網路卡的 IP 位址(只要設 IP 位址 與 網路遮罩 資料即可)。
於
上午8:40

2011年4月12日 星期二
數值資料字串格式化(VB篇)
D 或 d,代表「十進位」。
只有整數類資料型別 (Integral Type) 才支援這個格式。
數值將會被轉換為十進位數 (0-9) 的字串,如果數值為負數,則在前面加上負號。
例如下列範例會使用十進位格式規範格式化:
Dim value As Integer
value = 12345
outputBlock.Text &= value.ToString("D") & vbCrLf
' Displays 12345
outputBlock.Text &= value.ToString("D8") & vbCrLf
' Displays 00012345
value = -12345
outputBlock.Text &= value.ToString("D") & vbCrLf
' Displays -12345
outputBlock.Text &= value.ToString("D8") & vbCrLf
' Displays -0001234
F或f,代表「固定點」。
數字會轉換為 "ddd.ddd..." 型式的字串,其中 "d" 表示數字 (0-9)。
下列範例會使用定點格式規範格式化 Double 和 Int32 值。
Dim integerNumber As Integer
integerNumber = 17843
outputBlock.Text &= String.Format(integerNumber.ToString("F", CultureInfo.InvariantCulture)) & vbCrLf
' Displays 17843.00
integerNumber = -29541
outputBlock.Text &= String.Format(integerNumber.ToString("F3", CultureInfo.InvariantCulture)) & vbCrLf
' Displays -29541.000
Dim doubleNumber As Double
doubleNumber = 18934.1879
outputBlock.Text &= String.Format(doubleNumber.ToString("F", CultureInfo.InvariantCulture)) & vbCrLf
' Displays 18934.19
outputBlock.Text &= String.Format(doubleNumber.ToString("F0", CultureInfo.InvariantCulture)) & vbCrLf
' Displays 18934
doubleNumber = -1898300.1987
outputBlock.Text &= String.Format(doubleNumber.ToString("F1", CultureInfo.InvariantCulture)) & vbCrLf
' Displays -1898300.2
outputBlock.Text &= doubleNumber.ToString("F3", _
New CultureInfo("es-ES")) & vbCrLf
' Displays -1898300,199
N或n,代表數字。
數字會轉換為 "d,ddd,ddd.ddd…" 格式的字串、'd' 表示數字 (0-9)、',' 表示數字群組之間的千位分隔符號,
而 '.' 則表示小數點符號。
下列範例會使用數字格式規範來格式化各種浮點數值
。
Dim dblValue As Double = -12445.6789
outputBlock.Text &= String.Format(dblValue.ToString("N", CultureInfo.InvariantCulture)) & vbCrLf
' Displays -12,445.68
outputBlock.Text &= dblValue.ToString("N1", _
New CultureInfo("sv-SE")) & vbCrLf
' Displays -12?445,7
Dim intValue As Integer = 123456789
outputBlock.Text &= String.Format(intValue.ToString("N1", CultureInfo.InvariantCulture)) & vbCrLf
' Displays 123,456,789.0
P或p,代表百分比
下列範例會使用百分比格式規範來格式化浮點數值。
Dim number As Double = 0.2468013
outputBlock.Text &= String.Format(number.ToString("P", CultureInfo.InvariantCulture)) & vbCrLf
' Displays 24.68 %
outputBlock.Text &= number.ToString("P", _
New CultureInfo("hr-HR")) & vbCrLf
' Displays 24,68%
outputBlock.Text &= String.Format(number.ToString("P1", CultureInfo.InvariantCulture)) & vbCrLf
' Displays 24.7 %
D 或 d,代表「十進位」。
只有整數類資料型別 (Integral Type) 才支援這個格式。
數值將會被轉換為十進位數 (0-9) 的字串,如果數值為負數,則在前面加上負號。
例如下列範例會使用十進位格式規範格式化:
Dim value As Integer
value = 12345
outputBlock.Text &= value.ToString("D") & vbCrLf
' Displays 12345
outputBlock.Text &= value.ToString("D8") & vbCrLf
' Displays 00012345
value = -12345
outputBlock.Text &= value.ToString("D") & vbCrLf
' Displays -12345
outputBlock.Text &= value.ToString("D8") & vbCrLf
' Displays -0001234
F或f,代表「固定點」。
數字會轉換為 "ddd.ddd..." 型式的字串,其中 "d" 表示數字 (0-9)。
下列範例會使用定點格式規範格式化 Double 和 Int32 值。
Dim integerNumber As Integer
integerNumber = 17843
outputBlock.Text &= String.Format(integerNumber.ToString("F", CultureInfo.InvariantCulture)) & vbCrLf
' Displays 17843.00
integerNumber = -29541
outputBlock.Text &= String.Format(integerNumber.ToString("F3", CultureInfo.InvariantCulture)) & vbCrLf
' Displays -29541.000
Dim doubleNumber As Double
doubleNumber = 18934.1879
outputBlock.Text &= String.Format(doubleNumber.ToString("F", CultureInfo.InvariantCulture)) & vbCrLf
' Displays 18934.19
outputBlock.Text &= String.Format(doubleNumber.ToString("F0", CultureInfo.InvariantCulture)) & vbCrLf
' Displays 18934
doubleNumber = -1898300.1987
outputBlock.Text &= String.Format(doubleNumber.ToString("F1", CultureInfo.InvariantCulture)) & vbCrLf
' Displays -1898300.2
outputBlock.Text &= doubleNumber.ToString("F3", _
New CultureInfo("es-ES")) & vbCrLf
' Displays -1898300,199
N或n,代表數字。
數字會轉換為 "d,ddd,ddd.ddd…" 格式的字串、'd' 表示數字 (0-9)、',' 表示數字群組之間的千位分隔符號,
而 '.' 則表示小數點符號。
下列範例會使用數字格式規範來格式化各種浮點數值
。
Dim dblValue As Double = -12445.6789
outputBlock.Text &= String.Format(dblValue.ToString("N", CultureInfo.InvariantCulture)) & vbCrLf
' Displays -12,445.68
outputBlock.Text &= dblValue.ToString("N1", _
New CultureInfo("sv-SE")) & vbCrLf
' Displays -12?445,7
Dim intValue As Integer = 123456789
outputBlock.Text &= String.Format(intValue.ToString("N1", CultureInfo.InvariantCulture)) & vbCrLf
' Displays 123,456,789.0
P或p,代表百分比
下列範例會使用百分比格式規範來格式化浮點數值。
Dim number As Double = 0.2468013
outputBlock.Text &= String.Format(number.ToString("P", CultureInfo.InvariantCulture)) & vbCrLf
' Displays 24.68 %
outputBlock.Text &= number.ToString("P", _
New CultureInfo("hr-HR")) & vbCrLf
' Displays 24,68%
outputBlock.Text &= String.Format(number.ToString("P1", CultureInfo.InvariantCulture)) & vbCrLf
' Displays 24.7 %
於
凌晨12:06

2011年4月11日 星期一
MaxUserPort 和 TcpTimedWaitDelay
TcpTimedWaitDelay
TcpTimedWaitDelay 值決定了 TCP/IP 必須經過多久,才能釋出已關閉的連線及重複使用它的資源。 這個關閉和釋出的間隔稱為 TIME_WAIT 狀態,或是區段生命期限上限 (2MSL) 狀態的兩倍。 在這段時間內,通往用戶端和伺服器的連線重新開啟的成本,比建立新的連線低。 藉由縮減這個項目的值,TCP/IP 可以更快釋出已關閉的連線,提供更多資源給新的連線。 如果執行中的應用程式需要快速釋出、建立新連線,或多個連線在 TIME_WAIT 狀態中造成通訊量太低,因而需要進行調整的話,請調整這個參數。
預設值是 0xF0,它會將等待時間設為 240 秒(4 分鐘)。
最小的建議值是 0x1E,它會將等待時間設為 30 秒。 請利用這個程序來檢視或自訂您的值。
啟動 regedit 指令,瀏覽至HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TCPIP\Parameters 登錄次機碼,建立名稱為 TcpTimedWaitDelay 的新 REG_DWORD 值。
將值設為十進位 30,也就是十六進位的 0x0000001e。 這個值會將等待時間設為 30 秒。
關閉登錄編輯器。
停止並重新啟動系統。
MaxUserPort
MaxUserPort 值決定了當應用程式向系統要求可用的使用者埠時,TCP/IP 所能指派的最高埠號。 如果您的系統報告建立 Socket 時,發生錯誤異常狀況,可能是匿名(短期)埠的數量不當所造成,當系統開啟大量的埠來建立 Web 服務、資料庫或其他遠端資源的連線時,尤其如此。
依預設,Windows 會保留埠號 1024 至 5000,供匿名(短期)埠使用
一般作法是將這個值設成 32768。 請利用這個程序來檢視或自訂您的值。
啟動 regedit 指令,瀏覽至HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TCPIP\Parameters 登錄次機碼,建立名稱為 MaxUserPort 的新 REG_DWORD 值。
將這個值設成至少十進位 32768。
關閉登錄編輯器。
停止並重新啟動系統。
TcpTimedWaitDelay 值決定了 TCP/IP 必須經過多久,才能釋出已關閉的連線及重複使用它的資源。 這個關閉和釋出的間隔稱為 TIME_WAIT 狀態,或是區段生命期限上限 (2MSL) 狀態的兩倍。 在這段時間內,通往用戶端和伺服器的連線重新開啟的成本,比建立新的連線低。 藉由縮減這個項目的值,TCP/IP 可以更快釋出已關閉的連線,提供更多資源給新的連線。 如果執行中的應用程式需要快速釋出、建立新連線,或多個連線在 TIME_WAIT 狀態中造成通訊量太低,因而需要進行調整的話,請調整這個參數。
預設值是 0xF0,它會將等待時間設為 240 秒(4 分鐘)。
最小的建議值是 0x1E,它會將等待時間設為 30 秒。 請利用這個程序來檢視或自訂您的值。
啟動 regedit 指令,瀏覽至HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TCPIP\Parameters 登錄次機碼,建立名稱為 TcpTimedWaitDelay 的新 REG_DWORD 值。
將值設為十進位 30,也就是十六進位的 0x0000001e。 這個值會將等待時間設為 30 秒。
關閉登錄編輯器。
停止並重新啟動系統。
MaxUserPort
MaxUserPort 值決定了當應用程式向系統要求可用的使用者埠時,TCP/IP 所能指派的最高埠號。 如果您的系統報告建立 Socket 時,發生錯誤異常狀況,可能是匿名(短期)埠的數量不當所造成,當系統開啟大量的埠來建立 Web 服務、資料庫或其他遠端資源的連線時,尤其如此。
依預設,Windows 會保留埠號 1024 至 5000,供匿名(短期)埠使用
一般作法是將這個值設成 32768。 請利用這個程序來檢視或自訂您的值。
啟動 regedit 指令,瀏覽至HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TCPIP\Parameters 登錄次機碼,建立名稱為 MaxUserPort 的新 REG_DWORD 值。
將這個值設成至少十進位 32768。
關閉登錄編輯器。
停止並重新啟動系統。
於
凌晨12:50

訂閱:
文章 (Atom)