update pgsql2sqlite to new geometry
This commit is contained in:
parent
9732369750
commit
95ca3a02f8
2 changed files with 89 additions and 6 deletions
84
include/mapnik/geometry_empty.hpp
Normal file
84
include/mapnik/geometry_empty.hpp
Normal file
|
@ -0,0 +1,84 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2015 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
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef MAPNIK_GEOMETRY_EMPTY_HPP
|
||||
#define MAPNIK_GEOMETRY_EMPTY_HPP
|
||||
|
||||
#include <mapnik/geometry_impl.hpp>
|
||||
|
||||
namespace mapnik { namespace new_geometry {
|
||||
|
||||
namespace detail {
|
||||
|
||||
struct geometry_empty
|
||||
{
|
||||
bool operator() (mapnik::new_geometry::geometry const& geom) const
|
||||
{
|
||||
return mapnik::util::apply_visitor(*this, geom);
|
||||
}
|
||||
|
||||
bool operator() (mapnik::new_geometry::point const&) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator() (mapnik::new_geometry::line_string const& geom) const
|
||||
{
|
||||
return geom.empty();
|
||||
}
|
||||
|
||||
bool operator() (mapnik::new_geometry::polygon const& geom) const
|
||||
{
|
||||
return geom.empty();
|
||||
}
|
||||
|
||||
bool operator() (mapnik::new_geometry::multi_point const& geom) const
|
||||
{
|
||||
return geom.empty();
|
||||
}
|
||||
|
||||
bool operator() (mapnik::new_geometry::multi_line_string const& geom) const
|
||||
{
|
||||
return geom.empty();
|
||||
}
|
||||
|
||||
bool operator() (mapnik::new_geometry::multi_polygon const& geom) const
|
||||
{
|
||||
return geom.empty();
|
||||
}
|
||||
|
||||
bool operator() (mapnik::new_geometry::geometry_collection const& geom) const
|
||||
{
|
||||
return geom.empty();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
inline bool empty(mapnik::new_geometry::geometry const& geom)
|
||||
{
|
||||
return detail::geometry_empty()(geom);
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
#endif // MAPNIK_GEOMETRY_EMPTY_HPP
|
|
@ -29,6 +29,8 @@
|
|||
#include <mapnik/global.hpp>
|
||||
#include <mapnik/sql_utils.hpp>
|
||||
#include <mapnik/util/conversions.hpp>
|
||||
#include <mapnik/geometry_empty.hpp>
|
||||
#include <mapnik/geometry_envelope.hpp>
|
||||
|
||||
#include "connection_manager.hpp"
|
||||
#include "cursorresultset.hpp"
|
||||
|
@ -387,21 +389,18 @@ void pgsql2sqlite(Connection conn,
|
|||
if (oid == geometry_oid)
|
||||
{
|
||||
mapnik::Feature feat(ctx,pkid);
|
||||
if (geometry_utils::from_wkb(feat.paths(),buf,size,wkbGeneric)
|
||||
&& feat.num_geometries() > 0)
|
||||
mapnik::new_geometry::geometry geom = geometry_utils::from_wkb(buf, size, wkbGeneric);
|
||||
if (!mapnik::new_geometry::empty(geom))
|
||||
{
|
||||
geometry_type const& geom=feat.get_geometry(0);
|
||||
box2d<double> bbox = ::mapnik::envelope(geom);
|
||||
box2d<double> bbox = mapnik::new_geometry::envelope(geom);
|
||||
if (bbox.valid())
|
||||
{
|
||||
sqlite::record_type rec;
|
||||
|
||||
rec.push_back(sqlite::value_type(pkid));
|
||||
rec.push_back(sqlite::value_type(bbox.minx()));
|
||||
rec.push_back(sqlite::value_type(bbox.maxx()));
|
||||
rec.push_back(sqlite::value_type(bbox.miny()));
|
||||
rec.push_back(sqlite::value_type(bbox.maxy()));
|
||||
|
||||
spatial_index.insert_record(rec);
|
||||
empty_geom = false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue