Tuesday, March 4, 2008

June

I like this song. This song makes me recall so much. I miss the time I was in San Diego. Even though I moved out from there several months ago, it is still sad for me to hear that the story in that warm and lovely place is going to the end. So much to be memorized, just use this song at this little place to express my feeling.


Get this widget | Track details | eSnips Social DNA

Monday, March 3, 2008

A lonely position

I can not say my job is bad. It is free, very free. I can do whatever I want during the working hours. I can sleep a late as I want. I can even not go to the office. I can go aboard several times a year. I have long winter and summer vacations during which I can plan anything I like. I can do anything as long as I can pass the university evaluation or I can finish all the works I have promised. I can have my own employees to ask them to do things I like to do. Probably I am having one of the best positions in Taiwan as long as you like research.
Two disadvantages, the first is the low-pay given the responsibility I have to carry. The disadvantage I concern the most is I am lonely, very lonely. I am alone for almost all day long, all week long. I do not have officemates to chat. People I met are my students or my teachers. I can hardly meet somebody who can chat and share with me. Today I am depressed. I am lonely even though many tasks are stilling waiting for me.

Feelings under an arch of triumph

Yesterday I was standing in front of an arch of triumph. No other reasons, just waiting for somebody about 1 hour. After that, I went back to my office directly and resume my heavy tasks.
For what reason, probably I was there to memorize all the good time I had been with her. Even though it must be a no-future relationship, I still appreciate very much all this short time her lovely company. Everything I had done to this relationship was bad because of the diverge of our future plan. Anyway, I wish all her best.




It was a relationship that I hesitate to join because of her status of applying study aboard. In fact, I am looking for a stable relationship to complement my life. It is so obvious that our future plan might not be able to converge given this situation unless she changes her mind.
It is still difficult for me to realize the fact that our very-short relationship has been broken. Though no future, we still share quite a bit happy time together.

Monday, February 18, 2008

Extract points from polyline in ArcGIS

Here is a visual basic macro for ArcGIS to generate points on the polylines. How to use these codes. Few steps are discussed below:
  1. Add the polyline shapefile in your ArcMap project.
  2. Create a point shapefile in ArcCatalog by right-click a specific folder and select New to create a new point shapefile in which the to-be-generated points will be saved.
  3. In ArcMap, Go to Tool > Macro > Visual Basic Editor > Project > ArcMap Objects > ThisDocument
  4. Copy the VB script attached below and paste into ThisDocument
  5. Highlight the polyline shapefile to be extracted
  6. Click the "Run Sub" button to execute the script
  7. Done !!
----------------------------------------------------
Public Sub CreatePointsAlongCurve()
'Creates points at a set distance along any feature implementing ICurve
'
'Justin Johnson
'January 23, 2004
'justin.johnson@geog.utah.edu
'
'Obtains selected features from currently-selected Layer
'Stores new points in point theme at top of TOC

Dim pMxDoc As IMxDocument
Dim pMap As IMap
Dim pInGeometry As IGeometry
Dim pInLayer As ILayer
Dim pInFLayer As IFeatureLayer
Dim pOutFLayer As IFeatureLayer
Dim pInFCursor As IFeatureCursor
Dim pOutFCursor As IFeatureCursor
Dim pOutFBuffer As IFeatureBuffer
Dim pInFClass As IFeatureClass
Dim pOutFClass As IFeatureClass
Dim pSelSet As ISelectionSet
Dim pFSelection As IFeatureSelection
Dim pInFeature As IFeature
Dim pCurve As ICurve
Dim pPointCollection As IPointCollection
Dim pConstructMultipoint As IConstructMultipoint

Set pMxDoc = ThisDocument
Set pMap = pMxDoc.FocusMap
Set pInLayer = pMxDoc.SelectedLayer

If pInLayer Is Nothing Then 'Check if no input layer is selected
MsgBox "Select a feature layer in the TOC", vbCritical, "Incompatible input layer"
Exit Sub
End If

