Merge branch 'master' into conv_simplify
This commit is contained in:
commit
f5b4ff9429
4 changed files with 80 additions and 46 deletions
|
@ -6,6 +6,11 @@ Developers: Please commit along with changes.
|
|||
|
||||
For a complete change history, see the git log.
|
||||
|
||||
## Future
|
||||
|
||||
- Fixed zoom_all behavior when Map maximum-extent is provided. Previously maximum-extent was used outright but
|
||||
now the combined layer extents will be again respected: they will be clipped to the maximum-extent if possible
|
||||
and only when back-projecting fails for all layers will the maximum-extent be used as a fallback (#1473)
|
||||
|
||||
## Mapnik 2.1.0
|
||||
|
||||
|
|
23
demo/simple-renderer/render.py
Executable file
23
demo/simple-renderer/render.py
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import mapnik
|
||||
|
||||
def render(input_file, output_file, width=800, height=800, bbox=None):
|
||||
m = mapnik.Map(width, height)
|
||||
mapnik.load_map(m, input_file, False)
|
||||
if bbox is not None:
|
||||
m.zoom_to_box(bbox)
|
||||
else:
|
||||
m.zoom_all()
|
||||
mapnik.render_to_file(m, output_file)
|
||||
|
||||
if len(sys.argv) == 2:
|
||||
render(sys.argv[1], "output.png")
|
||||
elif len(sys.argv) == 3:
|
||||
render(sys.argv[1], sys.argv[2])
|
||||
elif len(sys.argv) == 5:
|
||||
render(sys.argv[1], sys.argv[2], int(sys.argv[3]), int(sys.argv[4]))
|
||||
else:
|
||||
print "usage: %s style_file [output_file] [width height]" % sys.argv[0]
|
||||
sys.exit(1)
|
96
src/map.cpp
96
src/map.cpp
|
@ -340,54 +340,59 @@ void Map::zoom(double factor)
|
|||
|
||||
void Map::zoom_all()
|
||||
{
|
||||
if (maximum_extent_) {
|
||||
zoom_to_box(*maximum_extent_);
|
||||
}
|
||||
else
|
||||
try
|
||||
{
|
||||
try
|
||||
if (!layers_.size() > 0)
|
||||
return;
|
||||
projection proj0(srs_);
|
||||
box2d<double> ext;
|
||||
bool success = false;
|
||||
bool first = true;
|
||||
std::vector<layer>::const_iterator itr = layers_.begin();
|
||||
std::vector<layer>::const_iterator end = layers_.end();
|
||||
while (itr != end)
|
||||
{
|
||||
if (!layers_.size() > 0)
|
||||
return;
|
||||
projection proj0(srs_);
|
||||
box2d<double> ext;
|
||||
bool success = false;
|
||||
bool first = true;
|
||||
std::vector<layer>::const_iterator itr = layers_.begin();
|
||||
std::vector<layer>::const_iterator end = layers_.end();
|
||||
while (itr != end)
|
||||
if (itr->active())
|
||||
{
|
||||
if (itr->active())
|
||||
std::string const& layer_srs = itr->srs();
|
||||
projection proj1(layer_srs);
|
||||
proj_transform prj_trans(proj0,proj1);
|
||||
box2d<double> layer_ext = itr->envelope();
|
||||
if (prj_trans.backward(layer_ext, PROJ_ENVELOPE_POINTS))
|
||||
{
|
||||
std::string const& layer_srs = itr->srs();
|
||||
projection proj1(layer_srs);
|
||||
|
||||
proj_transform prj_trans(proj0,proj1);
|
||||
|
||||
box2d<double> layer_ext = itr->envelope();
|
||||
if (prj_trans.backward(layer_ext, PROJ_ENVELOPE_POINTS))
|
||||
success = true;
|
||||
MAPNIK_LOG_DEBUG(map) << "map: Layer " << itr->name() << " original ext=" << itr->envelope();
|
||||
MAPNIK_LOG_DEBUG(map) << "map: Layer " << itr->name() << " transformed to map srs=" << layer_ext;
|
||||
if (first)
|
||||
{
|
||||
success = true;
|
||||
|
||||
MAPNIK_LOG_DEBUG(map) << "map: Layer " << itr->name() << " original ext=" << itr->envelope();
|
||||
MAPNIK_LOG_DEBUG(map) << "map: Layer " << itr->name() << " transformed to map srs=" << layer_ext;
|
||||
|
||||
if (first)
|
||||
{
|
||||
ext = layer_ext;
|
||||
first = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ext.expand_to_include(layer_ext);
|
||||
}
|
||||
ext = layer_ext;
|
||||
first = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ext.expand_to_include(layer_ext);
|
||||
}
|
||||
}
|
||||
++itr;
|
||||
}
|
||||
if (success) {
|
||||
zoom_to_box(ext);
|
||||
} else {
|
||||
++itr;
|
||||
}
|
||||
if (success)
|
||||
{
|
||||
if (maximum_extent_) {
|
||||
ext.clip(*maximum_extent_);
|
||||
}
|
||||
zoom_to_box(ext);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (maximum_extent_)
|
||||
{
|
||||
MAPNIK_LOG_ERROR(map) << "could not zoom to combined layer extents"
|
||||
<< " so falling back to maximum-extent for zoom_all result";
|
||||
zoom_to_box(*maximum_extent_);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ostringstream s;
|
||||
s << "could not zoom to combined layer extents "
|
||||
<< "using zoom_all because proj4 could not "
|
||||
|
@ -396,10 +401,10 @@ void Map::zoom_all()
|
|||
throw std::runtime_error(s.str());
|
||||
}
|
||||
}
|
||||
catch (proj_init_error & ex)
|
||||
{
|
||||
throw mapnik::config_error(std::string("Projection error during map.zoom_all: ") + ex.what());
|
||||
}
|
||||
}
|
||||
catch (proj_init_error & ex)
|
||||
{
|
||||
throw mapnik::config_error(std::string("Projection error during map.zoom_all: ") + ex.what());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -544,7 +549,8 @@ featureset_ptr Map::query_point(unsigned index, double x, double y) const
|
|||
if (fs)
|
||||
{
|
||||
mapnik::box2d<double> map_ex = current_extent_;
|
||||
if (maximum_extent_) {
|
||||
if (maximum_extent_)
|
||||
{
|
||||
map_ex.clip(*maximum_extent_);
|
||||
}
|
||||
if (!prj_trans.backward(map_ex,PROJ_ENVELOPE_POINTS))
|
||||
|
|
|
@ -84,7 +84,7 @@ if __name__ == "__main__":
|
|||
for name in sys.argv[1:]:
|
||||
files.append({"name": name})
|
||||
|
||||
if 'osm' in mapnik.DatasourceCache.instance().plugin_names():
|
||||
if 'osm' in mapnik.DatasourceCache.plugin_names():
|
||||
for f in files:
|
||||
config = dict(defaults)
|
||||
config.update(f)
|
||||
|
|
Loading…
Add table
Reference in a new issue