Saturday, 15 December 2007

Can not export data in Oracle 10g

Error: "RemoteOperationException: ERROR: wrong password for user".
Resolve:

  1. Go to "Control Panel" -> "Admin Tools" -> "Local Security Policy."
  2. Within "Local Policies", go to user "Right Assignment."
  3. Add the user to "Logon as a Batch Job."
http://weblogs.asp.net/wallym/archive/2005/01/03/345818.aspx

Import Shapefile into Oracle 10g

Step 1
Download tool Oracle Shapefile Converter at http://www.oracle.com/technology/software/products/spatial/index.html and extract it into any directory.
Open the directory correspond with your operating system (ex: directory shp2sdo_nt for MS Windows), called CONVERT_HOME.
Call the directory that contains your shapefiles is SHAPE_HOME.
Call the directory that installs Oracle 10g is ORACLE_HOME.

Step 2
1. Open console, run the following commands:
> cd $SHAPE_HOME
> set path="$CONVERT_HOME"

2. Run shp2sdo converter:

  • on Windows NT
shp2sdo.exe <file_name> <table_name> -g <geom_name> -d -x (<minx>,<maxx>) -y (<miny>,<maxy>) -s <SRS> -t <tolerance> -v
  • on Sun Sparc Solaris or Linux
shp2sdo.exe <file_name> <table_name> -g <geom_name> -d -x \(<minx>,<maxx>\) -y \(<miny>,<maxy>\) -s <SRS> -t <tolerance> -v

Ex:
shp2sdo.exe tuyendg spa_tuyendg -g geom -d -x (575977.125,577368.125) -y (1195219.125,1196522.0) -s 32648 -t 0.5 -v

Note: Type shp2sdo.exe -h for help.


Step 3
After running shp2sdo converter, it creates 2 files:
  • *.sql : to create oracle table.
  • *.ctrl : to store data.
1. Open iSQL*Plus with database that you want to import, execute the content in *.sql (ex: @spa_tuyendg.sql).

2. Open file *.ctrl, insert line " CHARACTERSET UTF8" after line "LOAD DATA" and save it.

3. Open console, use Oracle SQL*Loader by running the following commands:
> set path="$ORACLE_HOME/product/10.1.0/db_1/BIN"
> sqlldr <username>/<password> <table_name>

Ex: sqlldr SYSTEM/oracle spa_tuyendg


