Changes between Initial Version and Version 1 of PerlshapeObj


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

--

Legend:

Unmodified
Added
Removed
Modified
  • PerlshapeObj

    v1 v1  
     1= shapeObj =
     2
     3{{{
     4#!perl
     5$shape = new mapscript::shapeObj(-1);
     6
     7$shape = new mapscript::shapeObj($mapscript::MS_SHAPE_POLYGON);
     8
     9$extents = $shape->{bounds};
     10
     11$minx = $shape->{bounds}->{minx};
     12$miny = $shape->{bounds}->{miny};
     13$maxx = $shape->{bounds}->{maxx};
     14$maxy = $shape->{bounds}->{maxy};
     15
     16$numlines = $shape->{numlines};
     17
     18$street_poly->get($result_mem->{shapeindex},$selected_shape);
     19
     20my $result_shape = $prcl_dim_layer->getResult(0);
     21
     22for($i=0; $i<$numshapes; i++) {
     23  $shapefile->get($i, $shape);
     24  ...
     25}
     26
     27This example retrieves all of the x,y's for all the lines in a polygon shape.
     28#
     29# Create shape object.
     30$shp = new mapscript::shapeObj(-1);
     31#
     32# Retrieve shape into shape object.
     33$shpfile->get(1,$shp);
     34#
     35# How many lines in shape.
     36my $num_lines = $shp->{numlines};
     37#
     38# Loop through each line.
     39for ( $line_num=0; $line_num<$num_lines; $line_num++ ) {
     40  #
     41  # Get line.
     42  my $line = new mapscript::lineObj();
     43  $line = $ishp->get($line_num);
     44  print "Got Line #$line_num\n";
     45  #
     46  # How many points in line.
     47  my $num_points = $line->{numpoints};
     48  #
     49  # Loop through each point.
     50  for ( $point_num=0; $point_num<$num_points; $point_num++ ) {
     51    #
     52    # Get the point.
     53    my $point = new mapscript::pointObj();
     54    $point = $line->get($point_num);
     55    print "Got Point #$point_num";
     56    $px = $point->{x};
     57    $py = $point->{y};
     58    print " X=$px Y=$py\n";
     59  }
     60}
     61print "\n";
     62
     63}}}
     64----
     65back to PerlMapScript