Changes between Initial Version and Version 1 of PerlshapefileObj


Ignore:
Timestamp:
Jan 29, 2009, 10:56:57 AM (15 years ago)
Author:
jmckenna
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PerlshapefileObj

    v1 v1  
     1= shapefileObj =
     2
     3{{{
     4#!perl
     5$shapefile = new mapscript::shapefileObj('lakes',-1) or die "Unable to open lakes shapefile";
     6
     7$extents = $shapefile->{bounds};
     8
     9$numshapes = $shapefile->{numshapes};
     10
     11$typeno = $shapefile->{type};
     12
     13$shapefile->add($shape);
     14
     15This example saves a selected polygon shape into a new shapefile.
     16#
     17# Open the map.
     18my $map = new mapscript::mapObj('your.map');
     19#
     20# Create the layer object to query.
     21my $layer = new mapscript::layerObj($map);
     22#
     23# Create a new shapefile for the selection set.
     24my $newshpf = new mapscript::shapefileObj("$newshpfname",  $mapscript::MS_SHAPEFILE_POLYGON);
     25#
     26# Set index value for selected shape.
     27my $poly = 400;
     28#
     29# Create a shapefile object for getting queried shape.
     30my $shpf = new mapscript::shapefileObj("data_shapefile", -1);
     31#
     32# Create shape object for storing queried shape.
     33my $shp = new mapscript::shapeObj(-1);
     34#
     35# Retrieve shape into shape object.
     36$shpf->get($poly, $shp);
     37#
     38# Put shape into new shapefile.
     39$newshpf->add($shp);
     40#
     41# Create dbf to go with new.
     42@toucherror = system("touch $newshpfname.dbf");
     43#
     44# Get the extent of the new shapefile.
     45my $newrect = $newshpf->{bounds};
     46my $newminx = $newrect->{minx};
     47my $newminy = $newrect->{miny};
     48my $newmaxx = $newrect->{maxx};
     49my $newmaxy = $newrect->{maxy};
     50#
     51# Close new shapefile.
     52undef $newshpf;
     53}}}
     54----
     55back to PerlMapScript