# # - Geo::Shapelib - # This spec file was automatically generated by cpan2rpm [ver: 2.028] # The following arguments were used: # -i http://search.cpan.org/CPAN/authors/id/A/AJ/AJOLMA/Geo-Shapelib-0.20.tar.gz # For more information on cpan2rpm please visit: http://perl.arix.com/ # %define pkgname Geo-Shapelib %define filelist %{pkgname}-%{version}-filelist %define NVR %{pkgname}-%{version}-%{release} %define maketest 1 name: perl-Geo-Shapelib summary: Geo-Shapelib - Perl extension for reading and writing shapefiles as defined by ESRI(r) version: 0.20 release: 1 vendor: Ari Jolma packager: Arix International license: Artistic group: Applications/CPAN url: http://www.cpan.org buildroot: %{_tmppath}/%{name}-%{version}-%(id -u -n) buildarch: i386 prefix: %(echo %{_prefix}) source: http://search.cpan.org/CPAN/authors/id/A/AJ/AJOLMA/Geo-Shapelib-0.20.tar.gz %description This is a library for reading, creating, and writing shapefiles as defined by ESRI(r) using Perl. The Perl code uses Frank Warmerdam's Shapefile C Library (http://shapelib.maptools.org/). The library is included in this distribution. Currently no methods exist for populating an empty Shape. You need to do it in your own code. This is how: First you include the module into your code. If you want to define the shape type using its name, import all: use Geo::Shapelib qw/:all/; Create the shapefile object and specify its name and type: $shapefile = new Geo::Shapelib { Name => , Shapetype => , FieldNames => , FieldTypes => } The name (filename, may include path) of the shapefile, the extension is not used (it is stripped in the save method). The shape type is an integer. This module defines shape type names as constants (see below). The field name list is an array reference of the names of the data items assigned to each shape. The field type list is an array reference of the types of the data items. Field type is either 'Integer', 'Double', or 'String'. The types may have optional 'width' and 'decimals' fields defined, like this: 'Integer[:width]' defaults: width = 10 'Double[:width[:decimals]]' defaults: width = 10, decimals = 4 'String[:width]' defaults: width = 255 There are some other attributes which can be defined in the constructor (see below), they are rarely needed. The shape object will need or get a couple of other attributes as well. They should be treated as private: $shapefile->{NShapes} is the number of shapes in your object. Shapefile is a collection of shapes. This is usually automatically deduced from the Shapes array when needed. $shapefile->{MinBounds} is set by shapelib C functions. $shapefile->{MaxBounds} is set by shapelib C functions. Create the shapes and respective shape records and put them into the shape: for many times { make $s, a new shape as a reference to a hash push @{$shapefile->{Shapes}}, $s; make $r, a shape record as a reference to an array push @{$shapefile->{ShapeRecords}}, $r; } how to create $s? It is a (reference to an) hash. set: $s->{Vertices} this is a reference to an array of arrays of four values, one for each vertex: x, y, z, and m of the vertex. There should be at least one vertex in $s. Point has only one vertex. $s->{Parts}: $s->{Parts} is not needed in simple cases. $s->{Parts} is a reference to an array (a) of arrays (b). There is one (b) array for each part. In a (b) array the first value is an index to the Vertices array denoting the first vertex of that part. The second value is the type of the part (NOTE: not the type of the shape). The type is 5 (Ring) unless the shape is of type Multipatch. The third value is set as the type of the part as a string when reading from a file but the save method requires only the first two values. The index of the last vertex of any part is implicitly the index of the next part minus one or the index of the last vertex. forget these: $s->{ShapeId} may be left undefined. The save method sets it to the index in the Shapes array. Instead create and use an id field in the record. $s->{NParts} and $s->{NVertices} may be set but that is usually not necessary since they are calculated in the save method. You only need to set these if you want to save less parts or vertices than there actually are in the Parts or Vertices arrays. $s->{SHPType} is the type of the shape and it is automatically set to $shape->{Shapetype} unless defined (which you should not do) The shape record is simply an array reference, for example: $r = [item1,item2,item3,...]; That's all. Then save it and start your shapefile viewer to look at the result. # # This package was generated automatically with the cpan2rpm # utility. To get this software or for more information # please visit: http://perl.arix.com/ # %prep %setup -q -n %{pkgname}-%{version} chmod -R u+w %{_builddir}/%{pkgname}-%{version} %build grep -rsl '^#!.*perl' . | grep -v '.bak$' |xargs --no-run-if-empty \ %__perl -MExtUtils::MakeMaker -e 'MY->fixin(@ARGV)' CFLAGS="$RPM_OPT_FLAGS" %{__perl} Makefile.PL `%{__perl} -MExtUtils::MakeMaker -e ' print qq|PREFIX=%{buildroot}%{_prefix}| if \$ExtUtils::MakeMaker::VERSION =~ /5\.9[1-6]|6\.0[0-5]/ '` %{__make} %if %maketest %{__make} test %endif %install [ "%{buildroot}" != "/" ] && rm -rf %{buildroot} %{makeinstall} `%{__perl} -MExtUtils::MakeMaker -e ' print \$ExtUtils::MakeMaker::VERSION <= 6.05 ? qq|PREFIX=%{buildroot}%{_prefix}| : qq|DESTDIR=%{buildroot}| '` cmd=/usr/share/spec-helper/compress_files [ -x $cmd ] || cmd=/usr/lib/rpm/brp-compress [ -x $cmd ] && $cmd # SuSE Linux if [ -e /etc/SuSE-release -o -e /etc/UnitedLinux-release ] then %{__mkdir_p} %{buildroot}/var/adm/perl-modules %{__cat} `find %{buildroot} -name "perllocal.pod"` \ | %{__sed} -e s+%{buildroot}++g \ > %{buildroot}/var/adm/perl-modules/%{name} fi # remove special files find %{buildroot} -name "perllocal.pod" \ -o -name ".packlist" \ -o -name "*.bs" \ |xargs -i rm -f {} # no empty directories find %{buildroot}%{_prefix} \ -type d -depth \ -exec rmdir {} \; 2>/dev/null %{__perl} -MFile::Find -le ' find({ wanted => \&wanted, no_chdir => 1}, "%{buildroot}"); print "%doc example TODO Changes shapelib README"; for my $x (sort @dirs, @files) { push @ret, $x unless indirs($x); } print join "\n", sort @ret; sub wanted { return if /auto$/; local $_ = $File::Find::name; my $f = $_; s|^\Q%{buildroot}\E||; return unless length; return $files[@files] = $_ if -f $f; $d = $_; /\Q$d\E/ && return for reverse sort @INC; $d =~ /\Q$_\E/ && return for qw|/etc %_prefix/man %_prefix/bin %_prefix/share|; $dirs[@dirs] = $_; } sub indirs { my $x = shift; $x =~ /^\Q$_\E\// && $x ne $_ && return 1 for @dirs; } ' > %filelist [ -z %filelist ] && { echo "ERROR: empty %files listing" exit -1 } %clean [ "%{buildroot}" != "/" ] && rm -rf %{buildroot} %files -f %filelist %defattr(-,root,root) %changelog * Sat Oct 30 2010 root@hampacket.trinnet.net - Initial build.