If TypeOf pInLayer Is IFeatureLayer Then 'check if selected layer is a feature layer
Set pInFLayer = pMxDoc.SelectedLayer 'set selected layer as input feature layer
Else
MsgBox "Select a feature layer in the TOC", vbCritical, "Incompatible input layer"
Exit Sub
End If

Set pOutFLayer = pMap.Layer(0) ' set top layer in TOC as output feature layer
Set pInFClass = pInFLayer.FeatureClass
Set pOutFClass = pOutFLayer.FeatureClass

If Not pOutFClass.ShapeType = esriGeometryPoint Then 'check if output layer is Point type
MsgBox "Geometry type of output layer is not Point", vbCritical, "Incompatible Output Layer"
Exit Sub
End If

'Get selected features, if any
Set pFSelection = pInFLayer
Set pSelSet = pFSelection.SelectionSet

'Prompt user for distance between points
Dim pPointDist As Double
pPointDist = InputBox("Distance between points: ", "Point Spacing in Map Units")

'Create an Insert cursor on output feature class
Set pOutFBuffer = pOutFClass.CreateFeatureBuffer
Set pOutFCursor = pOutFClass.Insert(True)

If pSelSet.Count <> 0 Then
'use selected features from input feature class
pFSelection.SelectionSet.Search Nothing, True, pInFCursor
Else
'use all features if none are selected
Set pInFCursor = pInFClass.Search(Nothing, True)
End If

Dim k As Long 'count the number of points created
k = 0

Set pInFeature = pInFCursor.NextFeature

Do While Not pInFeature Is Nothing

Set pInGeometry = pInFeature.Shape
Set pCurve = pInGeometry
Set pConstructMultipoint = New Multipoint

pConstructMultipoint.ConstructDivideLength pCurve, pPointDist

Set pPointCollection = pConstructMultipoint

Dim i As Long
For i = 0 To pPointCollection.PointCount - 1

Set pOutFBuffer.Shape = pPointCollection.Point(i) 'store the new geometry
pOutFCursor.InsertFeature pOutFBuffer
k = k + 1

Next i

Set pInFeature = pInFCursor.NextFeature

Loop

pMxDoc.ActiveView.Refresh
MsgBox k & " points created in " & pOutFLayer.Name, vbInformation, "Complete"

End Sub

Saturday, February 16, 2008

Compile Fortran and C++ together under VS2005

Since the new release of windows vista system, the old mixed-language programming under WS6.0 and Compaq Fortran 6.0 does not work anymore since both compilers are not compatible with the new windows OS system. In order to response to such changes, here I did my first test of the mixed-language programming under VS2005 and Intel Fortran. The example codes are copied from the website. It should be noticed that the calling convention between Compaq Fortran 6.0 and VS6.0 is different from that between Intel Fortran and VS2005. Here is a table shown in Steve's article "Porting applications from Compaq frotran to Intel Fortran" to list the difference calling conventions.



Therefore, in Intel Fortran, we no longer require the __stdcall put ahead of the fortran functions in the C code. Instead, __stdcall should be replaced by __cdecl or simply be removed. The original codes in the website become

(1) The C++ file:

