2011年8月18日 星期四

Oracle Spatial 建置

Mapinfo Easyloader 轉入Oracle spatial

刪除table spatial index

INSERT INTO USER_SDO_GEOM_METADATA
VALUES (
'TOWN_97_OK',
'GEOLOC',
MDSYS.SDO_DIM_ARRAY(
MDSYS.SDO_DIM_ELEMENT('X', -7998349.27594, 8498349.27594, .000000003),
MDSYS.SDO_DIM_ELEMENT('Y', -10001001.0314, 10001001.0314, 4.5000E-09)
),
NULL --SRID
);

DROP INDEX COUN_POLY_97_OK_IDX;

CREATE INDEX COUN_POLY_97_OK_IDX
ON "GISSEC"."TOWN_97_OK"(GEOLOC)
INDEXTYPE IS MDSYS.SPATIAL_INDEX;

2011年8月2日 星期二

MapGuide Enterprise 2011 授权错误的解决办法

MapGuide Enterprise 2011 授权错误的解决办法

如果你以前使用的MapGuide Enterprise 2011试用版,在转为正式授权版后可能出现授权错误。比如在授权错误日志中频繁出现[The license has already been checked out] 错误,下面的解决办法也许适合你。
解决方案内容来自http://usa.autodesk.com/adsk/servlet/ps/dl/item?siteID=123112&id=15367639&linkID=9242178

错误现象:

在C:\Program Files\Autodesk\MapGuideEnterprise2011\Server\Logs\LicenseError.log 里面频繁出现下面的日志内容。
1400 2011/03/21 09:49:56 Reason=Fatal error
1400 2011/03/21 09:49:56 ComputerName=ALBAGEOMAP
1400 2011/03/21 09:49:56 OS=5.2.3790.Szervizcsomag 2
1400 2011/03/21 09:49:56 File=AdlmIntNWFBLicense.cpp,Line=622
1400 2011/03/21 09:49:56 AdlmIntError=18 [The license has already been checked out]

解决方案
1. 在LMTOOLS里确认有可用的License
打开LMTOOLS
到Server Status选显卡,点击Perform Status Enquiry按钮
检查 MapGuide 2011的授权是否有效,你应该能看到类似下面的东东:
"Users of 85552MAPGE_2011_0F: (Total of 1 license issued; Total of 0 licenses in use)"
2. 用记事本或其他文本编辑器打开serverconfig.ini文件,这个文件在\MapGuideEnterprise2011\Server\Bin目录下
编辑LicenseServerPath参数,使其指向你安装LMTOOLS的机器,本地安装情况下缺省是
LicenseServerPath =@127.0.0.1.
编辑SerialNumber参数,使其和你在LMTOOLS中的序列号一致,比如
SerialNumber = 123-12345678
3. 打开文本编辑器,在MapGuideEnterprise2011\Server\目录下创建一个licpath.lic文件,SERVER后面的值必须和你的LicenseServerPath的值一致。比如下面的示例:
SERVER 127.0.0.1 000000000000
USE_SERVER
4. 重新启动MapGuide Server服务。

2011年6月30日 星期四

不同的Random物件給予不同的亂數種子

要讓不同的Random物件產生不同的亂數組,我們必須要做的是給予不同的Random物件不同的亂數種子。以往像這樣的需求我會這摸寫:
1
Random r = new Random(DateTime.Now.Millisecond);

但在回應網友問題時才發現,使用這種寫法並無法有效的解決亂數重複問題。
後來再度嚐試MSDN的方法
1
Random Counter = new Random(unchecked((int)(DateTime.Now.Ticks >> ctr)));

在極短的時間內一樣是無法有效的取得不同的亂數種子。最後想到用GUID的HashCode來當亂數種子帶入才能有效解決這問題。
1
Random Counter = new Random(Guid.NewGuid().GetHashCode());

之所以能這樣寫是因為亂數種子必須要在極短的時間內帶入不同的值,而GUID剛好能有效的產生不重複的識別值,HashCode又是用來當作雜湊的Key,相同物件才會有相同的HashCode,因此GUID的HashCode剛好就能有效的產生不同的整數值作為亂數種子。Google了一下,這方法在對岸及國外都有在用,所以應該是沒有問題。

引用:http://www.dotblogs.com.tw/larrynung/archive/2010/01/04/12801.aspx

2011年5月10日 星期二

Mapguide2011 License 驗證注意事項。

1) Go to serverconfig.ini in \MapGuideEnterprise2011\Server\Bin and open in a text editor.
Edit the LicenseServerPath variable to point to your LMTOOLS install. The default for a local install is: LicenseServerPath =@127.0.0.1.
Edit the SerialNumber variable to indicate the serial number in use by LMTOOLS, such as: SerialNumber = 123-12345678

2) Open a text editor and create a licpath.lic file in \MapGuideEnterprise2011\Server. The value after SERVER must match your LicenseServerPath entry. See the example below.

SERVER 127.0.0.1 000000000000
USE_SERVER

3) Restart the MapGuide service (Look under Windows Services)

4) 確認C:\Program Files\Autodesk\MapGuideEnterprise2011\Server路徑下是否存在LICPATH.LIC
若缺此檔案,請建立文字檔並命名為LICPATH.LIC,其內容為:
------------------------------------------------
SERVER 127.0.0.1 000000000000
USE_SERVER

5) Start Map Guide Studio

2011年4月27日 星期三

MgFeatureProperty

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月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 位址 與 網路遮罩 資料即可)。

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 %