- aligned code style in geos plugin

This commit is contained in:
kunitoki 2011-10-23 21:19:56 +02:00
parent 2cf56bf767
commit 9967132b78
5 changed files with 91 additions and 100 deletions

View file

@ -2,7 +2,7 @@
* *
* This file is part of Mapnik (c++ mapping toolkit) * This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2010 Artem Pavlenko * Copyright (C) 2011 Artem Pavlenko
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -19,16 +19,16 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*****************************************************************************/ *****************************************************************************/
// $Id$
#include "geos_datasource.hpp"
#include "geos_featureset.hpp"
// stl
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <stdexcept> #include <stdexcept>
#include <cstdarg> #include <cstdarg>
#include "geos_datasource.hpp"
#include "geos_featureset.hpp"
// mapnik // mapnik
#include <mapnik/ptree_helpers.hpp> #include <mapnik/ptree_helpers.hpp>
#include <mapnik/geom_util.hpp> #include <mapnik/geom_util.hpp>
@ -44,17 +44,9 @@
// geos // geos
#include <geos_c.h> #include <geos_c.h>
using std::clog;
using std::endl;
using boost::lexical_cast; using boost::lexical_cast;
using boost::bad_lexical_cast; using boost::bad_lexical_cast;
using mapnik::datasource;
using mapnik::parameters;
DATASOURCE_PLUGIN(geos_datasource)
using mapnik::box2d; using mapnik::box2d;
using mapnik::coord2d; using mapnik::coord2d;
using mapnik::query; using mapnik::query;
@ -62,9 +54,12 @@ using mapnik::featureset_ptr;
using mapnik::layer_descriptor; using mapnik::layer_descriptor;
using mapnik::attribute_descriptor; using mapnik::attribute_descriptor;
using mapnik::datasource_exception; using mapnik::datasource_exception;
using mapnik::datasource;
using mapnik::parameters;
using mapnik::filter_in_box; using mapnik::filter_in_box;
using mapnik::filter_at_point; using mapnik::filter_at_point;
DATASOURCE_PLUGIN(geos_datasource)
void geos_notice(const char* fmt, ...) void geos_notice(const char* fmt, ...)
{ {
@ -153,7 +148,7 @@ void geos_datasource::bind() const
if (! extent_initialized_) if (! extent_initialized_)
{ {
#ifdef MAPNIK_DEBUG #ifdef MAPNIK_DEBUG
clog << "GEOS Plugin: initializing extent from geometry" << endl; std::clog << "GEOS Plugin: initializing extent from geometry" << std::endl;
#endif #endif
if (GEOSGeomTypeId(*geometry_) == GEOS_POINT) if (GEOSGeomTypeId(*geometry_) == GEOS_POINT)
@ -177,7 +172,7 @@ void geos_datasource::bind() const
{ {
#ifdef MAPNIK_DEBUG #ifdef MAPNIK_DEBUG
char* wkt = GEOSGeomToWKT(*envelope); char* wkt = GEOSGeomToWKT(*envelope);
clog << "GEOS Plugin: getting coord sequence from: " << wkt << endl; std::clog << "GEOS Plugin: getting coord sequence from: " << wkt << std::endl;
GEOSFree(wkt); GEOSFree(wkt);
#endif #endif
@ -188,7 +183,7 @@ void geos_datasource::bind() const
if (cs != NULL) if (cs != NULL)
{ {
#ifdef MAPNIK_DEBUG #ifdef MAPNIK_DEBUG
clog << "GEOS Plugin: iterating boundary points" << endl; std::clog << "GEOS Plugin: iterating boundary points" << std::endl;
#endif #endif
double x, y; double x, y;
@ -196,8 +191,8 @@ void geos_datasource::bind() const
miny = std::numeric_limits<float>::max(), miny = std::numeric_limits<float>::max(),
maxx = -std::numeric_limits<float>::max(), maxx = -std::numeric_limits<float>::max(),
maxy = -std::numeric_limits<float>::max(); maxy = -std::numeric_limits<float>::max();
unsigned int num_points;
unsigned int num_points;
GEOSCoordSeq_getSize(cs, &num_points); GEOSCoordSeq_getSize(cs, &num_points);
for (unsigned int i = 0; i < num_points; ++i) for (unsigned int i = 0; i < num_points; ++i)
@ -220,7 +215,9 @@ void geos_datasource::bind() const
} }
if (! extent_initialized_) if (! extent_initialized_)
{
throw datasource_exception("GEOS Plugin: cannot determine extent for <wkt> geometry"); throw datasource_exception("GEOS Plugin: cannot determine extent for <wkt> geometry");
}
is_bound_ = true; is_bound_ = true;
} }
@ -265,7 +262,7 @@ featureset_ptr geos_datasource::features(query const& q) const
<< "))"; << "))";
#ifdef MAPNIK_DEBUG #ifdef MAPNIK_DEBUG
clog << "GEOS Plugin: using extent: " << s.str() << endl; std::clog << "GEOS Plugin: using extent: " << s.str() << std::endl;
#endif #endif
return boost::make_shared<geos_featureset>(*geometry_, return boost::make_shared<geos_featureset>(*geometry_,
@ -285,7 +282,7 @@ featureset_ptr geos_datasource::features_at_point(coord2d const& pt) const
s << "POINT(" << pt.x << " " << pt.y << ")"; s << "POINT(" << pt.x << " " << pt.y << ")";
#ifdef MAPNIK_DEBUG #ifdef MAPNIK_DEBUG
clog << "GEOS Plugin: using point: " << s.str() << endl; std::clog << "GEOS Plugin: using point: " << s.str() << std::endl;
#endif #endif
return boost::make_shared<geos_featureset>(*geometry_, return boost::make_shared<geos_featureset>(*geometry_,
@ -296,4 +293,3 @@ featureset_ptr geos_datasource::features_at_point(coord2d const& pt) const
desc_.get_encoding(), desc_.get_encoding(),
multiple_geometries_); multiple_geometries_);
} }

View file

@ -2,7 +2,7 @@
* *
* This file is part of Mapnik (c++ mapping toolkit) * This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2010 Artem Pavlenko * Copyright (C) 2011 Artem Pavlenko
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*****************************************************************************/ *****************************************************************************/
//$Id$
#ifndef GEOS_DATASOURCE_HPP #ifndef GEOS_DATASOURCE_HPP
#define GEOS_DATASOURCE_HPP #define GEOS_DATASOURCE_HPP
@ -46,6 +45,7 @@ class geos_datasource : public mapnik::datasource
mapnik::box2d<double> envelope() const; mapnik::box2d<double> envelope() const;
mapnik::layer_descriptor get_descriptor() const; mapnik::layer_descriptor get_descriptor() const;
void bind() const; void bind() const;
private: private:
mutable mapnik::box2d<double> extent_; mutable mapnik::box2d<double> extent_;
mutable bool extent_initialized_; mutable bool extent_initialized_;
@ -59,5 +59,4 @@ class geos_datasource : public mapnik::datasource
bool multiple_geometries_; bool multiple_geometries_;
}; };
#endif // GEOS_DATASOURCE_HPP #endif // GEOS_DATASOURCE_HPP

View file

@ -2,7 +2,7 @@
* *
* This file is part of Mapnik (c++ mapping toolkit) * This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2010 Artem Pavlenko * Copyright (C) 2011 Artem Pavlenko
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public

View file

@ -2,7 +2,7 @@
* *
* This file is part of Mapnik (c++ mapping toolkit) * This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2010 Artem Pavlenko * Copyright (C) 2011 Artem Pavlenko
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -19,8 +19,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*****************************************************************************/ *****************************************************************************/
//$Id$
// stl
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
@ -35,12 +35,8 @@
#include <mapnik/unicode.hpp> #include <mapnik/unicode.hpp>
#include <mapnik/feature_factory.hpp> #include <mapnik/feature_factory.hpp>
// ogr
#include "geos_featureset.hpp" #include "geos_featureset.hpp"
using std::clog;
using std::endl;
using mapnik::query; using mapnik::query;
using mapnik::box2d; using mapnik::box2d;
using mapnik::coord2d; using mapnik::coord2d;
@ -97,6 +93,7 @@ feature_ptr geos_featureset::next()
render_geometry = true; render_geometry = true;
} }
break; break;
case GEOS_POLYGON: case GEOS_POLYGON:
if (GEOSContains(*extent_, geometry_) if (GEOSContains(*extent_, geometry_)
|| GEOSWithin(geometry_, *extent_) || GEOSWithin(geometry_, *extent_)
@ -105,9 +102,10 @@ feature_ptr geos_featureset::next()
render_geometry = true; render_geometry = true;
} }
break; break;
default: default:
#ifdef MAPNIK_DEBUG #ifdef MAPNIK_DEBUG
clog << "GEOS Plugin: unknown extent geometry_type=" << type << endl; std::clog << "GEOS Plugin: unknown extent geometry_type=" << type << std::endl;
#endif #endif
break; break;
} }
@ -138,4 +136,3 @@ feature_ptr geos_featureset::next()
return feature_ptr(); return feature_ptr();
} }

View file

@ -2,7 +2,7 @@
* *
* This file is part of Mapnik (c++ mapping toolkit) * This file is part of Mapnik (c++ mapping toolkit)
* *
* Copyright (C) 2010 Artem Pavlenko * Copyright (C) 2011 Artem Pavlenko
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -19,7 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* *
*****************************************************************************/ *****************************************************************************/
//$Id$
#ifndef GEOS_FEATURESET_HPP #ifndef GEOS_FEATURESET_HPP
#define GEOS_FEATURESET_HPP #define GEOS_FEATURESET_HPP