/***************************************************************************** * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2006 Artem Pavlenko * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ #include #include #include #include // boost #include #include #include "shape_featureset.hpp" #include "shape_index_featureset.hpp" #include "shape.hpp" DATASOURCE_PLUGIN(shape_datasource) using mapnik::String; using mapnik::Double; using mapnik::Integer; using mapnik::datasource_exception; using mapnik::filter_in_box; using mapnik::filter_at_point; using mapnik::attribute_descriptor; shape_datasource::shape_datasource(const parameters ¶ms) : datasource (params), type_(datasource::Vector), file_length_(0), indexed_(false), desc_(*params.get("type"), *params.get("encoding","utf-8")) { boost::optional file = params.get("file"); if (!file) throw datasource_exception("missing parameter"); boost::optional base = params.get("base"); if (base) shape_name_ = *base + "/" + *file; else shape_name_ = *file; boost::algorithm::ireplace_last(shape_name_,".shp",""); if (!boost::filesystem::exists(shape_name_ + ".shp")) throw datasource_exception(shape_name_ + " does not exist"); try { shape_io shape(shape_name_); init(shape); for (int i=0;i0) { desc_.add_descriptor(attribute_descriptor(fld_name,Double,false,8)); } else { desc_.add_descriptor(attribute_descriptor(fld_name,Integer,false,4)); } break; } default: #ifdef MAPNIK_DEBUG std::clog << "unknown type "<