[Mapserver-users] How can mapserver show a text file???

Manfred Meier m.meier at spiekermann.de
Tue Jun 15 00:22:13 EDT 2004


I would use a program to convert the text file to a shape-file. See 
below for a little test program using perl/mapscript. I'm using 
mapserver 4.0.2.

#!/usr/bin/perl

use strict;
use mapscript;
use XBase;

my $SHP_NAM     = "shpfile"; # name of shape-file trio

#--- Delete old shape files. commented out because dangerous.
#unlink $SHP_NAM . ".dbf";
#unlink $SHP_NAM . ".shp";
#unlink $SHP_NAM . ".shx";

#--- Test data.
my @data = ( [  10,  10, "1st point" ],
              [ 100, 100, "2nd point" ],
              [  75,  90, "3rd point" ] );

#--- Create Point-Shape
#
my $sf1 = new mapscript::shapefileObj (
                         $SHP_NAM,
                         $mapscript::MS_SHAPEFILE_POINT);
foreach my $i (0 .. $#data)
{
     my $pt = new mapscript::pointObj();
     $pt->{x} = $data[$i]->[0];
     $pt->{y} = $data[$i]->[1];
     $sf1->addPoint ($pt);
}
undef $sf1;

#-  create the dbf file. I think the dbf-file must not exist
#   before creating a new one.
#
my @fieldnames = (   'id', 'ptname');
my @fieldtypes = (    'N',      'C');
my @fieldlengths = ( '10',     '10');
my @fielddecimals = ( '0',      '0');

my $tab = XBase->create('name'           => $SHP_NAM . ".dbf",
                             'field_names'    => \@fieldnames,
                             'field_types'    => \@fieldtypes,
                             'field_lengths'  => \@fieldlengths,
                             'field_decimals' => \@fielddecimals)
             or die XBase->errstr();
foreach my $i (0 .. $#data)
{
     $tab->set_record($i, $i, $data[$i]->[2]);
}
$tab->close();







joanvp schrieb:

> I'd like to know how can I insert a text file (for
> example, from a GPS) in Mapserver.
> And a final question,Is it possible to show a gml?
> 
> Excuse my english...
> Thank you
> 
> 
> 	
> 		
> __________________________________
> Do you Yahoo!?
> Friends.  Fun.  Try the all-new Yahoo! Messenger.
> http://messenger.yahoo.com/ 
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
> 




More information about the mapserver-users mailing list