diff --git a/SConstruct b/SConstruct index 5e4bf4417..246dc6dc1 100644 --- a/SConstruct +++ b/SConstruct @@ -1,4 +1,21 @@ -#mapnik SConctruct +# This file is part of Mapnik (c++ mapping toolkit) +# Copyright (C) 2005 Artem Pavlenko +# +# Mapnik is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# $Id$ import os @@ -23,7 +40,7 @@ cxx = 'g++' env = Environment(CXX=cxx,ENV=os.environ, options=opts) -cxx_debug='-Wall -ftemplate-depth-100 -O0 -fno-inline -g -pthread' +cxx_debug='-Wall -ftemplate-depth-100 -O0 -fno-inline -g -pthread -DDEBUG' cxx_release='-Wall -ftemplate-depth-100 -O2 -finline-functions -Wno-inline -pthread -DNDEBUG' release_env = env.Copy(CXXFLAGS = cxx_release) @@ -72,6 +89,9 @@ SConscript('src/SConscript') #python ext SConscript('python/SConscript') +#shapeindex +SConscript('util/shapeindex/SConscript') + #datasources for datasource in Split(env['DATASOURCES']): env.BuildDir('build/datasources/'+datasource,'src/datasources/'+datasource,duplicate=0) diff --git a/agg/SConscript b/agg/SConscript index 3e87edc07..810972d28 100644 --- a/agg/SConscript +++ b/agg/SConscript @@ -1,4 +1,22 @@ +# This file is part of Mapnik (c++ mapping toolkit) +# Copyright (C) 2005 Artem Pavlenko # +# Mapnik is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# $Id$ + import glob Import('env') diff --git a/boost/SConscript b/boost/SConscript index 1aab25682..94b6416be 100644 --- a/boost/SConscript +++ b/boost/SConscript @@ -1,4 +1,22 @@ -## +# This file is part of Mapnik (c++ mapping toolkit) +# Copyright (C) 2005 Artem Pavlenko +# +# Mapnik is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# $Id$ + import glob Import('env') diff --git a/datasources/postgis/SConscript b/datasources/postgis/SConscript index 3e5daad6d..115932abf 100644 --- a/datasources/postgis/SConscript +++ b/datasources/postgis/SConscript @@ -1,12 +1,28 @@ -#mapnik +# This file is part of Mapnik (c++ mapping toolkit) +# Copyright (C) 2005 Artem Pavlenko +# +# Mapnik is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# $Id$ + Import ('env') prefix = env['PREFIX'] boost_root = env['BOOST_ROOT'] postgresql_root = env['POSTGRESQL_ROOT'] -agg_root = env['AGG_ROOT'] -agg_headers = agg_root + '/include' postgresql_headers=postgresql_root+"/include" postgresql_libs=postgresql_root+"/lib" @@ -18,7 +34,7 @@ postgis_src = Split( """ ) -headers = ['#include',boost_root,agg_headers,postgresql_headers] +headers = ['#include',boost_root,postgresql_headers] postgis_datasource = env.SharedLibrary('postgis',source=postgis_src,SHLIBPREFIX='',CPPPATH=headers,LIBS="pq",LIBPATH=postgresql_libs) env.Install(prefix + '/datasources',postgis_datasource) env.Alias("install",prefix + '/datasources') diff --git a/datasources/postgis/connection.hpp b/datasources/postgis/connection.hpp index 4e65f087b..e28610bcb 100644 --- a/datasources/postgis/connection.hpp +++ b/datasources/postgis/connection.hpp @@ -23,7 +23,6 @@ #include "libpq-fe.h" -#include "mapnik.hpp" #include "resultset.hpp" using namespace mapnik; diff --git a/datasources/postgis/postgis.hpp b/datasources/postgis/postgis.hpp index e7524abe9..23c82a6e0 100644 --- a/datasources/postgis/postgis.hpp +++ b/datasources/postgis/postgis.hpp @@ -22,7 +22,10 @@ #define POSTGIS_HPP -#include "mapnik.hpp" +#include "datasource.hpp" +#include "envelope.hpp" +#include "feature.hpp" + #include "connection_manager.hpp" #include diff --git a/datasources/postgis/postgisfs.cpp b/datasources/postgis/postgisfs.cpp index 769799aa2..741492228 100644 --- a/datasources/postgis/postgisfs.cpp +++ b/datasources/postgis/postgisfs.cpp @@ -20,6 +20,8 @@ #include "postgis.hpp" +#include "global.hpp" +#include "wkb.hpp" using boost::lexical_cast; using boost::bad_lexical_cast; @@ -53,7 +55,7 @@ Feature* PostgisFeatureset::next() for (unsigned pos=0;posgetValue(start + pos); - int field_size = rs_->getFieldLength(start + pos); + //int field_size = rs_->getFieldLength(start + pos); int oid = rs_->getTypeOID(start + pos); if (oid==23) //int4 diff --git a/datasources/shape/SConscript b/datasources/shape/SConscript index 6d99108a7..4e1a520ff 100644 --- a/datasources/shape/SConscript +++ b/datasources/shape/SConscript @@ -1,11 +1,26 @@ -#mapnik +# This file is part of Mapnik (c++ mapping toolkit) +# Copyright (C) 2005 Artem Pavlenko +# +# Mapnik is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# $Id$ Import ('env') prefix = env['PREFIX'] boost_root = env['BOOST_ROOT'] -agg_root = env['AGG_ROOT'] -agg_headers = agg_root + '/include' shape_src = Split( """ @@ -19,8 +34,8 @@ shape_src = Split( """ ) -headers = ['#include',boost_root,agg_headers] +headers = ['#include',boost_root] -shape_datasource = env.SharedLibrary('shape',source=shape_src,SHLIBPREFIX='',CPPPATH=headers) +shape_datasource = env.SharedLibrary('shape',source=shape_src,SHLIBPREFIX='',LIBS="",CPPPATH=headers) env.Install(prefix+"/datasources",shape_datasource) - +env.Alias("install",prefix + '/datasources') diff --git a/datasources/shape/dbffile.cpp b/datasources/shape/dbffile.cpp index 35693a817..b05b6ed1f 100644 --- a/datasources/shape/dbffile.cpp +++ b/datasources/shape/dbffile.cpp @@ -17,6 +17,7 @@ */ #include "dbffile.hpp" +#include "utils.hpp" #include diff --git a/datasources/shape/dbffile.hpp b/datasources/shape/dbffile.hpp index 3e439f682..51cfb4ce8 100644 --- a/datasources/shape/dbffile.hpp +++ b/datasources/shape/dbffile.hpp @@ -24,7 +24,7 @@ #include #include -#include "mapnik.hpp" +#include "feature.hpp" using namespace mapnik; diff --git a/datasources/shape/shape.cpp b/datasources/shape/shape.cpp index 8417e1ee2..258a3340a 100644 --- a/datasources/shape/shape.cpp +++ b/datasources/shape/shape.cpp @@ -19,6 +19,7 @@ #include "shape.hpp" #include "shape_featureset.hpp" #include "shape_index_featureset.hpp" +#include "geom_util.hpp" #include #include diff --git a/datasources/shape/shape.hpp b/datasources/shape/shape.hpp index 63e23e40f..1db981cb3 100644 --- a/datasources/shape/shape.hpp +++ b/datasources/shape/shape.hpp @@ -19,7 +19,8 @@ #ifndef SHAPE_HH #define SHAPE_HH -#include "mapnik.hpp" +#include "datasource.hpp" +#include "envelope.hpp" #include "shape_io.hpp" using namespace mapnik; diff --git a/datasources/shape/shape_featureset.hpp b/datasources/shape/shape_featureset.hpp index d724acaad..63e5dcc91 100644 --- a/datasources/shape/shape_featureset.hpp +++ b/datasources/shape/shape_featureset.hpp @@ -20,6 +20,7 @@ #define SHAPE_FS_HH #include "shape.hpp" +#include "geom_util.hpp" using namespace mapnik; diff --git a/datasources/shape/shapefile.hpp b/datasources/shape/shapefile.hpp index 8a61251d2..c38e5551f 100644 --- a/datasources/shape/shapefile.hpp +++ b/datasources/shape/shapefile.hpp @@ -21,9 +21,10 @@ #ifndef SHAPEFILE_HH #define SHAPEFILE_HH -#include "mapnik.hpp" #include +#include "envelope.hpp" + using namespace mapnik; struct shape_record diff --git a/datasources/shape/shp_index.cpp b/datasources/shape/shp_index.cpp index 892a93cf7..4513060a6 100644 --- a/datasources/shape/shp_index.cpp +++ b/datasources/shape/shp_index.cpp @@ -17,6 +17,7 @@ */ #include "shp_index.hpp" +#include "geom_util.hpp" template void shp_index::query(const filterT& filter,std::ifstream& file,std::set& pos) diff --git a/datasources/shape/shp_index.hpp b/datasources/shape/shp_index.hpp index ad109130f..6f48b6106 100644 --- a/datasources/shape/shp_index.hpp +++ b/datasources/shape/shp_index.hpp @@ -19,7 +19,8 @@ #ifndef SHP_INDEX_HH #define SHP_INDEX_HH -#include "mapnik.hpp" +#include "envelope.hpp" +#include "query.hpp" #include #include diff --git a/include/geom_util.hpp b/include/geom_util.hpp index a686a9103..2b7222883 100644 --- a/include/geom_util.hpp +++ b/include/geom_util.hpp @@ -21,7 +21,6 @@ #ifndef GEOM_UTIL_HPP #define GEOM_UTIL_HPP -#include "geometry.hpp" #include namespace mapnik @@ -81,7 +80,7 @@ namespace mapnik } template - inline bool point_inside_path(Iter start,Iter end,double x,double y) + inline bool point_inside_path(double x,double y,Iter start,Iter end) { bool inside=false; double x0=start->x; @@ -145,57 +144,15 @@ namespace mapnik } #undef TOL - - inline bool point_on_path(double x,double y,const geometry& geom) + template + inline bool point_on_path(double x,double y,Iter start,Iter end) { - bool on_path=false; - if (geom.num_points()>1) - { - geometry::path_iterator itr=geom.begin(); - geometry::path_iterator end=geom.end(); - - double x0=itr->x; - double y0=itr->y; - - while (++itr!=end) - { - if (itr->cmd == SEG_MOVETO) - { - x0=itr->x; - y0=itr->y; - continue; - } - double x1=itr->x; - double y1=itr->y; - - on_path = point_on_segment(x,y,x0,y0,x1,y1); - if (on_path) - break; - - x0=itr->x; - y0=itr->y; - } - } - return on_path; + return false; } - - inline bool point_on_points (double x,double y,const geometry_type& geom) + + template + inline bool point_on_points (double x,double y,Iter start,Iter end) { - geometry::path_iterator itr=geom.begin(); - geometry::path_iterator end=geom.end(); - while (itr!=end) - { - double dx = x - itr->x; - double dy = y - itr->y; - double d = sqrt(dx*dx+dy*dy); - - if (d < 0.02) - { - std::cout<<"d="<x="<x<<" itr->y="<y< class Container=vertex_vector> class point : public geometry { + typedef geometry geometry_base; typedef typename geometry::value_type value_type; using geometry::cont_; public: @@ -196,7 +198,10 @@ namespace mapnik } bool hit_test(value_type x,value_type y) const { - return point_on_points(x,y,*this); + typedef typename geometry_base::template path_iterator path_iterator; + path_iterator start = geometry_base::template begin(); + path_iterator end = geometry_base::template end(); + return point_on_points(x,y,start,end); } }; @@ -221,13 +226,14 @@ namespace mapnik typedef typename geometry_base::template path_iterator path_iterator; path_iterator start = geometry_base::template begin(); path_iterator end = geometry_base::template end(); - return point_inside_path(start,end,x,y); + return point_inside_path(x,y, start,end); } }; template class Container=vertex_vector> class line_string : public geometry { + typedef geometry geometry_base; typedef typename geometry::value_type value_type; public: line_string(int srid) @@ -241,7 +247,10 @@ namespace mapnik bool hit_test(value_type x,value_type y) const { - return point_on_path(x,y,*this); + typedef typename geometry_base::template path_iterator path_iterator; + path_iterator start = geometry_base::template begin(); + path_iterator end = geometry_base::template end(); + return point_on_path(x,y,start,end); } }; diff --git a/python/SConscript b/python/SConscript index 8a4f448b1..3a10d91a0 100644 --- a/python/SConscript +++ b/python/SConscript @@ -1,3 +1,22 @@ +# This file is part of Mapnik (c++ mapping toolkit) +# Copyright (C) 2005 Artem Pavlenko +# +# Mapnik is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# $Id$ + import os import SCons.Errors import SCons.Defaults diff --git a/settings.py b/settings.py index 4a327aecd..978582adc 100644 --- a/settings.py +++ b/settings.py @@ -1,3 +1,22 @@ +# This file is part of Mapnik (c++ mapping toolkit) +# Copyright (C) 2005 Artem Pavlenko +# +# Mapnik is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# $Id$ + #edit this file PREFIX = '/opt/mapnik' diff --git a/src/SConscript b/src/SConscript index 9d15e77f2..32601973b 100644 --- a/src/SConscript +++ b/src/SConscript @@ -1,4 +1,22 @@ -## +# This file is part of Mapnik (c++ mapping toolkit) +# Copyright (C) 2005 Artem Pavlenko +# +# Mapnik is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# $Id$ + import glob Import ('env') diff --git a/util/shapeindex/config.hpp b/util/shapeindex/config.hpp deleted file mode 100644 index dc511e617..000000000 --- a/util/shapeindex/config.hpp +++ /dev/null @@ -1,23 +0,0 @@ -/* config.hh. Generated by configure. */ -/* config.hh.in. Generated from configure.ac by autoheader. */ - -/* Name of package */ -#define PACKAGE "shapeindex" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "bugs@shapeindex" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "shapeindex" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "shapeindex 0.1" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "shapeindex" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "0.1" - -/* Version number of package */ -#define VERSION "0.1" diff --git a/util/shapeindex/quadtree.cpp b/util/shapeindex/quadtree.cpp deleted file mode 100644 index 994554e29..000000000 --- a/util/shapeindex/quadtree.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* This file is part of Mapnik (c++ mapping toolkit) - * Copyright (C) 2005 Artem Pavlenko - * - * Mapnik is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -//$Id: quadtree.cc 17 2005-03-08 23:58:43Z pavlenko $ - -#include "quadtree.hh" diff --git a/util/shapeindex/quadtree.hpp b/util/shapeindex/quadtree.hpp index 36ebe8825..c0d2261a2 100644 --- a/util/shapeindex/quadtree.hpp +++ b/util/shapeindex/quadtree.hpp @@ -21,7 +21,7 @@ #ifndef QUADTREE_HH #define QUADTREE_HH -#include "mapnik.hh" +#include "envelope.hpp" #include #include diff --git a/util/shapeindex/shapeindex.cpp b/util/shapeindex/shapeindex.cpp index 9c40636d5..71e9f3b61 100644 --- a/util/shapeindex/shapeindex.cpp +++ b/util/shapeindex/shapeindex.cpp @@ -18,192 +18,183 @@ //$Id: shapeindex.cc 27 2005-03-30 21:45:40Z pavlenko $ -#include -#include -#include "config.hh" -#include "mapnik.hh" -#include "shape.hh" -#include "quadtree.hh" +#include "shape.hpp" +#include "quadtree.hpp" +#include +#include +#include + +#include +#include +#include const int MAXDEPTH = 64; -const int DEFAULT_DEPTH = 16; +const int DEFAULT_DEPTH = 8; const double MINRATIO=0.5; const double MAXRATIO=0.8; const double DEFAULT_RATIO=0.55; -const char* argp_program_version = "shapeindex utility version 0.1"; -const char* argp_program_bug_address="bugs@shapeindex"; - -static char doc[] = "shapeindex utility to create spatial index"; - -static char args_doc[]="shape_file"; - -static struct argp_option options[] = { - {"verbose",'v',0, 0,"Produce verbose output"}, - {"quite", 'q',0, 0,"Don't produce any output"}, - {"silent", 's',0, OPTION_ALIAS}, - {0,0,0,0, "shape index options:" }, - {"depth", 'd',"VALUE",0,"maximum depth of the tree (default=16)"}, - {"ratio", 'r',"VALUE",0,"split ratio between 0.5-0.9 (default 0.55)"}, - { 0 } -}; - -struct arguments { - char *args[2]; - int silent; - int verbose; - int depth; - double ratio; -}; - -static error_t -parse_opt ( int key,char *arg, struct argp_state *state) { - struct arguments* arguments = (struct arguments*)state->input; - switch (key) +int main (int argc,char** argv) +{ + using namespace mapnik; + namespace po = boost::program_options; + using std::string; + using std::vector; + + bool verbose=false; + unsigned int depth=DEFAULT_DEPTH; + double ratio=DEFAULT_RATIO; + vector shape_files; + + try { - case 'q': - case 's': - arguments->silent = 1; - break; - case 'v': - arguments->verbose = 1; - break; - case 'd': - arguments->depth = arg ? atoi(arg) : DEFAULT_DEPTH; - break; - case 'r': - arguments->ratio = arg ? atof(arg) : DEFAULT_RATIO; - break; - case ARGP_KEY_NO_ARGS: - argp_usage (state); - case ARGP_KEY_ARG: - if (state->arg_num>=1) - //too many arguments. - argp_usage (state); - arguments->args[state->arg_num] = arg; - break; - case ARGP_KEY_END: - if (state->arg_num < 1) - //not enough arguments - argp_usage (state); - break; - default: - return ARGP_ERR_UNKNOWN; + po::options_description desc("shapeindex utility"); + desc.add_options() + ("help,h", "produce usage message") + ("version,V","print version string") + ("verbose,v","verbose output") + ("depth,d", po::value(), "max tree depth\n(default 8)") + ("ratio,r",po::value(),"split ratio (default 0.55)") + ("shape_files",po::value >(),"shape files to index file1 file2 ...fileN") + ; + + po::positional_options_description p; + p.add("shape_files",-1); + po::variables_map vm; + po::store(po::command_line_parser(argc, argv).options(desc).positional(p).run(), vm); + po::notify(vm); + + if (vm.count("version")) + { + cout<<"version 0.2.0a" <(); + } + if (vm.count("ratio")) + { + ratio = vm["ratio"].as(); + } + + if (vm.count("shape_files")) + { + shape_files=vm["shape_files"].as< vector >(); + } } - return 0; -} - -static struct argp argp = { options, parse_opt, args_doc, doc }; - -using namespace mapnik; - -int main (int argc,char** argv) { - - struct arguments arguments; - - arguments.silent = 0; - arguments.verbose = 0; - arguments.silent = 0; - arguments.depth = DEFAULT_DEPTH; - arguments.ratio = DEFAULT_RATIO; - argp_parse(&argp, argc, argv, 0, 0, &arguments); - - std::cout<<"processing "< extent; - shp.read_envelope(extent); + vector::const_iterator itr=shape_files.begin(); + if (itr==shape_files.end()) + { + std::cout << "no shape files to index"< tree(extent,arguments.depth,arguments.ratio); - int count=0; - while (true) { - - int offset=shp.pos(); - int record_number=shp.read_xdr_integer(); - int content_length=shp.read_xdr_integer(); + + int pos=50; + shp.seek(pos*2); + quadtree tree(extent,depth,ratio); + int count=0; + while (true) { + + int offset=shp.pos(); + int record_number=shp.read_xdr_integer(); + int content_length=shp.read_xdr_integer(); - shp.skip(4); - Envelope item_ext; - if (shape_type==shape_io::shape_point) - { - double x=shp.read_double(); - double y=shp.read_double(); - shp.skip(2*content_length-2*8-4); - item_ext=Envelope(x,y,x,y); + shp.skip(4); + Envelope item_ext; + if (shape_type==shape_io::shape_point) + { + double x=shp.read_double(); + double y=shp.read_double(); + shp.skip(2*content_length-2*8-4); + item_ext=Envelope(x,y,x,y); - } - else if (shape_type==shape_io::shape_pointz) - { - double x=shp.read_double(); - double y=shp.read_double(); - double z=shp.read_double(); - shp.skip(2*content_length-2*8-4); - item_ext=Envelope(x,y,x,y); - } + } + else if (shape_type==shape_io::shape_pointz) + { + double x=shp.read_double(); + double y=shp.read_double(); + shp.read_double(); + shp.skip(2*content_length-2*8-4); + item_ext=Envelope(x,y,x,y); + } - else - { + else + { - shp.read_envelope(item_ext); - shp.skip(2*content_length-4*8-4); + shp.read_envelope(item_ext); + shp.skip(2*content_length-4*8-4); - } + } - tree.insert(offset,item_ext); - if (arguments.verbose) { - std::cout<<"record number "<