Step 4
Open iSQL*Plus, execute the following commands:
CREATE INDEX <index_name> ON <table_name>(<geom_name>) INDEXTYPE IS MDSYS.SPATIAL_INDEX;
EXECUTE SDO_MIGRATE.TO_CURRENT('
<table_name>','<geom_name>');

Ex:
CREATE INDEX spa_tuyendg_spatial_idx ON spa_tuyendg(geom) INDEXTYPE IS MDSYS.SPATIAL_INDEX;
EXECUTE SDO_MIGRATE.TO_CURRENT('SPA_TUYENDG','GEOM');



View details in using_shp2sdo.txt of Oracle Shapefile Converter.

Sunday, 4 November 2007

Add fonts to Ubuntu

1. Copy all fonts into /usr/share/fonts/truetype.
2. Restart computer or type following command:
sudo fc-cache -fv

http://saylinux.wordpress.com/2007/06/19/cai-them-fonts-cho-ubuntu-than-yeu-p/

Tuesday, 9 October 2007

Import spatial data (shapefile) into PostgreSQL

1. Open console, execute following commands:
cd $ShapeDir
shp2pgsql -W UTF-8 <filename>.shp <schema>.<tablename> ><filename>.sql


2. Open file that has just created, insert string "WITH OIDS" before character ";" of command CREATE TABLE, and then save that file.

3. Continue to execute the command:
psql -h <hostname> -U <username> -d <databasename> -f <filename>.sql

4. Open pgAdmin3 (or phpPgAdmin), open Query Tool and input following lines:
CREATE INDEX <indexname> ON <tablename> USING gist (<spatial_attribute>);
VACUUM ANALYZE <tablename>


Ex:
shp2pgsql -W UTF-8 hcm_road.shp public.hcm_road > hcm_road.sql

psql -h 127.0.0.1 -U postgres -d hcmcity -f hcm_road.sql

CREATE INDEX hcm_road_the_geom_gist ON hcm_road USING gist (the_geom);

VACUUM ANALYZE hcm_road


* Note: if you want to export data from PostgreSQL to shapefile, using command pgsql2shp.

Wednesday, 3 October 2007

Install PostgreSQL 8.2 with PostGIS on Ubuntu

On Ubuntu 7.10
Open console, execute following command:
sudo apt-get install postgresql-8.2 postgresql-client-8.2 postgresql-client-common postgresql-common postgresql-server-dev-8.2 postgresql-contrib-8.2
libgeos-dev proj postgis postgresql-8.2-postgis

Note: /usr/lib/postgresql/8.2/lib ---> directory contains file
liblwgeom.so


On Ubuntu 7.04
1. Open console, execute following command:
sudo apt-get install postgresql-8.2 postgresql-client-8.2 postgresql-client-common postgresql-common postgresql-server-dev-8.2 postgresql-contrib-8.2 libgeos-dev proj flex postgis

2. Download postgis-1.3.x.tar.gz and decompress.

3. Execute following commands:
cd ${postgis-1.3.x}
./configure


Result:

SUMMARY
-------------------------------------------------------

HOST_OS: linux-gnu

PGSQL: /usr/bin/pg_config
GEOS: /usr/bin/geos-config (with C-API)
(ldflags: -L/usr/lib)
PROJ: prefix=/usr libdir=/usr/lib
ICONV: 1

PORTNAME: linux
PREFIX: /usr
EPREFIX: ${prefix}
DOC: /usr/share/doc/postgresql-doc-8.2/contrib
DATA: ${datarootdir}
MAN: ${datarootdir}/man
BIN: /usr/lib/postgresql/8.2/bin
EXT: /usr/lib/postgresql/8.2/lib (\$$libdir)
-------------------------------------------------------


Note: EXT: /usr/lib/postgresql/8.2/lib ---> directory contains file liblwgeom.so


4. Compile & Install
make
sudo make install

Cài đặt xvnkb trên Ubuntu

1. Cài đặt các package :
sudo apt-get install build-essential
sudo apt-get install xorg-dev


2. Download xvnkb-0.2.9a.tar.bz2 và decompress.
3. Thực hiện các lệnh sau :
cd xvnkb-0.2.9a/
./autogen.sh
./configure --use-extstroke

4. Sửa file config.h :
gedit config.h

thành :

#define __VK_CONFIG_H
#define VK_CHECK_SPELLING
#define VK_USE_EXTSTROKE
#define VK_NEED_UCHAR

(bỏ đi một vài dòng bị lỗi)

5. Compile & Install
make
sudo make install


6. Nếu muốn xvnkb tự động chạy lúc khởi động, bạn vào menu System > Preferences > Sessions, chọn New và nhập vào ô Command như sau: xvnkb --method=telex --charset=utf8 (trong đó method là telex, vni hoặc viqr; charset là utf8, tcvn, viscii, vps hoặc viqr). Bây giờ xvnkb sẽ khởi động mặc định với kiểu gõ (method) và bảng mã (charset) mà bạn đã chọn.

Theo http://saylinux.wordpress.com/

Friday, 11 May 2007

Get UTF-8 string from file *.properties to web page

Để lấy được chuỗi utf-8 từ file *.properties thì file đó phải thỏa các điều kiện :
- Định dạng của file là utf-8.
- Chuỗi nhập vào file là utf-8.
Từ file *.properties, ta dùng câu lệnh native2ascii trên console hoặc dùng thẻ native2ascii của Ant để chuyển các chuỗi utf-8 về dạng mà trang web có thể đọc được.
Ví dụ : Chào mọi người
--> Ch\u00e0o m\u1ecdi ng\u01b0\u1eddi

1. Dùng câu lệnh native2ascii trên console :
Cách dùng như sau :
native2ascii -encoding utf8 sourcefile destfile
Nếu destfile không có thì nó sẽ đè chồng lên sourcefile.

2. Dùng thẻ native2ascii của Ant :
Cách dùng như sau :


Thuộc tính ext là tùy chọn, dùng để thêm phần mở rộng (extension) của tên file cũ. Chỉ khi nào thư mục src trùng với thư mục dest thì phải có thuộc tính ext để tạo 1 file mới.

Ví dụ :


--> Kết quả trả về file : messages_en.properties

Wednesday, 25 April 2007

Configure Subversion and SmartSVN

Subversion

Task 1: Create respository

1. Open Console, use user root
$ su -
2. Type command:
$ svnadmin create --fs-type fsfs /home/svn_root/repos


Task 2: Authorize users
1. Type command:
$ cd /home/svn_root/repos/conf/

2. Edit files:
* authz
[groups]
ciren = taina
[/]
taina = rw
[repository:/]
@ciren = rw

* passwd
[users]
taina=[passwd]

* svnserve.conf
[general]
anon-access = none
auth-access = write
password-db = passwd
authz-db = authz
realm = Tai Nguyen's Subversion

Task 3: Start SVN
Type command:
$ svnserve -d -r /home/svn_root/


Note : If error "Can't bind server socket" happens, execute "ps -ef | grep svn" and "kill <svn process>".

Task 4: Install svnserve Windows Service

Case 1
1. Run command-line.
2. Type following command:
\sc create
binpath= "c:\svn\bin\svnserve.exe --service "
displayname= "Subversion Repository"
depend= Tcpip start= auto

(SC.EXE for "Service Control")

Case 2
1. Download 2 Resource Kit files Instrsrv.exe (installs and removes system services from Windows NT/2000) and Srvany.exe (allows any Windows application to run as a service).
2. Copy both files into the same directory, ex: C:\reskit.
3. Run command-line.
4. Type following command:
\reskit\INSTSRV.EXE "Service Name" \reskit\SRVANY.EXE
5. Run regedit.
6. Next navigate to this registry key.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\service name
7. From the Edit menu, click Add Key and name it Parameters
Next from the Edit menu, click Add Value and type this information.
Value Name: Application
Data Type : REG_SZ
String : \ (Ex: C:\svn\svnserve.exe -d -r C:\repos)

http://www.tacktech.com/display.cfm?ttid=197

SmartSVN

Task 1: Add repository

1. From the main menu, select Repository > Manage Profiles...
2. In tab Profiles, click
Add...
3. Complete the Add Repository Profile dialog with the following information:
* Location

  • Access Method: SVN
  • Server Name: localhost
  • Repository Path: /repos
  • Server Port: Default
  • Click Next
* Details
  • Check User Name/Password at SVN Login
  • Input user name and password (ex: taina/pass)
  • Check Store password on disk and Verify connection when pressing 'Next'
  • Click Next
  • Click Finish