// This illustrates how a Fortran routine and function may be
// called from a main program in C++
#include
extern "C"
{
void FR1(int*,int *);
int FF1(int *);
}
int main()
{
int n=10,nSq,nCube;
FR1(&n,&nSq);
cout << "The square is:" << ncube="FF1(&n);" style="font-weight: bold;"> (2) The Fortran File:

SUBROUTINE FR1(N,M)
C COMPUTES THE SQUARE OF N, RETURNS IN M
M=N*N
RETURN
END
C
INTEGER FUNCTION FF1(N)
C COMPUTES THE CUBE OF N
FF1=N*N*N
RETURN
END

To build mixed-language the VS2005 project, it is not similar to what we did in VS6.0 where we put both C++ files and fortran files in the same project and then compile them together as a whole. In VS2005, we should separate them into two projects, one for C++ and one form Fortran.
  1. Create a static library package for Fortran files by File > New> Intel Fortran > Library > Static Library when creating the package.
  2. Create a Win32 console application package for C++ files by File > New> Visual C++ > Win32 console application
  3. Create a VS2005 solution by going to File > New > Other Studio solutions > VS solution and add both created packages in.
  4. Add the Fortran and C++ into their packages respectively.
  5. Right-click both packages to confirm their runtime libraries are consistent. For C++, it is at Property > C/C++ > Code Generation > runtime library. For Fortran, it is at Property > Fortran > Libraries and also make sure that "Disable OBJCOMMENT ....." is set to be NO
  6. Add the new created lib file (from the Fortran package) into the solution by add the Fortran package name (FortranName.lib) at Property > Linker > Input > Additional dependence by right-click the C++ package
  7. Add the additional library path for C++ package by going to Tools > Options > Projects and Solutions > Library files and click the white boards to add Intel Fortran library at \IntelFortranRoot\Compiler\Fortran\versioncode\IA32\Lib and the location where the new lib file is generated.
  8. After all these settings, I successfully my first package built under VS2005.

Tuesday, February 12, 2008

Load DEM into ArcGIS

I download the DEM (Digital Elevation Model) files from Geocommunity to do the exercise of Archydro model to analysis DEM file for the collection of geographical information. Geocommunity is the free port providing the free GIS files from all over the world. Its format of DEM files is SDTS (Spatial Data Transfer Standard). In order to transfrom the SDTS file into the suitable format for ArcGIS 9.2 use, we should add the new extension by going to ArcCatalog->Tools-> Customize-> Arcview 8x tools.
The transformation of SDTS file to Grid file for the DEM analysis, it follows the steps
  1. Open ArcToolbox
  2. Under Conversion Tools > Import to Raster, choose 'SDTS Raster to Grid'
  3. In the Input Prefix box, navigate to the folder with the ****.ddf files, and choose the 4 digit input file (ex:1158). Note that the path for the .ddf files may not contain any spaces.
  4. Choose the Z-value field name for the Record No. box, i.e. "ELEVATION".
  5. Select an output folder and name the Grid.
  6. Keep Convert Values and Use Data Dictionary checked.
  7. Hit OK.
  8. You may then add this DEM Grid to ArcInfo Desktop or ArcView 3.x
For more comprehensive information, we can go to the website.

Monday, January 14, 2008

For her

It was long. I do not come here to write and read, since I came back from Taiwan. I was stuffed by all kinds of things and forgot to stop and check myself out. These days, these two weeks, it is hard, not for me, but for her.
這種感覺是辛酸的. 我是個糟糕透的人. 他說不要認為他可憐. 他會比以前更好更美不需要任何人同情. 他是堅強的. 而相對的我是軟弱的. 電話那頭激昂著講著. 而我這頭無言地不知如何答話. 顯地我好冷漠. 但我好難過. 我不知道該怎麼說. 我知道我的錯. 我卻是無法如他那般地堅強地為他的選擇而堅持. 是因為我無法做到他那般地肯定. 我心中有著疑惑. 而就任其這樣將他傷了又傷 傷了又傷. 我在他的世界. 我好似多餘地站在旁. 看著他的掙扎與努力. 我心痛但不行動.



詞曲:石裕博

我還是這樣的想像
事實總是多於遐想
你也不用刻意的補償
到現在有或沒有的感傷

可是始終還是這樣
我連掙扎都不想抵抗
躲起來也顯得那麼匆忙
這可不像我應該的模樣

我還是站在了多餘的一旁 無聊的歌唱
我像是一雙多餘的翅膀 不能帶你飛翔
(我也不想飛翔)

是你讓我回到了開場
黑暗就在不遠的前方
時間總是順著它的方向
不是你我就可以阻擋