[Chameleon] dynamic mapfile

Julien-Samuel Lacroix jlacroix at mapgears.com
Fri Apr 20 12:13:30 EDT 2007


Hi,
If you want to query your dynamic data, you'll have to create a 
temporary shapfile. You can't insert attributes in the the inline 
feature other than the text. To create a new shapefile, put the shape 
object you were adding to your layer features in a shapefile object. 
Than to add attributes, you'll have to create a separate DBF files. 
Here's a sample code:

$aDbfStruct =   array(
                        array( 'id'       ,'N', 7, 0),
                        array( 'specie'       ,'C', 50),
                        array( 'country'      ,'C', 50)
                      );
$dbfFile = dbase_create( $szFileName.'.dbf', $aDbfStruct);

$shpFile = ms_newShapeFileObj( $szFileName, -2 );
$oShp = ms_newShapeObj(MS_SHP_LINE);
$oLine = ms_newLineObj();
$nPoints = count($aPoints);
for ( $i=0; $i<$nPoints; $i++ )
{
     $oLine->addXY($aPoints[$i]['x'], $aPoints[$i]['y']);
}
$oShp->add( $oLine );
$oLine->free();
$shpFile->addShape($oShp);
$oShp->free();
dbase_add_record( $dbfFile, array_values( 1, 'specie', 'country' ) );
dbase_close($dbfFile);


You can also manage everything in a PostGIS, but that's a different world.

Julien



anthony farrant wrote:
> Hi guys,
> 
> I succeeded in creating dynamic layers by dynamically creating a mapfile 
> with *INLINE FEATURES* and passing it as an argument to the 
> initialization script. Works fine with the exception that:
> 
> I can't add other attributes than the coordinates (latitude & longitude) 
> and by consequence I cannot make the layer queryable.
> 
> I was wondering if it was possible to add attributes (like in a 
> shapefile: country, species name, source) to the layer with the "INLINE 
> FEATURES technique".
> 
> If not is it possible to add queryable attributes (like in a shapefile: 
> country, species name, source) to a dynamically created layer with 
> MAPSCRIPT.
> 
> I know these attributes usually come in a "dbf"-file but is it possible 
> to associate these with  a dynamic layer? 
> 
> I'm kind of stuck at this point so any kind of help is welcome.
> 
> Have a nice weekend y'all,
> 
> Anthony
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Chameleon mailing list
> Chameleon at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/chameleon

-- 
Julien-Samuel Lacroix
Mapgears
http://www.mapgears.com/


More information about the Chameleon mailing list