1. Install Apache
./configure –prefix=/usr/local/apache2 –enable-so –enable-rewrite –with-mpm=prefork
make
make install
rm -Rf /usr/local/apache2/htdocs/*
2. Install mod_python-3.3.1
./configure --with-apxs=/usr/local/apache2/bin/apxs
make
make install
3. Install Python Imaging Library (PIL) – Imaging-1.1.6
python setup.py install
Note: To check if PIL was successfully installed:
#python selftest.py
***Test Failed*** 1 failures.
*** 1 tests of 57 failed.
47 ln -s /usr/lib/libjpeg.so.62 /usr/lib/libjpeg.so
48 ldconfig
49 python setup.py install
51 python selftest.py
54 rm -rf Imaging-1.1.6
55 tar -zxvf Imaging-1.1.6.tar.gz
56 cd Imaging-1.1.6
58 python selftest.py -> still fails
59 python setup.py install
60 python selftest.py -> ok
4. Check if mod_python was sucessfully installed.
http://www.dscpl.com.au/wiki/ModPython/Articles/GettingModPythonWorking
[root@rupert-centos pytest]# python
Python 2.4.3 (#1, Mar 14 2007, 18:51:08)
[GCC 4.1.1 20070105 (Red Hat 4.1.1-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mod_python
>>> mod_python.version
'3.3.1'
>>>
4. Edit httpd.conf
<directory>
AddHandler python-program .py
PythonHandler TileCache.Service
PythonOption TileCacheConfig /usr/local/apache2/htdocs/tilecache/tilecache.cfg
PythonDebug On
PythonPath "sys.path + ['/usr/local/apache2/htdocs/tilecache/']"
</directory>
<directory>
AddHandler mod_python .py
PythonHandler test
PythonDebug On
</directory>
Note: This syntax will work for all versions of mod_python. In version 3.0 and later, the name of the mod_python handler reference has actually been changed and thus it is now preferred to use “mod_python” instead of “python-program”. The old name though is still supported and will be used here to avoid confusion for those using version 2.7.
5. Test your python
from mod_python import apache
def handler(req):
req.log_error('handler')
req.content_type = 'text/plain'
req.send_http_header()
req.write('mptest.py\n')
return apache.OK
Here is a list of the most widely used OGR commands I use..
OGR2OGR
1. POSTGRES -> MAPINFO
$ ogr2ogr -f "Mapinfo File" busline_buffer10m.tab PG:"host=localhost user=postgres dbname=cybersoftbj" -sql "select * from table_name" -a_srs WGS84 -nln layer_name -nlt MULTIPOLYGON
2. MAPINFO -> POSTGRES
ogr2ogr -f "PostgreSQL" PG:"host=127.0.0.1 user=rupert dbname=australia password=*****" AUS_ROAD.TAB -nln AUS_ROAD -a_srs EPSG:4269 -t_srs EPSG:3857 -skip-failures
ogr2ogr -f "PostgreSQL" PG:"host=myhost user=myloginname dbname=mydbname password=mypassword" mytabfile.tab -nln newtablename -select columnName
Note: If you have Chinese characters, might as well do MAPINFO -> SHAPE -> POSTGRES
http://222.128.19.19/wordpress/?p=108
3. SHAPE -> POSTGRES
shp2pgsql -W "gbk" -s 4326 lbjrdnt_small_polyline roads > roads.sql
4. POSTGRES -> SHAPE
pgsql2shp -h 127.0.0.1 -u lbs -P tracking -f roads.shp databasename tablename
4. MAPINFO TO ORACLE
ogr2ogr -f OCI OCI:username/password@orcl C:\path_to_tabfile\EMPLOYEES.TAB -nln employees
Note: This assumes you already have Oracle 10g Client installed and “orcl” is defined as an instance in tnsnames.ora. OGR2OGR automatically updates USER_SDO_GEOM_METADATA and creates a spatial index.
5. MAPINFO to MAPINFO but different projection. From EPSG:4326 to EPSG:3857
ogr2ogr -f "MapInfo File" BaseMaps_3857/AUS_CITIES_3857.TAB BaseMaps/AUS_CITIES.TAB -a_srs "EPSG:4326" -t_srs "EPSG:3857"
Here is a post in buffering points and combining them using GeomUnion. Works in GEOS3.0.0, so note that your POSTGIS installation in windows contains a lower version of GEOS.

DROP FUNCTION combineGeometry();
CREATE FUNCTION combineGeometry() RETURNS Void AS'
DECLARE
--define datatypes here
updateCount integer DEFAULT 0;
geom_record RECORD;
geom_current RECORD;
geom_final RECORD;
mytotal integer DEFAULT 0;
BEGIN
--get the total
SELECT count(*) as mycount FROM busstopv1_buffer_20_temp INTO mytotal;
-- 1,2,3,4,5
FOR geom_record IN SELECT * FROM busstopv1_buffer_20 LOOP
--get the current geom of the record
SELECT *
FROM busstopv1_buffer_20_temp b
WHERE b.gid = geom_record.gid INTO geom_current;
RAISE INFO ''RECORD GID: %'', geom_record.gid;
RAISE INFO ''===========TOTAL COUNT: %=============='', mytotal;
--find the intersection of the current geom with other spatial entities
--and loop through that. For each loop, update the geom.
IF geom_current IS NULL THEN
CONTINUE;
END IF;
FOR geom_final IN
SELECT GeomUnion(b0.the_geom, geom_current.the_geom ) AS geom_current_union, b0.gid
FROM busstopv1_buffer_20_temp b0
WHERE b0.gid <> geom_current.gid
AND Intersects(b0.the_geom, geom_current.the_geom) = ''t''
ORDER BY gid ASC LOOP
--geom_current.gid = geom_record.gid
UPDATE busstopv1_buffer_20_temp
SET the_geom = GeomUnion( the_geom, geom_final.geom_current_union )
WHERE gid = geom_current.gid;
RAISE INFO ''UPDATED GID:%'', geom_current.gid;
DELETE FROM busstopv1_buffer_20_temp WHERE gid = geom_final.gid;
RAISE INFO ''DELETED GID:%'', geom_final.gid;
mytotal = mytotal - 1;
END LOOP;
END LOOP;
END;'
LANGUAGE plpgsql;
SELECT combineGeometry();
Next step.. trying out CGAL.

Here is a sample script in using buffer in Postgis. I buffered the line by 10 and 20 meters. Take note that I have to transform the geometry to the corresponding EPSG, so I could specify “meters”.
DROP TABLE busline_buffer1;
DELETE FROM geometry_columns WHERE f_table_name = 'busline_buffer1';
CREATE TABLE busline_buffer1( gid serial, CONSTRAINT pk_buffer1 PRIMARY KEY(gid));
SELECT AddGeometryColumn('public', 'busline_buffer1', 'the_geom', 4326, 'POLYGON',2);
// This would display what the output of the geometry IS...
SELECT AsText( transform( ST_BUFFER( transform(v1.the_geom, 32650), 10 ), 4326 ) ) FROM buslinev1 v1;
INSERT INTO busline_buffer1(the_geom) SELECT transform( ST_BUFFER( transform(v1.the_geom, 32650), 10 ), 4326 ) FROM buslinev1 v1;
SELECT gid, AsText(the_geom) FROM busline_buffer1;
========================================
DROP TABLE busline_buffer2;
DELETE FROM geometry_columns WHERE f_table_name = 'busline_buffer2';
CREATE TABLE busline_buffer2( gid serial, CONSTRAINT pk_buffer2 PRIMARY KEY(gid));
SELECT AddGeometryColumn('public', 'busline_buffer2', 'the_geom', 4326, 'POLYGON',2);
SELECT AsText( transform( ST_BUFFER( transform(v1.the_geom, 32650), 20 ), 4326 ) ) FROM buslinev1 v1;
INSERT INTO busline_buffer2(the_geom) SELECT transform( ST_BUFFER( transform(v1.the_geom, 32650), 20 ), 4326 ) FROM buslinev1 v1;
SELECT gid, AsText(the_geom) FROM busline_buffer2;
Beijing China is located in EPSG:32650, UTM ZONE 50N on WGS84. UTM ZONE of the WORLD.

List of EPSG Codes
EPSG:4267 NAD27
EPSG:26710 NAD27 / UTM zone 10N
EPSG:26711 NAD27 / UTM zone 11N
EPSG:26712 NAD27 / UTM zone 12N
EPSG:26713 NAD27 / UTM zone 13N
EPSG:26714 NAD27 / UTM zone 14N
EPSG:26715 NAD27 / UTM zone 15N
EPSG:26716 NAD27 / UTM zone 16N
EPSG:26717 NAD27 / UTM zone 17N
EPSG:26718 NAD27 / UTM zone 18N
EPSG:26719 NAD27 / UTM zone 19N
EPSG:26720 NAD27 / UTM zone 20N
EPSG:26721 NAD27 / UTM zone 21N
EPSG:26722 NAD27 / UTM zone 22N
EPSG:26703 NAD27 / UTM zone 3N
EPSG:26704 NAD27 / UTM zone 4N
EPSG:26705 NAD27 / UTM zone 5N
EPSG:26706 NAD27 / UTM zone 6N
EPSG:26707 NAD27 / UTM zone 7N
EPSG:26708 NAD27 / UTM zone 8N
EPSG:26709 NAD27 / UTM zone 9N
EPSG:4269 NAD83
EPSG:26930 NAD83 / Alabama West
EPSG:26987 NAD83 / Massachusetts Island
EPSG:26986 NAD83 / Massachusetts Mainland
EPSG:32118 NAD83 / New York Long Island
EPSG:32128 NAD83 / Pennsylvania North
EPSG:32129 NAD83 / Pennsylvania South
EPSG:26910 NAD83 / UTM zone 10N
EPSG:26911 NAD83 / UTM zone 11N
EPSG:26912 NAD83 / UTM zone 12N
EPSG:26913 NAD83 / UTM zone 13N
EPSG:26914 NAD83 / UTM zone 14N
EPSG:26915 NAD83 / UTM zone 15N
EPSG:26916 NAD83 / UTM zone 16N
EPSG:26917 NAD83 / UTM zone 17N
EPSG:26918 NAD83 / UTM zone 18N
EPSG:26919 NAD83 / UTM zone 19N
EPSG:26920 NAD83 / UTM zone 20N
EPSG:26920 NAD83 / UTM zone 20N
EPSG:26921 NAD83 / UTM zone 21N
EPSG:26922 NAD83 / UTM zone 22N
EPSG:26923 NAD83 / UTM zone 23N
EPSG:26903 NAD83 / UTM zone 3N
EPSG:26904 NAD83 / UTM zone 4N
EPSG:26905 NAD83 / UTM zone 5N
EPSG:26906 NAD83 / UTM zone 6N
EPSG:26907 NAD83 / UTM zone 7N
EPSG:26908 NAD83 / UTM zone 8N
EPSG:26909 NAD83 / UTM zone 9N
EPSG:27582 NTF (Paris) / France II
EPSG:27700 OSGB 1936 / British National Grid
EPSG:4326 WGS 84
EPSG:32610 WGS 84 / UTM zone 10N
EPSG:32710 WGS 84 / UTM zone 10S
EPSG:32611 WGS 84 / UTM zone 11N
EPSG:32711 WGS 84 / UTM zone 11S
EPSG:32612 WGS 84 / UTM zone 12N
EPSG:32712 WGS 84 / UTM zone 12S
EPSG:32613 WGS 84 / UTM zone 13N
EPSG:32713 WGS 84 / UTM zone 13S
EPSG:32614 WGS 84 / UTM zone 14N
EPSG:32714 WGS 84 / UTM zone 14S
EPSG:32615 WGS 84 / UTM zone 15N
EPSG:32715 WGS 84 / UTM zone 15S
EPSG:32616 WGS 84 / UTM zone 16N
EPSG:32716 WGS 84 / UTM zone 16S
EPSG:32617 WGS 84 / UTM zone 17N
EPSG:32717 WGS 84 / UTM zone 17S
EPSG:32618 WGS 84 / UTM zone 18N
EPSG:32718 WGS 84 / UTM zone 18S
EPSG:32619 WGS 84 / UTM zone 19N
EPSG:32719 WGS 84 / UTM zone 19S
EPSG:32601 WGS 84 / UTM zone 1N
EPSG:32701 WGS 84 / UTM zone 1S
EPSG:32620 WGS 84 / UTM zone 20N
EPSG:32720 WGS 84 / UTM zone 20S
EPSG:32621 WGS 84 / UTM zone 21N
EPSG:32721 WGS 84 / UTM zone 21S
EPSG:32622 WGS 84 / UTM zone 22N
EPSG:32722 WGS 84 / UTM zone 22S
EPSG:32623 WGS 84 / UTM zone 23N
EPSG:32723 WGS 84 / UTM zone 23S
EPSG:32624 WGS 84 / UTM zone 24N
EPSG:32724 WGS 84 / UTM zone 24S
EPSG:32625 WGS 84 / UTM zone 25N
EPSG:32725 WGS 84 / UTM zone 25S
EPSG:32626 WGS 84 / UTM zone 26N
EPSG:32726 WGS 84 / UTM zone 26S
EPSG:32627 WGS 84 / UTM zone 27N
EPSG:32727 WGS 84 / UTM zone 27S
EPSG:32628 WGS 84 / UTM zone 28N
EPSG:32728 WGS 84 / UTM zone 28S
EPSG:32629 WGS 84 / UTM zone 29N
EPSG:32729 WGS 84 / UTM zone 29S
EPSG:32602 WGS 84 / UTM zone 2N
EPSG:32702 WGS 84 / UTM zone 2S
EPSG:32630 WGS 84 / UTM zone 30N
EPSG:32730 WGS 84 / UTM zone 30S
EPSG:32631 WGS 84 / UTM zone 31N
EPSG:32731 WGS 84 / UTM zone 31S
EPSG:32632 WGS 84 / UTM zone 32N
EPSG:32732 WGS 84 / UTM zone 32S
EPSG:32633 WGS 84 / UTM zone 33N
EPSG:32733 WGS 84 / UTM zone 33S
EPSG:32634 WGS 84 / UTM zone 34N
EPSG:32734 WGS 84 / UTM zone 34S
EPSG:32635 WGS 84 / UTM zone 35N
EPSG:32735 WGS 84 / UTM zone 35S
EPSG:32636 WGS 84 / UTM zone 36N
EPSG:32736 WGS 84 / UTM zone 36S
EPSG:32637 WGS 84 / UTM zone 37N
EPSG:32737 WGS 84 / UTM zone 37S
EPSG:32638 WGS 84 / UTM zone 38N
EPSG:32738 WGS 84 / UTM zone 38S
EPSG:32639 WGS 84 / UTM zone 39N
EPSG:32739 WGS 84 / UTM zone 39S
EPSG:32603 WGS 84 / UTM zone 3N
EPSG:32703 WGS 84 / UTM zone 3S
EPSG:32640 WGS 84 / UTM zone 40N
EPSG:32740 WGS 84 / UTM zone 40S
EPSG:32641 WGS 84 / UTM zone 41N
EPSG:32741 WGS 84 / UTM zone 41S
EPSG:32642 WGS 84 / UTM zone 42N
EPSG:32742 WGS 84 / UTM zone 42S
EPSG:32643 WGS 84 / UTM zone 43N
EPSG:32743 WGS 84 / UTM zone 43S
EPSG:32644 WGS 84 / UTM zone 44N
EPSG:32744 WGS 84 / UTM zone 44S
EPSG:32645 WGS 84 / UTM zone 45N
EPSG:32745 WGS 84 / UTM zone 45S
EPSG:32646 WGS 84 / UTM zone 46N
EPSG:32746 WGS 84 / UTM zone 46S
EPSG:32647 WGS 84 / UTM zone 47N
EPSG:32747 WGS 84 / UTM zone 47S
EPSG:32648 WGS 84 / UTM zone 48N
EPSG:32748 WGS 84 / UTM zone 48S
EPSG:32649 WGS 84 / UTM zone 49N
EPSG:32749 WGS 84 / UTM zone 49S
EPSG:32604 WGS 84 / UTM zone 4N
EPSG:32704 WGS 84 / UTM zone 4S
EPSG:32650 WGS 84 / UTM zone 50N
EPSG:32750 WGS 84 / UTM zone 50S
EPSG:32651 WGS 84 / UTM zone 51N
EPSG:32751 WGS 84 / UTM zone 51S
EPSG:32652 WGS 84 / UTM zone 52N
EPSG:32752 WGS 84 / UTM zone 52S
EPSG:32653 WGS 84 / UTM zone 53N
EPSG:32753 WGS 84 / UTM zone 53S
EPSG:32654 WGS 84 / UTM zone 54N
EPSG:32754 WGS 84 / UTM zone 54S
EPSG:32655 WGS 84 / UTM zone 55N
EPSG:32755 WGS 84 / UTM zone 55S
EPSG:32656 WGS 84 / UTM zone 56N
EPSG:32756 WGS 84 / UTM zone 56S
EPSG:32657 WGS 84 / UTM zone 57N
EPSG:32757 WGS 84 / UTM zone 57S
EPSG:32658 WGS 84 / UTM zone 58N
EPSG:32758 WGS 84 / UTM zone 58S
EPSG:32659 WGS 84 / UTM zone 59N
EPSG:32759 WGS 84 / UTM zone 59S
EPSG:32605 WGS 84 / UTM zone 5N
EPSG:32705 WGS 84 / UTM zone 5S
EPSG:32660 WGS 84 / UTM zone 60N
EPSG:32760 WGS 84 / UTM zone 60S
EPSG:32606 WGS 84 / UTM zone 6N
EPSG:32706 WGS 84 / UTM zone 6S
EPSG:32607 WGS 84 / UTM zone 7N
EPSG:32707 WGS 84 / UTM zone 7S
EPSG:32608 WGS 84 / UTM zone 8N
EPSG:32708 WGS 84 / UTM zone 8S
EPSG:32609 WGS 84 / UTM zone 9N
EPSG:32709 WGS 84 / UTM zone 9S