-
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.]tablepgsql2x3d [options] database subqueryOPTIONS:-f filenameUse this option to specify the name of the file to create.If not present, the result will be printed on stdout.-h hostAllows you to specify connection to a database on a machine other than the default.-p portAllows you to specify a database port other than the default.-P passwordConnect to the database with the specified password.-u userConnect to the database as the specified user.-g geometry_columnSpecify the geometry column to be exported. This option is necessary.-t texture_name_columnSpecify the texture name column to be exported.-uv texture_coordinatesSpecify the texture coordinates column to be exported.!!!: If one of -t or -uv option is given, the other one must be given too.-pos positionSpecify the observator's position at the beginning.-gc ground_colorSpecify the ground color. (for example : '-gc 0.34 0.7 0.98')-sc sky_colorSpecify the sky color.-fc faces_colorSpecify 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 optionsmust 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.
_______________________________________________________________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 MABASEconnexion okquery okconnexion closedfile 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 MABASEconnexion okquery okconnexion closedfile 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.
-