Another export function I decided to create is asx3d(). X3D is the VRML successor and describes an XML syntax. So it's a 3D format which is fine to use in a web environment.
This function is available for:
- POINT
- MULTIPOINT
- LINESTRING
- MULTILINESTRING
- POLYGON
- MULTIPOLYGON
- TIN
- POLYHEDRALSURFACE
Here are some example queries of its use:
- POINT/MULTIPOINT LINESTRING/MULTILINESTRING
___________________________________________________________________
SELECT asx3d('POINT(1 2 3)');
SELECT asx3d('MULTIPOINT(1 2 3, 4 5 6)');
SELECT asx3d('LINESTRING(1 2 3, 4 5 6)');
SELECT asx3d('MULTILINESTRING((1 2 3, 4 5 6), (0 0 0, 5 4 6))');
___________________________________________________________________
- TIN and POLYHEDRALSURFACE:
______________________________________________________________________________________________________________
SELECT asx3d('TIN(((0 0 0, 1 0 0 , 0 1 0, 0 0 0)),((1 0 0, 0 0 1, 0 1 0, 1 0 0)))');
SELECT asx3d('POLYHEDRALSURFACE(((0 0 0, 0 1 0, 1 1 0, 0 0 0)), ((0 0 0, 1 0 0, 1 0 1, 0 0 1, 0 0 0)))');
______________________________________________________________________________________________________________
PGSQL2X3D command:
I also developed a command which creates x3d files by exporting geometries from PostGIS.
Here is the help of this command:
__________________________________________________________
USAGE: pgsql2x3d [options] database [schema.]table
pgsql2x3d [options] database subquery
OPTIONS:
-f filename
Use this option to specify the name of the file to create.
If not present, the result will be printed on stdout.
-h host
Allows you to specify connection to a database on a machine other than the default.
-p port
Allows you to specify a database port other than the default.
-P password
Connect to the database with the specified password.
-u user
Connect to the database as the specified user.
-g geometry_column
Specify the geometry column to be exported. This option is necessary.
-t texture_name_column
Specify the texture name column to be exported.
-uv texture_coordinates
Specify the texture coordinates column to be exported.
!!!: If one of -t or -uv option is given, the other one must be given too.
-pos position
Specify the observator's position at the beginning.
-gc ground_color
Specify the ground color. (for example : '-gc 0.34 0.7 0.98')
-sc sky_color
Specify the sky color.
-fc faces_color
Specify the color of faces which are not textured.
-?
Display this help screen.
If you give a subquery instead of a table name in parameter, the -g -t and -uv options
must be the names of the alias you give in the subquery.
Example:
pgsql2x3d -g geom -t tex -uv uvcoord -f testfile mydatabase 'SELECT ST_RotateX(the_geom, 2)
AS geom, the_texture AS tex, coorduv AS uvcoord from mytable'
__________________________________________________________
EXAMPLES:
In these examples the names of the database, the table, the geometry_column, the texture_column and the texture_coordinates column are respectively MABASE mytable the_geom, the_texture and coorduv.
- simple X3D export:
_______________________________________________________________
pgsql2x3d -u postgres -f testfile -g the_geom MABASE mytable
_______________________________________________________________
If you execute this command, you'll see see this in your window
_________________________________
ask for connection to MABASE
connexion ok
query ok
connexion closed
file testfile.x3d has been created
_________________________________
You need an X3D viewer to see testfile.x3d. X3D is the successor of VRML, so, most of VRML viewers works for X3D too. You can use for example freewrl which is a free software you can get here.
By executing this command:
____________________
freewrl testfile.x3d
____________________
you'll see this:
- X3D export with textures:
_____________________________________________________________________________________________
pgsql2x3d -u postgres -f testfile -g the_geom -t the_texture -uv coorduv MABASE mytable
_____________________________________________________________________________________________
If you execute this command, you'll see see this in your window
_________________________________
ask for connection to MABASE
connexion ok
query ok
connexion closed
file testfile.x3d has been created
_________________________________
By executing this command
____________________
freewrl testfile.x3d
____________________
you'll see this:
including X3D in a web browser:
An advantage of X3D format is that it's easy to use in a web environment because of its XML syntax.
Here is an example with two files you can get here. If you place them on a server, change the path of the file x3d.php in the index.htm one and put the query that interests you, you can get this result in a web browser at the right url:
Unfortunately, x3d plugins for web browthers aren't really competitive for now. The best solution seems to be the use of FLUX Player, available on MediaMachines website, and Internet explorer on Windows. Indeed, consequents geometries could need about a minute to be loaded.
-
Aucun commentaire:
Enregistrer un commentaire