Merge branch 'master' of github.com:mapnik/mapnik into optional-extent

This commit is contained in:
Dane Springmeyer 2013-07-24 13:26:43 -04:00
commit 0219a54726
1498 changed files with 40399 additions and 30410 deletions

View file

@ -5,10 +5,10 @@ compiler: clang
before_install:
- echo 'yes' | sudo add-apt-repository ppa:mapnik/boost
- sudo apt-get update -qq
- sudo apt-get install -qq libboost-dev libboost-filesystem-dev libboost-program-options-dev libboost-python-dev libboost-regex-dev libboost-system-dev libboost-thread-dev python-nose libicu-dev libpng-dev libjpeg-dev libtiff-dev libz-dev libfreetype6-dev libxml2-dev libproj-dev
- sudo apt-get install -qq libboost-dev libboost-filesystem-dev libboost-program-options-dev libboost-python-dev libboost-regex-dev libboost-system-dev libboost-thread-dev python-nose libicu-dev libpng-dev libjpeg-dev libtiff-dev libwebp-dev libz-dev libfreetype6-dev libxml2-dev libproj-dev
script:
- ./configure DEMO=False BINDINGS='python' CPP_TESTS=False CAIRO=False INPUT_PLUGINS='' OPTIMIZATION=1 JOBS=2 FAST=True && make
- ./configure DEMO=False BINDINGS='python' CPP_TESTS=False CAIRO=False INPUT_PLUGINS='' OPTIMIZATION=1 FAST=True && JOBS=2 make
branches:
only:

View file

@ -8,9 +8,84 @@ For a complete change history, see the git log.
## Future
- Changed scale_denominator C++ interface to take scale as first argument rather than map.
- Added to python bindings: `has_tiff`, `has_png`, `has_webp`, `has_proj4`, `has_svg_renderer`, and `has_grid_renderer`
- Added support for `background-image` in cairo_renderer (#1724)
- Made it possible to disable compilation of `grid_renderer` with `./configure GRID_RENDERER=False` (#1962)
- Added `webp` image encoding and decoding support (#1955)
- Added `premultiplied` property on mapnik::image_32 / mapnik.Image to enable knowledge of premultiplied status of image buffer.
- Added `scale-hsla` image-filter that allows scaling colors in HSL color space. RGB is converted to HSL (hue-saturation-lightness) and then each value (and the original alpha value) is stretched based on the specified scaling values. An example syntax is `scale-hsla(0,1,0,1,0,1,0,1)` which means no change because the full range will be kept (0 for lowest, 1 for highest). Other examples are: 1) `scale-hsla(0,0,0,1,0,1,0,1)` which would force all colors to be red in hue in the same way `scale-hsla(1,1,0,1,0,1,0,1)` would, 2) `scale-hsla(0,1,1,1,0,1,0,1)` which would cause all colors to become fully saturated, 3) `scale-hsla(0,1,1,1,0,1,.5,1)` which would force no colors to be any more transparent than half, and 4) `scale-hsla(0,1,1,1,0,1,0,.5)` which would force all colors to be at least half transparent. (#1954)
## 2.2.0
Released June 3rd, 2013
(Packaged from 9231205)
Summary: The 2.2.0 release is primarily a performance and stability release. The code line represents development in the master branch since the release of 2.1.0 in Aug 2012 and therefore includes nearly a year of bug-fixes and optimizations. Nearly 500 new tests have been added bring the total coverage to 925. Shapefile and PostGIS datasources have benefited from numerous stability fixes, 64 bit integer support has been added to support OSM data in the grid renderer and in attribute filtering, and many fixes have landed for higher quality output when using a custom `scale_factor` during rendering. Critical code paths have been optimized include raster rendering, xml map loading, string to number conversion, vector reprojection when using `epsg:4326` and `epsg:3857`, `hextree` encoding, halo rendering, and rendering when using a custom `gamma`. Mapnik 2.2 also compiles faster than previous releases in the 2.x series and drops several unneeded and hard to install dependencies making builds on OS X and Windows easier than any previous release.
- Removed 3 depedencies without loosing any functionality: `ltdl`, `cairomm` and `libsigc++` (#1804,#806,#1681)
- Added 64 bit integer support in expressions, feature ids, and the grid_renderer (#1661,#1662,#1662)
- Added the ability to disable the need for various dependencies: `proj4`, `libpng`, `libtiff`, `libjpeg`
- Added faster reprojection support between `epsg:3857` and `epsg:4326` (#1705,#1703,#1579)
- Fixed concurrency problem when using cursors in postgis plugin (#1823,#1588)
- Fixed postgres connection pool leaks when using `persist_connection=false` (#1764)
- Fixed postgres connection key to respect highest value of `max_size` and `initial_size` for any layer in map (#1599)
- Fixed potential crash in wkb parsing when postgis returns null geometry (#1843)
- Fixed blurry rendering of image and SVG icons (#1316)
- Added detection of invalid srs values when loading xml (#646)
- Added support for specifying a base_path as a third, optional argument to load_xml
- Removed muffling of projection errors while rendering (#646)
- Improved logging system (https://github.com/mapnik/mapnik/wiki/Logging)
- Added support for reading images from in memory streams (#1805)
- Optimized halo rendering. When halo radius is < 1 new method will be used automatically (#1781)
- Added `text-halo-rasterizer` property. Set to `fast` for lower quality but faster
halo rendering (#1298) which matched new default method when radius is < 1.
- Added support in `shape`, `sqlite`, `geojson`, and `csv` plugin for handling non-latin characters in the paths to file-based resources (#1177)
- Fixed rendering of markers when their size is greater than the specified `spacing` value (#1487)
- Fixed handling of alpha premultiplication in image scaling (#1489)
- Optimized rendering when a style with no symbolizers is encountered (#1517)
- Optimized string handling and type conversion by removing `boost::to_lower`, `boost::trim`, and `boost::lexical_cast` usage (#1687,#1687,#1633)
- Optimized alpha preserving `hextree` method for quantization of png images (#1629)
- Faster rendering of rasters by reducing memory allocation of temporary buffers (#1516)
- Fixed some raster reprojection artifacts (#1501)
- Fixed raster alignment when width != height and raster is being scaled (#1748,#1622)
- Added support for caching rasters for re-use during rendering when styling more than once per layer (#1543)
- Improved compile speeds of the code - in some cases by up to 2x and removed need for freetype dependency when building code against mapnik (#1688, #1756)
- Removed internal rule cache on `mapnik::Map` c++ object (#1723)
- Improved the scaled rendering of various map features when using `scale_factor` > 1 (#1280,#1100,#1273,#1792,#1291,#1344,#1279,#1624,#1767,#1766)
- Added C++ api for overriding scale_denominator to enable rendering at fixed scale (#1582)
- Added Layer `buffer-size` that can be used to override Map `buffer-size` to avoid
over-fetching of data that does not need to be buffered as much as other layers.
@ -18,13 +93,49 @@ For a complete change history, see the git log.
previously undocumented parameter by the same name that impacted clipping extent and
was not needed (clipping padding should likely be a symbolizer level option) (#1566)
- Fixed building symbolizer rendering to be fully sensitive to alpha (8b66128c892 / bc8ea1c5a7a)
- Fixed potential file descriptor leaks in image readers when invalid images were encountered (#1783)
- Added 64 bit integer support in the grid_renderer (#1662)
- Fixed alpha handling in the `blur` and `invert` image filters (#1541)
- Fixed error reporting in the python plugin (#1422)
- Added the ability to run tests without installing with `make test-local`
- Reduced library binary size by adding support for `-fvisibility-inlines-hidden` and `-fvisibility=hidden` (#1826,#1832)
- Added `mapnik::map_request` class, a special object to allow passing mutable map objects to renderer (#1737)
- Added the ability to use `boost::hash` on `mapnik::value` types (#1729)
- Removed obsolete `geos` plugin (functionality replaced by `csv` plugin) and unmaintained `kismet` plugin (#1809,#1833)
- Added new `mapnik-config` flags: `--all-flags`, `--defines`, `--git-describe`, `--includes`, `--dep-includes`, `--cxxflags`, `--cxx` (#1443)
- Added support for unicode strings as arguments in python bindings (#163)
- Added DebugSymbolizer which is able to render the otherwise invisible collision boxes (#1366)
- Optimized rendering by reducing overhead of using `gamma` property (#1174)
- Fixed rendering artifacts when using `polygon-gamma` or `line-gamma` equal to 0 (#761,#1763)
- Fixed and optimized the display of excessive precision of some float data in labels (#430,#1697)
- Removed the `bind` option for datasources (#1654)
- Added ability to access style list from map by (name,obj) in python (#1725)
- Added `is_solid` method to python mapnik.Image and mapnik.ImageView classes (#1728)
- Changed scale_denominator C++ interface to take scale as first argument rather than map.
- Added support for `background-image` in cairo_renderer (#1724)
- Fixed building symbolizer rendering to be fully sensitive to alpha (8b66128c892 / bc8ea1c5a7a)
- `<Filter>[attr]</Filter>` now returns false if attr is an empty string (#1665)
- Added 64 bit integer support in expressions and feature ids (#1661,#1662)
- `<Filter>[attr]!=null</Filter>` now returns true if attr is not null (#1642)
- Added support for DBF `Logical` type: #1614
@ -41,9 +152,7 @@ For a complete change history, see the git log.
- Added support for setting zlib `Z_FIXED` strategy with format string: `png:z=fixed`
- Fixed handling of transparency level option in Octree-based PNG encoding (#1556)
- Faster rendering of rasters by reducing memory allocation of temporary buffers (#1516)
- Fixed handling of transparency level option in `octree` png encoding (#1556)
- Added ability to pass a pre-created collision detector to the cairo renderer (#1444)
@ -59,6 +168,24 @@ For a complete change history, see the git log.
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)
- Compile time flag called `PLUGIN_LINKING` to allow input datasource plugins to be statically linked with the mapnik library (#249)
- Fixed `dasharray` rendering in cairo backend (#1740)
- Fixed handling of `opacity` in svg rendering (#1744)
- Fixed uneven rendering of markers along lines (#1693)
- Fixed handling of extra bytes in some shapefile fields (#1605)
- Fixed handling (finally) of null shapes and partially corrupt shapefiles (#1630,#1621)
- Added ability to re-use `mapnik::image_32` and `mapnik::grid` by exposing a `clear` method (#1571)
- Added support for writing RGB (no A) png images by using the format string of `png:t=0` (#1559)
- Added experimental support for geometry simplification at symbolizer level (#1385)
## Mapnik 2.1.0
Released Aug 23, 2012
@ -119,7 +246,7 @@ Released Aug 23, 2012
- Improved logging/debugging system with release logs and file redirection (https://github.com/mapnik/mapnik/wiki/Runtime-Logging) (#937 and partially #986, #467)
- GDAL: allow setting nodata value on the fly (will override value if nodata is set in data) (#1161)
- GDAL: respect nodata for paletted/colormapped images (#1160)
- PostGIS: Added a new option called `autodetect_key_field` (by default false) that if true will
@ -175,7 +302,7 @@ Released Aug 3, 2012
- Fixed possible breakage registering plugins via python if a custom PREFIX or DESTDIR was used (e.g. macports/homebrew) (#1171)
- Fixed memory leak in the case of proj >= 4.8 and a projection initialization error (#1173)
- Fixed memory leak in the case of proj >= 4.8 and a projection initialization error (#1173)
## Mapnik 2.0.1
@ -206,7 +333,7 @@ Released April 10, 2012
- Workaround for boost interprocess compile error with recent gcc versions (#950,#1001,#1082)
- Fix possible memory corruption when using hextree mode for png color reduction (#1087)
- Fix possible memory corruption when using `hextree` mode for png color reduction (#1087)
- Fixed bug in shield line placement when dx/dy are used to shift the label relative to the placement point (Matt Amos) (#908)
@ -386,14 +513,14 @@ Released March 23, 2010
- PNG: fixed png256 for large images and some improvements to reduce color corruptions ([#522](https://github.com/mapnik/mapnik/issues/522))
- PNG: Added new quantization method for indexed png format using hextree with full support for alpha
- PNG: Added new quantization method for indexed png format using `hextree` with full support for alpha
channel. Also new method has some optimizations for color gradients common when using elevation based
rasters. By default old method using octree is used. (r1680, r1683, [#477](https://github.com/mapnik/mapnik/issues/477))
rasters. By default old method using `octree` is used. (r1680, r1683, [#477](https://github.com/mapnik/mapnik/issues/477))
- PNG: Added initial support for passing options to png writter like number of colors, transparency
support, quantization method and possibly other in future using type parameter. For example
"png8:c=128:t=1:m=h" limits palette to 128 colors, uses only binary transparency (0 - none,
1 - binary, 2 - full), and new method of quantization using hextree (h - hextree, o - octree).
1 - binary, 2 - full), and new method of quantization using `hextree` (h - `hextree`, o - `octree`).
Existing type "png256" can be also written using "png8:c=256:m=o:t=2" (r1680, r1683, [#477](https://github.com/mapnik/mapnik/issues/477))

36
COPYING
View file

@ -1,8 +1,8 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@ -10,7 +10,7 @@
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
@ -55,7 +55,7 @@ modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
@ -111,8 +111,8 @@ modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
@ -146,7 +146,7 @@ such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
@ -158,7 +158,7 @@ Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
@ -216,7 +216,7 @@ instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
@ -267,7 +267,7 @@ Library will still fall under Section 6.)
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
@ -329,7 +329,7 @@ restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
@ -370,7 +370,7 @@ subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
@ -422,7 +422,7 @@ conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
@ -432,7 +432,7 @@ decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
@ -455,8 +455,8 @@ FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
@ -485,7 +485,7 @@ convey the exclusion of warranty; and each file should have at least the
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.

View file

@ -7,7 +7,7 @@ To configure and build Mapnik do:
./configure
make
NOTE: the above will not work on windows, rather see https://github.com/mapnik/mapnik/wiki/BuildingOnWindows
NOTE: the above will not work on windows, rather see https://github.com/mapnik/mapnik/wiki/WindowsInstallation
Then to run the tests locally (without needing to install):
@ -48,27 +48,33 @@ Mapnik Core depends on:
- regex (optionally built with icu regex support)
- program_options (optionally for mapnik command line programs)
* libicuuc >= 4.0 (ideally >= 4.2) - International Components for Unicode
* libpng >= 1.2.x - PNG graphics
* libjpeg - JPEG graphics
* libtiff - TIFF graphics
* libz - Zlib compression
* libfreetype - Freetype2 for font support (Install requires freetype-config)
* libxml2 - XML parsing (Install requires xml2-config)
* libproj - PROJ.4 projection library
Mapnik Core optionally depends on:
* libpng >= 1.2.x - PNG graphics (Default enabled, if found)
* libjpeg - JPEG graphics (Default enabled, if found)
* libtiff - TIFF graphics (Default enabled, if found)
* libwebp - WEBP graphics (Default enabled, if found)
* libproj - PROJ.4 projection library (Default enabled, if found)
Mapnik Python bindings depend on:
* Python 2.5-2.7 or >= 3.2
* Boost python
Note: Python3k is supported, see: https://github.com/mapnik/mapnik/wiki/Python3k
Note: Python 3.x is supported, see: https://github.com/mapnik/mapnik/wiki/Python3k
Optional dependencies:
Additional optional dependencies:
* Cairo - Graphics library for output formats like PDF, PS, and SVG
* Cairo >= 1.6.0 - Graphics library for output formats like PDF, PS, and SVG
- pkg-config - Required for building with cairo support
- pycairo - Python bindings for cairo
* libpq - PostgreSQL libraries (For PostGIS plugin support)
* PostgreSQL (for PostGIS plugin support)
- libpq - PostreSQL libraries
- pg_config - PostgreSQL installation capabilities
* libgdal - GDAL/OGR input (For gdal and ogr plugin support)
* libsqlite3 - SQLite input (needs RTree support builtin) (sqlite plugin support)
* libocci - Oracle input plugin support

View file

@ -5,16 +5,28 @@ ifeq ($(UNAME), Darwin)
else
endif
OS:=$(shell uname -s)
ifeq ($(JOBS),)
JOBS:=1
ifeq ($(OS),Linux)
JOBS:=$(shell grep -c ^processor /proc/cpuinfo)
endif
ifeq ($(OS),Darwin)
JOBS:=$(shell sysctl -n hw.ncpu)
endif
endif
all: mapnik
install:
@python scons/scons.py --config=cache --implicit-cache --max-drift=1 install
@python scons/scons.py -j$(JOBS) --config=cache --implicit-cache --max-drift=1 install
mapnik:
@python scons/scons.py --config=cache --implicit-cache --max-drift=1
@python scons/scons.py -j$(JOBS) --config=cache --implicit-cache --max-drift=1
clean:
@python scons/scons.py -c --config=cache --implicit-cache --max-drift=1
@python scons/scons.py -j$(JOBS) -c --config=cache --implicit-cache --max-drift=1
@if test -e ".sconsign.dblite"; then rm ".sconsign.dblite"; fi
@if test -e "config.log"; then rm "config.log"; fi
@if test -e ".sconf_temp/"; then rm -r ".sconf_temp/"; fi
@ -34,7 +46,7 @@ rebuild:
make uninstall && make clean && time make && make install
uninstall:
@python scons/scons.py --config=cache --implicit-cache --max-drift=1 uninstall
@python scons/scons.py -j$(JOBS) --config=cache --implicit-cache --max-drift=1 uninstall
test:
@ ./run_tests
@ -42,6 +54,7 @@ test:
test-local:
@echo "*** Boostrapping local test environment..."
@export ${LINK_FIX}=`pwd`/src:${${LINK_FIX}} && \
export PATH=`pwd`/utils/mapnik-config/:${PATH} && \
export PYTHONPATH=`pwd`/bindings/python/:${PYTHONPATH} && \
export MAPNIK_FONT_DIRECTORY=`pwd`/fonts/dejavu-fonts-ttf-2.33/ttf/ && \
export MAPNIK_INPUT_PLUGINS_DIRECTORY=`pwd`/plugins/input/ && \
@ -55,7 +68,7 @@ check: test-local
demo:
@echo "*** Running rundemo.cpp…"
cd demo/c++; ./rundemo `mapnik-config --prefix`/lib/mapnik
cd demo/c++; ./rundemo `mapnik-config --prefix`
pep8:
# https://gist.github.com/1903033

View file

@ -27,4 +27,4 @@ See [INSTALL.md](https://github.com/mapnik/mapnik/blob/master/INSTALL.md) for in
# License
Mapnik software is free and is released under LGPL ([GNU Lesser General Public License](http://www.gnu.org/licenses/lgpl.html_). Please see [COPYING](https://github.com/mapnik/mapnik/blob/master/COPYING) for more information.
Mapnik software is free and is released under LGPL ([GNU Lesser General Public License](http://www.gnu.org/licenses/lgpl.html_)). Please see [COPYING](https://github.com/mapnik/mapnik/blob/master/COPYING) for more information.

File diff suppressed because it is too large Load diff

View file

@ -10,12 +10,16 @@ test_env['LIBS'] = copy(env['LIBMAPNIK_LIBS'])
test_env.AppendUnique(LIBS='mapnik')
#test_env.AppendUnique(LIBS='sqlite3')
test_env.AppendUnique(CXXFLAGS='-g')
linkflags = copy(env['CUSTOM_LDFLAGS'])
linkflags
if env['PLATFORM'] == 'Darwin':
linkflags += ' -F/ -framework CoreFoundation'
for cpp_test in glob.glob('run*.cpp'):
name = cpp_test.replace('.cpp','')
source_files = [cpp_test]
test_env_local = test_env.Clone()
test_program = test_env_local.Program(name, source=source_files, LINKFLAGS=env['CUSTOM_LDFLAGS'])
test_program = test_env_local.Program(name, source=source_files, LINKFLAGS=linkflags)
Depends(test_program, env.subst('../src/%s' % env['MAPNIK_LIB_NAME']))
# build locally if installing
if 'install' in COMMAND_LINE_TARGETS:

View file

@ -0,0 +1 @@
MULTIPOLYGON (((30 20, 10 40, 45 40, 30 20)),((15 5, 40 10, 10 20, 5 10, 15 5)))

View file

@ -12,6 +12,8 @@
#include <sstream>
#include <cstdio>
#include <set>
#include <stdexcept>
// boost
#include <boost/version.hpp>
@ -35,44 +37,56 @@ typedef process_cpu_clock clock_type;
typedef clock_type::duration dur;
template <typename T>
void benchmark(T test, std::string const& name)
void benchmark(T & test_runner, std::string const& name)
{
try {
bool should_run_test = true;
if (!test_set.empty()) {
if (!test_set.empty())
{
should_run_test = test_set.find(test_num) != test_set.end();
}
if (should_run_test || dry_run) {
if (!test.validate()) {
if (should_run_test || dry_run)
{
if (!test_runner.validate())
{
std::clog << "test did not validate: " << name << "\n";
//throw std::runtime_error(std::string("test did not validate: ") + name);
}
if (dry_run) {
std::clog << test_num << ") " << (test.threads_ ? "threaded -> ": "")
if (dry_run)
{
std::clog << test_num << ") " << (test_runner.threads_ ? "threaded -> ": "")
<< name << "\n";
} else {
}
else
{
process_cpu_clock::time_point start;
dur elapsed;
if (test.threads_ > 0) {
if (test_runner.threads_ > 0)
{
boost::thread_group tg;
for (unsigned i=0;i<test.threads_;++i)
for (unsigned i=0;i<test_runner.threads_;++i)
{
tg.create_thread(test);
tg.create_thread(test_runner);
//tg.create_thread(boost::bind(&T::operator(),&test_runner));
}
start = process_cpu_clock::now();
tg.join_all();
elapsed = process_cpu_clock::now() - start;
} else {
}
else
{
start = process_cpu_clock::now();
test();
test_runner();
elapsed = process_cpu_clock::now() - start;
}
std::clog << test_num << ") " << (test.threads_ ? "threaded -> ": "")
std::clog << test_num << ") " << (test_runner.threads_ ? "threaded -> ": "")
<< name << ": "
<< boost::chrono::duration_cast<milliseconds>(elapsed) << "\n";
}
}
} catch (std::exception const& ex) {
}
catch (std::exception const& ex)
{
std::clog << "test runner did not complete: " << ex.what() << "\n";
}
test_num++;
@ -252,7 +266,7 @@ struct test5
s.resize(s.capacity());
while (true)
{
size_t n2 = static_cast<size_t>(snprintf(&s[0], s.size()+1, "%g", val_));
size_t n2 = static_cast<size_t>(snprintf(&s[0], s.size()+1, "%g", val));
if (n2 <= s.size())
{
s.resize(n2);
@ -380,13 +394,15 @@ struct test8
bool validate()
{
mapnik::expression_grammar<std::string::const_iterator> expr_grammar(transcoder("utf-8"));
mapnik::expression_ptr expr = mapnik::parse_expression(expr_,expr_grammar);
return mapnik::to_expression_string(*expr) == expr_;
transcoder tr("utf-8");
mapnik::expression_grammar<std::string::const_iterator> expr_grammar(tr);
mapnik::expression_ptr expr = mapnik::parse_expression(expr_,expr_grammar);
return mapnik::to_expression_string(*expr) == expr_;
}
void operator()()
{
mapnik::expression_grammar<std::string::const_iterator> expr_grammar(transcoder("utf-8"));
transcoder tr("utf-8");
mapnik::expression_grammar<std::string::const_iterator> expr_grammar(tr);
for (unsigned i=0;i<iter_;++i) {
mapnik::expression_ptr expr = mapnik::parse_expression(expr_,expr_grammar);
}
@ -591,6 +607,142 @@ struct test10
}
};
#include <mapnik/wkt/wkt_factory.hpp>
#include "agg_conv_clipper.h"
#include "agg_path_storage.h"
#include <mapnik/geometry.hpp>
struct test11
{
unsigned iter_;
unsigned threads_;
std::string wkt_in_;
mapnik::box2d<double> extent_;
typedef agg::conv_clipper<mapnik::geometry_type, agg::path_storage> poly_clipper;
test11(unsigned iterations,
unsigned threads,
std::string wkt_in,
mapnik::box2d<double> const& extent)
: iter_(iterations),
threads_(threads),
wkt_in_(wkt_in),
extent_(extent) {
}
bool validate()
{
return true;
}
void operator()()
{
boost::ptr_vector<geometry_type> paths;
if (!mapnik::from_wkt(wkt_in_, paths))
{
throw std::runtime_error("Failed to parse WKT");
}
agg::path_storage ps;
ps.move_to(extent_.minx(), extent_.miny());
ps.line_to(extent_.minx(), extent_.maxy());
ps.line_to(extent_.maxx(), extent_.maxy());
ps.line_to(extent_.maxx(), extent_.miny());
ps.close_polygon();
for (unsigned i=0;i<iter_;++i) {
BOOST_FOREACH( geometry_type & geom, paths)
{
poly_clipper clipped(geom,ps,
agg::clipper_and,
agg::clipper_non_zero,
agg::clipper_non_zero,
1);
clipped.rewind(0);
unsigned cmd;
double x,y;
while ((cmd = geom.vertex(&x, &y)) != SEG_END) {}
}
}
}
};
#include <mapnik/polygon_clipper.hpp>
struct test12
{
unsigned iter_;
unsigned threads_;
std::string wkt_in_;
mapnik::box2d<double> extent_;
typedef mapnik::polygon_clipper<mapnik::geometry_type> poly_clipper;
test12(unsigned iterations,
unsigned threads,
std::string wkt_in,
mapnik::box2d<double> const& extent)
: iter_(iterations),
threads_(threads),
wkt_in_(wkt_in),
extent_(extent)
{
}
bool validate()
{
return true;
}
void operator()()
{
boost::ptr_vector<geometry_type> paths;
if (!mapnik::from_wkt(wkt_in_, paths))
{
throw std::runtime_error("Failed to parse WKT");
}
for (unsigned i=0;i<iter_;++i)
{
BOOST_FOREACH( geometry_type & geom, paths)
{
poly_clipper clipped(extent_, geom);
unsigned cmd;
double x,y;
while ((cmd = geom.vertex(&x, &y)) != SEG_END) {}
}
}
}
};
#include <mapnik/font_engine_freetype.hpp>
#include <boost/format.hpp>
struct test13
{
unsigned iter_;
unsigned threads_;
test13(unsigned iterations,
unsigned threads)
: iter_(iterations),
threads_(threads)
{}
bool validate()
{
return true;
}
void operator()()
{
mapnik::freetype_engine engine;
unsigned long count = 0;
for (unsigned i=0;i<iter_;++i)
{
BOOST_FOREACH( std::string const& name, mapnik::freetype_engine::face_names())
{
mapnik::face_ptr f = engine.create_face(name);
if (f) ++count;
}
}
}
};
int main( int argc, char** argv)
{
if (argc > 0) {
@ -720,6 +872,42 @@ int main( int argc, char** argv)
benchmark(runner,"rule caching using heap allocation");
}
{
std::string filename_("benchmark/data/polygon.wkt");
std::ifstream in(filename_.c_str(),std::ios_base::in | std::ios_base::binary);
if (!in.is_open())
throw std::runtime_error("could not open: '" + filename_ + "'");
std::string wkt_in( (std::istreambuf_iterator<char>(in) ),
(std::istreambuf_iterator<char>()) );
mapnik::box2d<double> clipping_box(0,0,40,40);
test11 runner(100000,10,wkt_in,clipping_box);
benchmark(runner,"clipping polygon with agg_conv_clipper");
}
{
std::string filename_("benchmark/data/polygon.wkt");
std::ifstream in(filename_.c_str(),std::ios_base::in | std::ios_base::binary);
if (!in.is_open())
throw std::runtime_error("could not open: '" + filename_ + "'");
std::string wkt_in( (std::istreambuf_iterator<char>(in) ),
(std::istreambuf_iterator<char>()) );
mapnik::box2d<double> clipping_box(0,0,40,40);
test12 runner(100000,10,wkt_in,clipping_box);
benchmark(runner,"clipping polygon with mapnik::polygon_clipper");
}
{
bool success = mapnik::freetype_engine::register_fonts("./fonts", true);
if (!success) {
std::clog << "warning, did not register any new fonts!\n";
}
unsigned face_count = mapnik::freetype_engine::face_names().size();
test13 runner(1000,10);
benchmark(runner, (boost::format("font_engihe: created %ld faces in ") % (face_count * 1000 * 10)).str());
}
std::cout << "...benchmark done\n";
return 0;
}

View file

@ -1,7 +1,7 @@
#
# This file is part of Mapnik (c++ mapping toolkit)
#
# Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon
# Copyright (C) 2013 Artem Pavlenko
#
# Mapnik is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@ -43,20 +43,23 @@ prefix = env['PREFIX']
target_path = os.path.normpath(env['PYTHON_INSTALL_LOCATION'] + os.path.sep + 'mapnik')
target_path_deprecated = os.path.normpath(env['PYTHON_INSTALL_LOCATION'] + os.path.sep + 'mapnik2')
libraries = ['mapnik',env['BOOST_PYTHON_LIB']]
py_env = env.Clone()
py_env.Append(CPPPATH = env['PYTHON_INCLUDES'])
py_env.Append(CPPDEFINES = env['LIBMAPNIK_DEFINES'])
py_env['LIBS'] = ['mapnik',env['BOOST_PYTHON_LIB']]
link_all_libs = env['LINKING'] == 'static' or env['RUNTIME_LINK'] == 'static' or (env['PLATFORM'] == 'Darwin' and not env['PYTHON_DYNAMIC_LOOKUP'])
if link_all_libs:
py_env.AppendUnique(LIBS=env['LIBMAPNIK_LIBS'])
if env['RUNTIME_LINK'] == 'static' and env['PLATFORM'] == 'Linux':
py_env.AppendUnique(LIBS='rt')
# TODO - do solaris/fedora need direct linking too?
if env['PLATFORM'] == 'Darwin':
if not env['PYTHON_DYNAMIC_LOOKUP']:
if env['PNG']:
libraries.append('png')
if env['JPEG']:
libraries.append('jpeg')
libraries.append(env['ICU_LIB_NAME'])
libraries.append('boost_regex%s' % env['BOOST_APPEND'])
if env['THREADING'] == 'multi':
libraries.append('boost_thread%s' % env['BOOST_APPEND'])
##### Python linking on OS X is tricky ###
# Confounding problems are:
# 1) likelyhood of multiple python installs of the same major.minor version
@ -96,7 +99,6 @@ if env['PLATFORM'] == 'Darwin':
else:
# should we fall back to -lpython here?
python_link_flag = '-F/ -framework Python'
# if we are not linking to a framework then use the *nix standard approach
else:
# TODO - do we need to pass -L/?
@ -147,9 +149,6 @@ except: pass
# install the shared object beside the module directory
sources = glob.glob('*.cpp')
py_env = env.Clone()
py_env.Append(CPPPATH = env['PYTHON_INCLUDES'])
if 'install' in COMMAND_LINE_TARGETS:
# install the core mapnik python files, including '__init__.py'
init_files = glob.glob('mapnik/*.py')
@ -175,16 +174,16 @@ if 'install' in COMMAND_LINE_TARGETS:
if 'uninstall' not in COMMAND_LINE_TARGETS:
if env['HAS_CAIRO']:
py_env.Append(CPPPATH = env['CAIRO_CPPPATHS'])
py_env.Append(CXXFLAGS = '-DHAVE_CAIRO')
if env['PLATFORM'] == 'Darwin':
py_env.Append(LIBS=env['CAIRO_LINKFLAGS'])
py_env.Append(CPPDEFINES = '-DHAVE_CAIRO')
if link_all_libs:
py_env.Append(LIBS=env['CAIRO_ALL_LIBS'])
if env['HAS_PYCAIRO']:
py_env.ParseConfig('pkg-config --cflags pycairo')
py_env.Append(CXXFLAGS = '-DHAVE_PYCAIRO')
py_env.Append(CPPDEFINES = '-DHAVE_PYCAIRO')
libraries.append('boost_thread%s' % env['BOOST_APPEND'])
_mapnik = py_env.LoadableModule('mapnik/_mapnik', sources, LIBS=libraries, LDMODULEPREFIX='', LDMODULESUFFIX='.so',LINKFLAGS=linkflags)
py_env.AppendUnique(LIBS = 'boost_thread%s' % env['BOOST_APPEND'])
_mapnik = py_env.LoadableModule('mapnik/_mapnik', sources, LDMODULEPREFIX='', LDMODULESUFFIX='.so',LINKFLAGS=linkflags)
Depends(_mapnik, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME']))

View file

@ -340,6 +340,53 @@ def Shapefile(**keywords):
keywords['type'] = 'shape'
return CreateDatasource(keywords)
def CSV(**keywords):
"""Create a CSV Datasource.
Required keyword arguments:
file -- path to csv
Optional keyword arguments:
inline -- inline CSV string (if provided 'file' argument will be ignored and non-needed)
base -- path prefix (default None)
encoding -- file encoding (default 'utf-8')
row_limit -- integer limit of rows to return (default: 0)
strict -- throw an error if an invalid row is encountered
escape -- The escape character to use for parsing data
quote -- The quote character to use for parsing data
separator -- The separator character to use for parsing data
headers -- A comma separated list of header names that can be set to add headers to data that lacks them
filesize_max -- The maximum filesize in MB that will be accepted
>>> from mapnik import CSV
>>> csv = CSV(file='test.csv')
>>> from mapnik import CSV
>>> csv = CSV(inline='''wkt,Name\n"POINT (120.15 48.47)","Winthrop, WA"''')
For more information see https://github.com/mapnik/mapnik/wiki/CSV-Plugin
"""
keywords['type'] = 'csv'
return CreateDatasource(keywords)
def GeoJSON(**keywords):
"""Create a GeoJSON Datasource.
Required keyword arguments:
file -- path to json
Optional keyword arguments:
encoding -- file encoding (default 'utf-8')
base -- path prefix (default None)
>>> from mapnik import GeoJSON
>>> geojson = GeoJSON(file='test.json')
"""
keywords['type'] = 'geojson'
return CreateDatasource(keywords)
def PostGIS(**keywords):
"""Create a PostGIS Datasource.
@ -558,44 +605,6 @@ def Osm(**keywords):
keywords['type'] = 'osm'
return CreateDatasource(keywords)
def Kismet(**keywords):
"""Create a Kismet Datasource.
Required keyword arguments:
host -- kismet hostname
port -- kismet port
Optional keyword arguments:
encoding -- file encoding (default 'utf-8')
extent -- manually specified data extent (comma delimited string, default None)
>>> from mapnik import Kismet, Layer
>>> datasource = Kismet(host='localhost',port=2501,extent='-179,-85,179,85')
>>> lyr = Layer('Kismet Server Layer')
>>> lyr.datasource = datasource
"""
keywords['type'] = 'kismet'
return CreateDatasource(keywords)
def Geos(**keywords):
"""Create a GEOS Vector Datasource.
Required keyword arguments:
wkt -- inline WKT text of the geometry
Optional keyword arguments:
extent -- manually specified data extent (comma delimited string, default None)
>>> from mapnik import Geos, Layer
>>> datasource = Geos(wkt='MULTIPOINT(100 100, 50 50, 0 0)')
>>> lyr = Layer('GEOS Layer from WKT string')
>>> lyr.datasource = datasource
"""
keywords['type'] = 'geos'
return CreateDatasource(keywords)
def Python(**keywords):
"""Create a Python Datasource.

View file

@ -48,14 +48,30 @@ namespace
{
//user-friendly wrapper that uses Python dictionary
using namespace boost::python;
boost::shared_ptr<mapnik::datasource> create_datasource(const dict& d)
boost::shared_ptr<mapnik::datasource> create_datasource(dict const& d)
{
mapnik::parameters params;
boost::python::list keys=d.keys();
for (int i=0; i<len(keys); ++i)
for (int i=0; i < len(keys); ++i)
{
std::string key = extract<std::string>(keys[i]);
object obj = d[key];
if (PyUnicode_Check(obj.ptr()))
{
PyObject* temp = PyUnicode_AsUTF8String(obj.ptr());
if (temp)
{
#if PY_VERSION_HEX >= 0x03000000
char* c_str = PyBytes_AsString(temp);
#else
char* c_str = PyString_AsString(temp);
#endif
params[key] = std::string(c_str);
Py_DecRef(temp);
}
continue;
}
extract<std::string> ex0(obj);
extract<mapnik::value_integer> ex1(obj);
extract<double> ex2(obj);
@ -138,6 +154,9 @@ boost::python::list field_types(boost::shared_ptr<mapnik::datasource> const& ds)
return fld_types;
}}
mapnik::parameters const& (mapnik::datasource::*params_const)() const = &mapnik::datasource::params;
void export_datasource()
{
using namespace boost::python;
@ -164,7 +183,7 @@ void export_datasource()
.def("fields",&fields)
.def("field_types",&field_types)
.def("features_at_point",&datasource::features_at_point, (arg("coord"),arg("tolerance")=0))
.def("params",&datasource::params,return_value_policy<copy_const_reference>(),
.def("params",make_function(params_const,return_value_policy<copy_const_reference>()),
"The configuration parameters of the data source. "
"These vary depending on the type of data source.")
;

View file

@ -0,0 +1,42 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2013 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 <boost/python.hpp>
#include "mapnik_enumeration.hpp"
#include <mapnik/debug_symbolizer.hpp>
void export_debug_symbolizer()
{
using namespace boost::python;
mapnik::enumeration_<mapnik::debug_symbolizer_mode_e>("debug_symbolizer_mode")
.value("COLLISION",mapnik::DEBUG_SYM_MODE_COLLISION)
.value("VERTEX",mapnik::DEBUG_SYM_MODE_VERTEX)
;
class_<mapnik::debug_symbolizer>("DebugSymbolizer",
init<>("Default debug Symbolizer"))
.add_property("mode",
&mapnik::debug_symbolizer::get_mode,
&mapnik::debug_symbolizer::set_mode)
;
}

View file

@ -34,8 +34,6 @@
#include <mapnik/parse_path.hpp>
#include <mapnik/value.hpp>
using mapnik::Feature;
using mapnik::expression_ptr;
using mapnik::parse_expression;
using mapnik::to_expression_string;
@ -53,15 +51,15 @@ std::string expression_to_string_(mapnik::expr_node const& expr)
return mapnik::to_expression_string(expr);
}
mapnik::value expression_evaluate_(mapnik::expr_node const& expr, mapnik::Feature const& f)
mapnik::value expression_evaluate_(mapnik::expr_node const& expr, mapnik::feature_impl const& f)
{
// will be auto-converted to proper python type by `mapnik_value_to_python`
return boost::apply_visitor(mapnik::evaluate<mapnik::Feature,mapnik::value>(f),expr);
return boost::apply_visitor(mapnik::evaluate<mapnik::feature_impl,mapnik::value>(f),expr);
}
bool expression_evaluate_to_bool_(mapnik::expr_node const& expr, mapnik::Feature const& f)
bool expression_evaluate_to_bool_(mapnik::expr_node const& expr, mapnik::feature_impl const& f)
{
return boost::apply_visitor(mapnik::evaluate<mapnik::Feature,mapnik::value>(f),expr).to_bool();
return boost::apply_visitor(mapnik::evaluate<mapnik::feature_impl,mapnik::value>(f),expr).to_bool();
}
// path expression
@ -75,7 +73,7 @@ std::string path_to_string_(mapnik::path_expression const& expr)
return mapnik::path_processor_type::to_string(expr);
}
std::string path_evaluate_(mapnik::path_expression const& expr, mapnik::Feature const& f)
std::string path_evaluate_(mapnik::path_expression const& expr, mapnik::feature_impl const& f)
{
return mapnik::path_processor_type::evaluate(expr, f);
}

View file

@ -30,7 +30,6 @@
#include <boost/python.hpp>
#include <boost/noncopyable.hpp>
// mapnik
#include <mapnik/feature.hpp>
#include <mapnik/feature_kv_iterator.hpp>
@ -39,30 +38,33 @@
#include <mapnik/wkt/wkt_factory.hpp>
#include <mapnik/json/geojson_generator.hpp>
// stl
#include <stdexcept>
namespace {
using mapnik::Feature;
using mapnik::geometry_utils;
using mapnik::from_wkt;
using mapnik::context_type;
using mapnik::context_ptr;
using mapnik::feature_kv_iterator;
mapnik::geometry_type const& (mapnik::Feature::*get_geometry_by_const_ref)(unsigned) const = &mapnik::Feature::get_geometry;
boost::ptr_vector<mapnik::geometry_type> const& (mapnik::Feature::*get_paths_by_const_ref)() const = &mapnik::Feature::paths;
mapnik::geometry_type const& (mapnik::feature_impl::*get_geometry_by_const_ref)(unsigned) const = &mapnik::feature_impl::get_geometry;
boost::ptr_vector<mapnik::geometry_type> const& (mapnik::feature_impl::*get_paths_by_const_ref)() const = &mapnik::feature_impl::paths;
void feature_add_geometries_from_wkb(Feature &feature, std::string wkb)
void feature_add_geometries_from_wkb(mapnik::feature_impl &feature, std::string wkb)
{
geometry_utils::from_wkb(feature.paths(), wkb.c_str(), wkb.size());
bool result = geometry_utils::from_wkb(feature.paths(), wkb.c_str(), wkb.size());
if (!result) throw std::runtime_error("Failed to parse WKB");
}
void feature_add_geometries_from_wkt(Feature &feature, std::string wkt)
void feature_add_geometries_from_wkt(mapnik::feature_impl &feature, std::string wkt)
{
bool result = mapnik::from_wkt(wkt, feature.paths());
if (!result) throw std::runtime_error("Failed to parse WKT");
}
std::string feature_to_geojson(Feature const& feature)
std::string feature_to_geojson(mapnik::feature_impl const& feature)
{
std::string json;
mapnik::json::feature_generator g;
@ -73,22 +75,22 @@ std::string feature_to_geojson(Feature const& feature)
return json;
}
mapnik::value __getitem__(Feature const& feature, std::string const& name)
mapnik::value __getitem__(mapnik::feature_impl const& feature, std::string const& name)
{
return feature.get(name);
}
mapnik::value __getitem2__(Feature const& feature, std::size_t index)
mapnik::value __getitem2__(mapnik::feature_impl const& feature, std::size_t index)
{
return feature.get(index);
}
void __setitem__(Feature & feature, std::string const& name, mapnik::value const& val)
void __setitem__(mapnik::feature_impl & feature, std::string const& name, mapnik::value const& val)
{
feature.put_new(name,val);
}
boost::python::dict attributes(Feature const& f)
boost::python::dict attributes(mapnik::feature_impl const& f)
{
boost::python::dict attributes;
feature_kv_iterator itr = f.begin();
@ -191,7 +193,6 @@ struct value_null_from_python
void export_feature()
{
using namespace boost::python;
using mapnik::Feature;
// Python to mapnik::value converters
// NOTE: order matters here. For example value_null must be listed before
@ -211,25 +212,25 @@ void export_feature()
.def("push", &context_type::push)
;
class_<Feature,boost::shared_ptr<Feature>,
class_<mapnik::feature_impl,boost::shared_ptr<mapnik::feature_impl>,
boost::noncopyable>("Feature",init<context_ptr,mapnik::value_integer>("Default ctor."))
.def("id",&Feature::id)
.def("__str__",&Feature::to_string)
.def("id",&mapnik::feature_impl::id)
.def("__str__",&mapnik::feature_impl::to_string)
.def("add_geometries_from_wkb", &feature_add_geometries_from_wkb)
.def("add_geometries_from_wkt", &feature_add_geometries_from_wkt)
.def("add_geometry", &Feature::add_geometry)
.def("num_geometries",&Feature::num_geometries)
.def("add_geometry", &mapnik::feature_impl::add_geometry)
.def("num_geometries",&mapnik::feature_impl::num_geometries)
.def("get_geometry", make_function(get_geometry_by_const_ref,return_value_policy<reference_existing_object>()))
.def("geometries",make_function(get_paths_by_const_ref,return_value_policy<reference_existing_object>()))
.def("envelope", &Feature::envelope)
.def("has_key", &Feature::has_key)
.def("envelope", &mapnik::feature_impl::envelope)
.def("has_key", &mapnik::feature_impl::has_key)
.add_property("attributes",&attributes)
.def("__setitem__",&__setitem__)
.def("__contains__",&__getitem__)
.def("__getitem__",&__getitem__)
.def("__getitem__",&__getitem2__)
.def("__len__", &Feature::size)
.def("context",&Feature::context)
.def("__len__", &mapnik::feature_impl::size)
.def("context",&mapnik::feature_impl::context)
.def("to_geojson",&feature_to_geojson)
;
}

View file

@ -65,10 +65,7 @@ inline mapnik::feature_ptr next(mapnik::featureset_ptr const& itr)
void export_featureset()
{
using namespace boost::python;
using mapnik::Feature;
using mapnik::Featureset;
class_<Featureset,boost::shared_ptr<Featureset>,
class_<mapnik::Featureset,boost::shared_ptr<mapnik::Featureset>,
boost::noncopyable>("Featureset",no_init)
.def("__iter__",pass_through)
.def("next",next)

View file

@ -43,6 +43,9 @@
#include <mapnik/util/geometry_to_svg.hpp>
#endif
// stl
#include <stdexcept>
namespace {
using mapnik::from_wkt;

View file

@ -20,6 +20,8 @@
*
*****************************************************************************/
#if defined(GRID_RENDERER)
// boost
#include <boost/python.hpp>
#include <boost/python/module.hpp>
@ -80,3 +82,5 @@ void export_grid()
;
}
#endif

View file

@ -20,6 +20,8 @@
*
*****************************************************************************/
#if defined(GRID_RENDERER)
// boost
#include <boost/python.hpp>
#include <boost/python/module.hpp>
@ -49,3 +51,5 @@ void export_grid_view()
)
;
}
#endif

View file

@ -107,6 +107,28 @@ bool painted(mapnik::image_32 const& im)
return im.painted();
}
bool is_solid(mapnik::image_32 const& im)
{
if (im.width() > 0 && im.height() > 0)
{
mapnik::image_data_32 const & data = im.data();
mapnik::image_data_32::pixel_type const* first_row = data.getRow(0);
mapnik::image_data_32::pixel_type const first_pixel = first_row[0];
for (unsigned y = 0; y < im.height(); ++y)
{
mapnik::image_data_32::pixel_type const * row = data.getRow(y);
for (unsigned x = 0; x < im.width(); ++x)
{
if (first_pixel != row[x])
{
return false;
}
}
}
}
return true;
}
unsigned get_pixel(mapnik::image_32 const& im, int x, int y)
{
if (x < static_cast<int>(im.width()) && y < static_cast<int>(im.height()))
@ -142,6 +164,36 @@ boost::shared_ptr<image_32> open_from_file(std::string const& filename)
throw mapnik::image_reader_exception("Unsupported image format:" + filename);
}
boost::shared_ptr<image_32> fromstring(std::string const& str)
{
std::auto_ptr<image_reader> reader(get_image_reader(str.c_str(),str.size()));
if (reader.get())
{
boost::shared_ptr<image_32> image_ptr = boost::make_shared<image_32>(reader->width(),reader->height());
reader->read(0,0,image_ptr->data());
return image_ptr;
}
throw mapnik::image_reader_exception("Failed to load image from buffer" );
}
boost::shared_ptr<image_32> frombuffer(PyObject * obj)
{
void const* buffer=0;
Py_ssize_t buffer_len;
if (PyObject_AsReadBuffer(obj, &buffer, &buffer_len) == 0)
{
std::auto_ptr<image_reader> reader(get_image_reader(reinterpret_cast<char const*>(buffer),buffer_len));
if (reader.get())
{
boost::shared_ptr<image_32> image_ptr = boost::make_shared<image_32>(reader->width(),reader->height());
reader->read(0,0,image_ptr->data());
return image_ptr;
}
}
throw mapnik::image_reader_exception("Failed to load image from buffer" );
}
void blend (image_32 & im, unsigned x, unsigned y, image_32 const& im2, float opacity)
{
im.set_rectangle_alpha2(im2.data(),x,y,opacity);
@ -206,6 +258,7 @@ void export_image()
.def("height",&image_32::height)
.def("view",&image_32::get_view)
.def("painted",&painted)
.def("is_solid",&is_solid)
.add_property("background",make_function
(&image_32::get_background,return_value_policy<copy_const_reference>()),
&image_32::set_background, "The background color of the image.")
@ -219,6 +272,7 @@ void export_image()
arg("mode")=mapnik::src_over,
arg("opacity")=1.0f
))
.def("premultiplied",&image_32::premultiplied)
.def("premultiply",&image_32::premultiply)
.def("demultiply",&image_32::demultiply)
.def("set_pixel",&set_pixel)
@ -234,6 +288,10 @@ void export_image()
.def("save", &save_to_file3)
.def("open",open_from_file)
.staticmethod("open")
.def("frombuffer",&frombuffer)
.staticmethod("frombuffer")
.def("fromstring",&fromstring)
.staticmethod("fromstring")
#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO)
.def("from_cairo",&from_cairo)
.staticmethod("from_cairo")

View file

@ -76,6 +76,27 @@ PyObject* view_tostring3(image_view<image_data_32> const & view, std::string con
(s.data(),s.size());
}
bool is_solid(image_view<image_data_32> const& view)
{
if (view.width() > 0 && view.height() > 0)
{
mapnik::image_view<image_data_32>::pixel_type const* first_row = view.getRow(0);
mapnik::image_view<image_data_32>::pixel_type const first_pixel = first_row[0];
for (unsigned y = 0; y < view.height(); ++y)
{
mapnik::image_view<image_data_32>::pixel_type const * row = view.getRow(y);
for (unsigned x = 0; x < view.width(); ++x)
{
if (first_pixel != row[x])
{
return false;
}
}
}
}
return true;
}
void save_view1(image_view<image_data_32> const& view,
std::string const& filename)
{
@ -104,6 +125,7 @@ void export_image_view()
class_<image_view<image_data_32> >("ImageView","A view into an image.",no_init)
.def("width",&image_view<image_data_32>::width)
.def("height",&image_view<image_data_32>::height)
.def("is_solid",&is_solid)
.def("tostring",&view_tostring1)
.def("tostring",&view_tostring2)
.def("tostring",&view_tostring3)

View file

@ -117,10 +117,14 @@ void set_buffer_size(mapnik::layer & l, boost::optional<int> const& buffer_size)
PyObject * get_buffer_size(mapnik::layer & l)
{
boost::optional<int> buffer_size = l.buffer_size();
boost::optional<int> buffer_size = l.buffer_size();
if (buffer_size)
{
#if PY_VERSION_HEX >= 0x03000000
return PyLong_FromLong(*buffer_size);
#else
return PyInt_FromLong(*buffer_size);
#endif
}
else
{

View file

@ -91,17 +91,6 @@ mapnik::featureset_ptr query_map_point(mapnik::Map const& m, int index, double x
return m.query_map_point(idx, x, y);
}
// deepcopy
/*
mapnik::Map map_deepcopy(mapnik::Map & m, boost::python::dict memo)
{
// FIXME: ignore memo for now
mapnik::Map result;
mapnik::util::deepcopy(m, result);
return result;
}
*/
void set_maximum_extent(mapnik::Map & m, boost::optional<mapnik::box2d<double> > const& box)
{
if (box)
@ -116,10 +105,10 @@ void set_maximum_extent(mapnik::Map & m, boost::optional<mapnik::box2d<double> >
struct extract_style
{
typedef mapnik::feature_type_style result_type;
typedef boost::python::tuple result_type;
result_type operator() (std::map<std::string, mapnik::feature_type_style>::value_type const& val) const
{
return val.second;
return boost::python::make_tuple(val.first,val.second);
}
};
@ -155,7 +144,7 @@ void export_map()
class_<style_range>("StyleRange")
.def("__iter__",
range(&style_range::first, &style_range::second))
boost::python::range(&style_range::first, &style_range::second))
;
class_<Map>("Map","The map object.",init<int,int,optional<std::string const&> >(

View file

@ -30,6 +30,8 @@
#include <mapnik/parse_path.hpp>
#include "mapnik_svg.hpp"
#include "mapnik_enumeration.hpp"
#include "python_optional.hpp"
#include <mapnik/marker_cache.hpp> // for known_svg_prefix_
using mapnik::markers_symbolizer;
@ -70,16 +72,6 @@ void set_marker_type(mapnik::markers_symbolizer & symbolizer, std::string const&
}
// https://github.com/mapnik/mapnik/issues/1367
PyObject* get_fill_opacity_impl(markers_symbolizer & sym)
{
boost::optional<float> fill_opacity = sym.get_fill_opacity();
if (fill_opacity)
return ::PyFloat_FromDouble(*fill_opacity);
Py_RETURN_NONE;
}
void export_markers_symbolizer()
{
using namespace boost::python;
@ -119,7 +111,7 @@ void export_markers_symbolizer()
&markers_symbolizer::set_opacity,
"Set/get the overall opacity")
.add_property("fill_opacity",
&get_fill_opacity_impl,
&markers_symbolizer::get_fill_opacity,
&markers_symbolizer::set_fill_opacity,
"Set/get the fill opacity")
.add_property("ignore_placement",

View file

@ -28,6 +28,9 @@
//mapnik
#include <mapnik/palette.hpp>
// stl
#include <stdexcept>
static boost::shared_ptr<mapnik::rgba_palette> make_palette( std::string const& palette, std::string const& format )
{
mapnik::rgba_palette::palette_type type = mapnik::rgba_palette::PALETTE_RGBA;

View file

@ -27,6 +27,10 @@
// boost
#include <boost/python.hpp>
// stl
#include <stdexcept>
using mapnik::proj_transform;
using mapnik::projection;

View file

@ -25,6 +25,9 @@
#include <boost/python/detail/api_placeholder.hpp>
#include <boost/python/exception_translator.hpp>
// stl
#include <stdexcept>
void register_cairo();
void export_color();
void export_coord();
@ -38,8 +41,10 @@ void export_image();
void export_image_view();
void export_gamma_method();
void export_scaling_method();
#if defined(GRID_RENDERER)
void export_grid();
void export_grid_view();
#endif
void export_map();
void export_python();
void export_expression();
@ -62,6 +67,7 @@ void export_polygon_pattern_symbolizer();
void export_raster_symbolizer();
void export_text_placement();
void export_shield_symbolizer();
void export_debug_symbolizer();
void export_font_engine();
void export_projection();
void export_proj_transform();
@ -84,12 +90,13 @@ void export_logger();
#include <mapnik/rule.hpp>
#include <mapnik/image_util.hpp>
#include <mapnik/load_map.hpp>
#include <mapnik/config_error.hpp>
#include <mapnik/scale_denominator.hpp>
#include <mapnik/value_error.hpp>
#include <mapnik/save_map.hpp>
#include <mapnik/scale_denominator.hpp>
#if defined(GRID_RENDERER)
#include "python_grid_utils.hpp"
#endif
#include "mapnik_value_converter.hpp"
#include "mapnik_threads.hpp"
#include "python_optional.hpp"
@ -333,11 +340,6 @@ double scale_denominator(mapnik::Map const &map, bool geographic)
}
// http://docs.python.org/c-api/exceptions.html#standard-exceptions
void config_error_translator(mapnik::config_error const & ex)
{
PyErr_SetString(PyExc_RuntimeError, ex.what());
}
void value_error_translator(mapnik::value_error const & ex)
{
PyErr_SetString(PyExc_ValueError, ex.what());
@ -348,6 +350,16 @@ void runtime_error_translator(std::runtime_error const & ex)
PyErr_SetString(PyExc_RuntimeError, ex.what());
}
void out_of_range_error_translator(std::out_of_range const & ex)
{
PyErr_SetString(PyExc_IndexError, ex.what());
}
void standard_error_translator(std::exception const & ex)
{
PyErr_SetString(PyExc_RuntimeError, ex.what());
}
unsigned mapnik_version()
{
return MAPNIK_VERSION;
@ -358,7 +370,33 @@ std::string mapnik_version_string()
return MAPNIK_VERSION_STRING;
}
// indicator for jpeg read/write support within libmapnik
bool has_proj4()
{
#if defined(MAPNIK_USE_PROJ4)
return true;
#else
return false;
#endif
}
bool has_svg_renderer()
{
#if defined(SVG_RENDERER)
return true;
#else
return false;
#endif
}
bool has_grid_renderer()
{
#if defined(GRID_RENDERER)
return true;
#else
return false;
#endif
}
bool has_jpeg()
{
#if defined(HAVE_JPEG)
@ -368,6 +406,33 @@ bool has_jpeg()
#endif
}
bool has_png()
{
#if defined(HAVE_PNG)
return true;
#else
return false;
#endif
}
bool has_tiff()
{
#if defined(HAVE_TIFF)
return true;
#else
return false;
#endif
}
bool has_webp()
{
#if defined(HAVE_WEBP)
return true;
#else
return false;
#endif
}
// indicator for cairo rendering support inside libmapnik
bool has_cairo()
{
@ -403,7 +468,7 @@ bool has_pycairo()
}
BOOST_PYTHON_FUNCTION_OVERLOADS(load_map_overloads, load_map, 2, 3)
BOOST_PYTHON_FUNCTION_OVERLOADS(load_map_overloads, load_map, 2, 4)
BOOST_PYTHON_FUNCTION_OVERLOADS(load_map_string_overloads, load_map_string, 2, 4)
BOOST_PYTHON_FUNCTION_OVERLOADS(save_map_overloads, save_map, 2, 3)
BOOST_PYTHON_FUNCTION_OVERLOADS(save_map_to_string_overloads, save_map_to_string, 1, 2)
@ -419,9 +484,9 @@ BOOST_PYTHON_MODULE(_mapnik)
using mapnik::load_map_string;
using mapnik::save_map;
using mapnik::save_map_to_string;
using mapnik::render_grid;
register_exception_translator<mapnik::config_error>(&config_error_translator);
register_exception_translator<std::exception>(&standard_error_translator);
register_exception_translator<std::out_of_range>(&out_of_range_error_translator);
register_exception_translator<mapnik::value_error>(&value_error_translator);
register_exception_translator<std::runtime_error>(&runtime_error_translator);
register_cairo();
@ -439,8 +504,10 @@ BOOST_PYTHON_MODULE(_mapnik)
export_image_view();
export_gamma_method();
export_scaling_method();
#if defined(GRID_RENDERER)
export_grid();
export_grid_view();
#endif
export_expression();
export_rule();
export_style();
@ -458,6 +525,7 @@ BOOST_PYTHON_MODULE(_mapnik)
export_raster_symbolizer();
export_text_placement();
export_shield_symbolizer();
export_debug_symbolizer();
export_font_engine();
export_projection();
export_proj_transform();
@ -477,7 +545,8 @@ BOOST_PYTHON_MODULE(_mapnik)
">>> clear_cache()\n"
);
def("render_grid",&render_grid,
#if defined(GRID_RENDERER)
def("render_grid",&mapnik::render_grid,
( arg("map"),
arg("layer"),
args("key")="__id__",
@ -485,6 +554,7 @@ BOOST_PYTHON_MODULE(_mapnik)
arg("fields")=boost::python::list()
)
);
#endif
def("render_to_file",&render_to_file1,
"\n"
@ -569,9 +639,11 @@ BOOST_PYTHON_MODULE(_mapnik)
(arg("map"),arg("image"),args("layer"))
);
#if defined(GRID_RENDERER)
def("render_layer", &mapnik::render_layer_for_grid,
(arg("map"),arg("grid"),args("layer"),arg("fields")=boost::python::list())
);
#endif
#if defined(HAVE_CAIRO) && defined(HAVE_PYCAIRO)
def("render",&render3,
@ -729,7 +801,12 @@ BOOST_PYTHON_MODULE(_mapnik)
def("save_map_to_string", &save_map_to_string, save_map_to_string_overloads());
def("mapnik_version", &mapnik_version,"Get the Mapnik version number");
def("mapnik_version_string", &mapnik_version_string,"Get the Mapnik version string");
def("has_proj4", &has_proj4, "Get proj4 status");
def("has_jpeg", &has_jpeg, "Get jpeg read/write support status");
def("has_png", &has_png, "Get png read/write support status");
def("has_tiff", &has_jpeg, "Get tiff read/write support status");
def("has_webp", &has_jpeg, "Get webp read/write support status");
def("has_grid_renderer", &has_grid_renderer, "Get grid_renderer status");
def("has_cairo", &has_cairo, "Get cairo library status");
def("has_pycairo", &has_pycairo, "Get pycairo module status");

View file

@ -22,11 +22,15 @@
// boost
#include <boost/python.hpp>
#include <boost/foreach.hpp>
// mapnik
#include <mapnik/query.hpp>
#include <mapnik/box2d.hpp>
#include <string>
#include <set>
using mapnik::query;
using mapnik::box2d;
@ -46,11 +50,30 @@ struct resolution_to_tuple
}
};
struct names_to_list
{
static PyObject* convert(std::set<std::string> const& names)
{
boost::python::list l;
BOOST_FOREACH( std::string const& name, names )
{
l.append(name);
}
return python::incref(l.ptr());
}
static PyTypeObject const* get_pytype()
{
return &PyList_Type;
}
};
void export_query()
{
using namespace boost::python;
to_python_converter<query::resolution_type, resolution_to_tuple> ();
to_python_converter<std::set<std::string>, names_to_list> ();
class_<query>("Query", "a spatial query data object",
init<box2d<double>,query::resolution_type const&,double>() )

View file

@ -28,18 +28,7 @@
#include <mapnik/raster_colorizer.hpp>
#include <mapnik/image_scaling.hpp>
namespace {
// https://github.com/mapnik/mapnik/issues/1367
PyObject* get_premultiplied_impl(mapnik::raster_symbolizer & sym)
{
boost::optional<bool> premultiplied = sym.premultiplied();
if (premultiplied)
return ::PyBool_FromLong(*premultiplied);
Py_RETURN_NONE;
}
}
using mapnik::raster_symbolizer;
void export_raster_symbolizer()
@ -132,7 +121,7 @@ void export_raster_symbolizer()
">>> r.mesh_size = 32\n"
)
.add_property("premultiplied",
&get_premultiplied_impl,
&raster_symbolizer::premultiplied,
&raster_symbolizer::set_premultiplied,
"Get/Set premultiplied status of the source image.\n"
"Can be used to override what the source data reports (when in error)\n"

View file

@ -34,7 +34,6 @@
using mapnik::rule;
using mapnik::expr_node;
using mapnik::expression_ptr;
using mapnik::Feature;
using mapnik::point_symbolizer;
using mapnik::line_symbolizer;
using mapnik::line_pattern_symbolizer;

View file

@ -28,7 +28,6 @@
#include <mapnik/value_error.hpp>
#include "mapnik_enumeration.hpp"
#include <mapnik/feature_type_style.hpp>
#include <mapnik/image_filter_grammar.hpp> // image_filter_grammar
#include <mapnik/image_filter_types.hpp> // generate_image_filters
using mapnik::feature_type_style;
@ -45,18 +44,12 @@ std::string get_image_filters(feature_type_style & style)
void set_image_filters(feature_type_style & style, std::string const& filters)
{
std::string::const_iterator itr = filters.begin();
std::string::const_iterator end = filters.end();
mapnik::image_filter_grammar<std::string::const_iterator,
std::vector<mapnik::filter::filter_type> > filter_grammar;
std::vector<mapnik::filter::filter_type> new_filters;
bool result = boost::spirit::qi::phrase_parse(itr,end,
filter_grammar,
boost::spirit::qi::ascii::space,
new_filters);
if (!result || itr!=end)
bool result = parse_image_filters(filters, new_filters);
if (!result)
{
throw mapnik::value_error("failed to parse image-filters: '" + std::string(itr,end) + "'");
throw mapnik::value_error("failed to parse image-filters: '" + filters + "'");
}
style.image_filters().swap(new_filters);
}

View file

@ -84,7 +84,7 @@ struct NodeWrap: formatting::node, wrapper<formatting::node>
}
void apply(char_properties const& p, Feature const& feature, processed_text &output) const
void apply(char_properties const& p, feature_impl const& feature, processed_text &output) const
{
python_block_auto_unblock b;
this->get_override("apply")(ptr(&p), ptr(&feature), ptr(&output));
@ -122,7 +122,7 @@ struct TextNodeWrap: formatting::text_node, wrapper<formatting::text_node>
}
virtual void apply(char_properties const& p, Feature const& feature, processed_text &output) const
virtual void apply(char_properties const& p, feature_impl const& feature, processed_text &output) const
{
if(override o = this->get_override("apply"))
{
@ -135,7 +135,7 @@ struct TextNodeWrap: formatting::text_node, wrapper<formatting::text_node>
}
}
void default_apply(char_properties const& p, Feature const& feature, processed_text &output) const
void default_apply(char_properties const& p, feature_impl const& feature, processed_text &output) const
{
formatting::text_node::apply(p, feature, output);
}
@ -143,7 +143,7 @@ struct TextNodeWrap: formatting::text_node, wrapper<formatting::text_node>
struct FormatNodeWrap: formatting::format_node, wrapper<formatting::format_node>
{
virtual void apply(char_properties const& p, Feature const& feature, processed_text &output) const
virtual void apply(char_properties const& p, feature_impl const& feature, processed_text &output) const
{
if(override o = this->get_override("apply"))
{
@ -156,7 +156,7 @@ struct FormatNodeWrap: formatting::format_node, wrapper<formatting::format_node>
}
}
void default_apply(char_properties const& p, Feature const& feature, processed_text &output) const
void default_apply(char_properties const& p, feature_impl const& feature, processed_text &output) const
{
formatting::format_node::apply(p, feature, output);
}
@ -164,7 +164,7 @@ struct FormatNodeWrap: formatting::format_node, wrapper<formatting::format_node>
struct ExprFormatWrap: formatting::expression_format, wrapper<formatting::expression_format>
{
virtual void apply(char_properties const& p, Feature const& feature, processed_text &output) const
virtual void apply(char_properties const& p, feature_impl const& feature, processed_text &output) const
{
if(override o = this->get_override("apply"))
{
@ -177,7 +177,7 @@ struct ExprFormatWrap: formatting::expression_format, wrapper<formatting::expres
}
}
void default_apply(char_properties const& p, Feature const& feature, processed_text &output) const
void default_apply(char_properties const& p, feature_impl const& feature, processed_text &output) const
{
formatting::expression_format::apply(p, feature, output);
}
@ -201,7 +201,7 @@ struct ListNodeWrap: formatting::list_node, wrapper<formatting::list_node>
http://wiki.python.org/moin/boost.python/HowTo#A.22Raw.22_function */
virtual void apply(char_properties const& p, Feature const& feature, processed_text &output) const
virtual void apply(char_properties const& p, feature_impl const& feature, processed_text &output) const
{
if(override o = this->get_override("apply"))
{
@ -214,7 +214,7 @@ struct ListNodeWrap: formatting::list_node, wrapper<formatting::list_node>
}
}
void default_apply(char_properties const& p, Feature const& feature, processed_text &output) const
void default_apply(char_properties const& p, feature_impl const& feature, processed_text &output) const
{
formatting::list_node::apply(p, feature, output);
}
@ -340,6 +340,11 @@ void export_text_placement()
.value("CAPITALIZE",CAPITALIZE)
;
enumeration_<halo_rasterizer_e>("halo_rasterizer")
.value("FULL",HALO_RASTERIZER_FULL)
.value("FAST",HALO_RASTERIZER_FAST)
;
class_<text_symbolizer>("TextSymbolizer",
init<>())
.def(init<expression_ptr, std::string const&, unsigned, color const&>())
@ -363,6 +368,10 @@ void export_text_placement()
&text_symbolizer::clip,
&text_symbolizer::set_clip,
"Set/get the text geometry's clipping status")
.add_property("halo_rasterizer",
&text_symbolizer::get_halo_rasterizer,
&text_symbolizer::set_halo_rasterizer,
"Set/get the halo rasterizer method")
;

View file

@ -35,11 +35,7 @@ namespace boost { namespace python {
{
PyObject * operator() (mapnik::value_integer val) const
{
#if PY_VERSION_HEX >= 0x03000000
return ::PyLong_FromLong(val);
#else
return ::PyInt_FromLong(val);
#endif
return ::PyLong_FromLongLong(val);
}
PyObject * operator() (double val) const

View file

@ -20,6 +20,8 @@
*
*****************************************************************************/
#if defined(GRID_RENDERER)
// boost
#include <boost/python.hpp>
#include <boost/scoped_array.hpp>
@ -39,13 +41,16 @@
#include "mapnik_value_converter.hpp"
#include "python_grid_utils.hpp"
// stl
#include <stdexcept>
namespace mapnik {
template <typename T>
void grid2utf(T const& grid_type,
boost::python::list& l,
std::vector<grid::lookup_type>& key_order)
std::vector<typename T::lookup_type>& key_order)
{
typedef std::map< typename T::lookup_type, typename T::value_type> keys_type;
typedef typename keys_type::const_iterator keys_iterator;
@ -469,3 +474,5 @@ boost::python::dict render_grid(mapnik::Map const& map,
}
}
#endif

View file

@ -22,7 +22,8 @@
#include <boost/optional/optional.hpp>
#include <boost/python.hpp>
#include <boost/noncopyable.hpp>
#include <mapnik/noncopyable.hpp>
// boost::optional<T> to/from converter from John Wiegley
@ -46,7 +47,7 @@ struct register_python_conversion
};
template <typename T>
struct python_optional : public boost::noncopyable
struct python_optional : public mapnik::noncopyable
{
struct optional_to_python
{
@ -74,7 +75,7 @@ struct python_optional : public boost::noncopyable
rvalue_from_python_stage1(source, converters);
return rvalue_from_python_stage2(source, data, converters);
}
return NULL;
return 0;
}
static void construct(PyObject * source,
@ -94,17 +95,116 @@ struct python_optional : public boost::noncopyable
}
};
explicit python_optional() {
explicit python_optional()
{
register_python_conversion<boost::optional<T>,
optional_to_python, optional_from_python>();
}
};
/** This class works around a bug in boost python.
// to/from boost::optional<bool>
template <>
struct python_optional<float> : public mapnik::noncopyable
{
struct optional_to_python
{
static PyObject * convert(const boost::optional<float>& value)
{
return (value ? PyFloat_FromDouble(*value) :
boost::python::detail::none());
}
};
See http://osdir.com/ml/python.c++/2003-11/msg00158.html
*/
template <typename T, typename X1 = boost::python::detail::not_specified, typename X2 = boost::python::detail::not_specified, typename X3 = boost::python::detail::not_specified>
struct optional_from_python
{
static void * convertible(PyObject * source)
{
using namespace boost::python::converter;
if (source == Py_None || PyFloat_Check(source))
return source;
return 0;
}
static void construct(PyObject * source,
boost::python::converter::rvalue_from_python_stage1_data * data)
{
using namespace boost::python::converter;
void * const storage = ((rvalue_from_python_storage<boost::optional<bool> > *)
data)->storage.bytes;
if (source == Py_None) // == None
new (storage) boost::optional<float>(); // A Boost uninitialized value
else
new (storage) boost::optional<float>(PyFloat_AsDouble(source));
data->convertible = storage;
}
};
explicit python_optional()
{
register_python_conversion<boost::optional<float>,
optional_to_python, optional_from_python>();
}
};
// to/from boost::optional<float>
template <>
struct python_optional<bool> : public mapnik::noncopyable
{
struct optional_to_python
{
static PyObject * convert(const boost::optional<bool>& value)
{
if (value)
{
if (*value) Py_RETURN_TRUE;
else Py_RETURN_FALSE;
}
else return boost::python::detail::none();
}
};
struct optional_from_python
{
static void * convertible(PyObject * source)
{
using namespace boost::python::converter;
if (source == Py_None || PyBool_Check(source))
return source;
return 0;
}
static void construct(PyObject * source,
boost::python::converter::rvalue_from_python_stage1_data * data)
{
using namespace boost::python::converter;
void * const storage = ((rvalue_from_python_storage<boost::optional<bool> > *)
data)->storage.bytes;
if (source == Py_None) // == None
new (storage) boost::optional<bool>(); // A Boost uninitialized value
else
{
new (storage) boost::optional<bool>(source == Py_True ? true : false);
}
data->convertible = storage;
}
};
explicit python_optional()
{
register_python_conversion<boost::optional<bool>,
optional_to_python, optional_from_python>();
}
};
// This class works around a feature in boost python.
// See http://osdir.com/ml/python.c++/2003-11/msg00158.html
template <typename T,
typename X1 = boost::python::detail::not_specified,
typename X2 = boost::python::detail::not_specified,
typename X3 = boost::python::detail::not_specified>
class class_with_converter : public boost::python::class_<T, X1, X2, X3>
{
public:
@ -128,7 +228,7 @@ public:
: boost::python::class_<T, X1, X2, X3>(name, doc, i) { }
template <class D>
self& def_readwrite_convert(char const* name, D const& d, char const* doc=0)
self& def_readwrite_convert(char const* name, D const& d, char const* /*doc*/=0)
{
this->add_property(name,
boost::python::make_getter(d, boost::python::return_value_policy<boost::python::return_by_value>()),

View file

@ -1,4 +1,4 @@
CXXFLAGS = $(shell mapnik-config --cflags)
CXXFLAGS = $(shell mapnik-config --includes --defines --cxxflags --dep-includes)
LDFLAGS = $(shell mapnik-config --libs --dep-libs --ldflags)
OBJ = rundemo.o
@ -13,8 +13,15 @@ $(BIN) : $(OBJ)
.c.o :
$(CXX) -c $(CXXFLAGS) $<
gyp:
rm -rf ./build
gyp rundemo.gyp --depth=. -f make --generator-output=./build/
make -C ./build
build/out/Release/rundemo `mapnik-config --prefix`
.PHONY : clean
clean:
rm -f $(OBJ)
rm -f $(BIN)
rm -f ./build

81
demo/c++/README.md Normal file
View file

@ -0,0 +1,81 @@
## rundemo.cpp
This directory contains a simple c++ program demonstrating the Mapnik C++ API. It mimics the python 'rundemo.py' example with a couple exceptions.
If building on unix you can have this program automatically build by configuring Mapnik like:
./configure DEMO=True
However, this example code also should be able to be built standalone.
The following notes describe how to do that on various operating systems.
## Depends
- Mapnik library development headers
- `mapnik-config` on unix and `mapnik-config.bat` on windows
### Unix
On OS X and Linux you also need `make`.
### Windows
On windows, additional dependencies to build are:
- MSVS 2010 with C++ compiler
- Python 2.x
- gyp: https://code.google.com/p/gyp | https://github.com/springmeyer/hello-gyp
`mapnik-config.bat` should come with your Mapnik installation.
First confirm it is on your path:
mapnik-config # should give usage
To install gyp, which is pure python do:
svn checkout http://gyp.googlecode.com/svn/trunk/ gyp
cd gyp
python setup.py install
If you do not have svn installed you can grab gyp from:
https://github.com/TooTallNate/node-gyp/archive/master.zip
# unzip and extract the 'gyp' subfolder then do
cd gyp
python setup.py install
## Building the demo
### Unix
Simply type:
make
Then to run do:
./rundemo `mapnik-config --prefix`
On OS X you can also create an xcode project:
gyp rundemo.gyp --depth=. -f xcode --generator-output=./build/
xcodebuild -project ./build/rundemo.xcodeproj
./build/out/Release/rundemo `mapnik-config --prefix`
### Windows
First you need to build the visual studio solution with gyp:
C:\Python27\python.exe c:\Python27\Scripts\gyp rundemo.gyp --depth=. -f msvs -G msvs_version=2010
Then you can compile with `msbuild`:
msbuild rundemo.sln /p:Configuration="Release" /p:Platform=Win32
Then run it!
for /f %i in ('mapnik-config --prefix') do set MAPNIK_PREFIX=%i
Release\rundemo.exe %MAPNIK_PREFIX%

View file

@ -34,13 +34,16 @@ demo_env = env.Clone()
demo_env['CXXFLAGS'] = copy(env['LIBMAPNIK_CXXFLAGS'])
demo_env.Append(CPPDEFINES = env['LIBMAPNIK_DEFINES'])
if env['HAS_CAIRO']:
demo_env.PrependUnique(CPPPATH=env['CAIRO_CPPPATHS'])
demo_env.Append(CXXFLAGS = '-DHAVE_CAIRO')
demo_env.Append(CPPDEFINES = '-DHAVE_CAIRO')
libraries = copy(env['LIBMAPNIK_LIBS'])
libraries.append('mapnik')
libraries = ['mapnik']
libraries.extend(copy(env['LIBMAPNIK_LIBS']))
if env['RUNTIME_LINK'] == 'static' and env['PLATFORM'] == 'Linux':
libraries.append('dl')
rundemo = demo_env.Program('rundemo', source, LIBS=libraries, LINKFLAGS=env["CUSTOM_LDFLAGS"])

42
demo/c++/common.gypi Normal file
View file

@ -0,0 +1,42 @@
{
'variables': {
'conditions': [
['OS == "mac"', {
'target_arch%': 'x64'
}, {
'target_arch%': 'ia32'
}]
]
},
'target_defaults': {
'default_configuration': 'Release',
'defines': [ ],
'conditions': [
['OS == "mac"', {
'defines': [ 'DARWIN' ]
}, {
'defines': [ 'LINUX' ]
}],
['OS == "mac" and target_arch == "x64"', {
'xcode_settings': {
'ARCHS': [ 'x86_64' ]
},
}]
],
'configurations': {
'Debug': {
'cflags': [ '-g', '-O0' ],
'xcode_settings': {
'OTHER_CFLAGS': [ '-g', '-O0' ]
}
},
'Release': {
'cflags': [ '-O3' ],
'defines': [ 'NDEBUG' ],
'xcode_settings': {
'OTHER_CFLAGS': [ '-O3' ]
}
}
}
}
}

View file

@ -1,20 +0,0 @@
This directory contains a simple c++ program demonstrating the Mapnik C++ API. It mimics the python 'rundemo.py' example with a couple exceptions.
To build it re-configure SCons with DEMO=True then rebuild::
$ python scons/scons.py configure DEMO=True
$ python scons/scons.py
The sample program will be compiled (but not installed).
To run::
$ cd demo/c++
$ ./rundemo /usr/local/lib/mapnik
For more detailed comments have a look in demo/python/rundemo.py
Have fun!
Artem.

View file

@ -34,7 +34,6 @@
#include <mapnik/expression.hpp>
#include <mapnik/color_factory.hpp>
#include <mapnik/image_util.hpp>
#include <mapnik/config_error.hpp>
#if defined(HAVE_CAIRO)
#include <mapnik/cairo_renderer.hpp>
@ -313,11 +312,6 @@ int main ( int argc , char** argv)
#endif
}
catch ( const mapnik::config_error & ex )
{
std::cerr << "### Configuration error: " << ex.what() << std::endl;
return EXIT_FAILURE;
}
catch ( const std::exception & ex )
{
std::cerr << "### std::exception: " << ex.what() << std::endl;

48
demo/c++/rundemo.gyp Normal file
View file

@ -0,0 +1,48 @@
{
'includes': [ 'common.gypi' ],
'default_configuration': 'Release',
'targets': [
{
'target_name': 'rundemo',
'type': 'executable',
'sources': [
'rundemo.cpp',
],
'conditions': [
[ 'OS=="mac"', {
'libraries': [
'-lmapnik',
'-undefined dynamic_lookup'
],
'xcode_settings': {
'OTHER_CPLUSPLUSFLAGS':[
'<!@(mapnik-config --cflags)'
],
'GCC_ENABLE_CPP_RTTI': 'YES',
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES'
}
}],
[ 'OS=="win"', {
'defines': [
'<!@(mapnik-config --defines)',
],
'libraries': [
'<!@(mapnik-config --libs)',
'<!@(mapnik-config --dep-libs)'
],
'include_dirs': [
'<!@(mapnik-config --includes)',
'<!@(mapnik-config --dep-includes)',
],
'msvs_settings': {
'VCLinkerTool': {
'AdditionalLibraryDirectories': [
'<!@(mapnik-config --ldflags)'
]
}
}
}]
]
}
],
}

View file

@ -1,25 +0,0 @@
<GMLFeatureClassList>
<GMLFeatureClass>
<Name>charplacement</Name>
<ElementPath>charplacement</ElementPath>
<DatasetSpecificInfo>
<FeatureCount>1</FeatureCount>
<ExtentXMin>1.00000</ExtentXMin>
<ExtentXMax>2.00000</ExtentXMax>
<ExtentYMin>1.00000</ExtentYMin>
<ExtentYMax>5.00000</ExtentYMax>
</DatasetSpecificInfo>
<PropertyDefn>
<Name>NAME</Name>
<ElementPath>NAME</ElementPath>
<Type>String</Type>
<Width>0</Width>
</PropertyDefn>
<PropertyDefn>
<Name>CLASS</Name>
<ElementPath>CLASS</ElementPath>
<Type>String</Type>
<Width>0</Width>
</PropertyDefn>
</GMLFeatureClass>
</GMLFeatureClassList>

View file

@ -1,99 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="charplacement.xsd"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
<gml:Box>
<gml:coord><gml:X>0</gml:X><gml:Y>0</gml:Y></gml:coord>
<gml:coord><gml:X>13</gml:X><gml:Y>-13</gml:Y></gml:coord>
</gml:Box>
</gml:boundedBy>
<gml:featureMember>
<ogr:charplacement fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>2,-1 1,-3 2,-5</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>TRIANGLE</ogr:CLASS>
</ogr:charplacement>
<ogr:charplacement fid="F1">
<ogr:geometryProperty><gml:LineString><gml:coordinates>3,-1 4,-3 3,-5</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>TRIANGLE</ogr:CLASS>
</ogr:charplacement>
<ogr:charplacement fid="F7">
<ogr:geometryProperty><gml:LineString><gml:coordinates>
1,-12 13,-12
</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>STRAIGHT</ogr:CLASS>
</ogr:charplacement>
<ogr:charplacement fid="F8">
<ogr:geometryProperty><gml:LineString><gml:coordinates>
1,-13 2,-13 5,-13 10,-13 13,-13
</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>STRAIGHT</ogr:CLASS>
</ogr:charplacement>
<ogr:charplacement fid="F9">
<ogr:geometryProperty><gml:LineString><gml:coordinates>6,-1 5,-3 5,-5</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>BEND</ogr:CLASS>
</ogr:charplacement>
<ogr:charplacement fid="F10">
<ogr:geometryProperty><gml:LineString><gml:coordinates>7,-1 8,-3 8,-5</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>BEND</ogr:CLASS>
</ogr:charplacement>
<ogr:charplacement fid="F11">
<ogr:geometryProperty><gml:LineString><gml:coordinates>5,-6 5,-8 6,-10</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>BEND</ogr:CLASS>
</ogr:charplacement>
<ogr:charplacement fid="F12">
<ogr:geometryProperty><gml:LineString><gml:coordinates>8,-6 8,-8 7,-10</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>BEND</ogr:CLASS>
</ogr:charplacement>
<ogr:charplacement fid="F13">
<ogr:geometryProperty><gml:LineString><gml:coordinates>10.055915,-1.00031738281 10.6649858,-1.077712483 11.274056,-1.26950068 11.77921,-1.55298308 12.191993,-1.92815928 12.51529,-2.369132 12.746218,-2.8329032 12.884774,-3.2968745 12.930959,-3.875339</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>CURVE</ogr:CLASS>
</ogr:charplacement>
<ogr:charplacement fid="F14">
<ogr:geometryProperty><gml:LineString><gml:coordinates>10.0555,-8.875339 10.6645708,-8.7979439 11.273641,-8.6061557 11.778795,-8.3226733 12.191578,-7.9474971 12.514875,-7.5065244 12.745803,-7.0427532 12.884359,-6.5787819 12.930544,-6.0003174</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>CURVE</ogr:CLASS>
</ogr:charplacement>
<ogr:charplacement fid="F15">
<ogr:geometryProperty><gml:LineString><gml:coordinates>
9.055915,-2.00031738281 9.6649858,-2.077712483 10.274056,-2.26950068 10.77921,-2.55298308 11.191993,-2.92815928 11.51529,-3.369132 11.746218,-3.8329032 11.884774,-4.2968745 11.930959,-4.875339
11.930544,-5.0003174 11.884359,-5.5787819 11.745803,-6.0427532 11.514875,-6.5065244 11.191578,-6.9474971 10.778795,-7.3226733 10.273641,-7.6061557 9.6645708,-7.7979439 9.0555,-7.875339
</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>CURVE</ogr:CLASS>
</ogr:charplacement>
<ogr:charplacement fid="F16">
<ogr:geometryProperty><gml:LineString><gml:coordinates>
9.0435048,-10.5550195 9.480786,-10.2191668 9.963148,-10.0731439 10.540222,-10.2495527 10.968444,-10.525815 11.419238,-10.8336443 12.01882,-10.9565825 12.559787,-10.7996079 12.956495,-10.4089966
</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>SQUIGGLE</ogr:CLASS>
</ogr:charplacement>
<ogr:charplacement fid="F16">
<ogr:geometryProperty><gml:LineString><gml:coordinates>
1,-9 1.4,-10 1.8,-9 2.2,-10 2.6,-9 3.0,-10 3.4,-9 3.8,-10 4.2,-9 4.6,-10
</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Long ZigZag Road Name</ogr:NAME>
<ogr:CLASS>ZIGZAG</ogr:CLASS>
</ogr:charplacement>
</gml:featureMember>
</ogr:FeatureCollection>

View file

@ -1,36 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://ogr.maptools.org/" xmlns:ogr="http://ogr.maptools.org/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:gml="http://www.opengis.net/gml" elementFormDefault="qualified" version="1.0">
<xs:import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengeospatial.net/gml/2.1.2/feature.xsd"/><xs:element name="FeatureCollection" type="ogr:FeatureCollectionType" substitutionGroup="gml:_FeatureCollection"/>
<xs:complexType name="FeatureCollectionType">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureCollectionType">
<xs:attribute name="lockId" type="xs:string" use="optional"/>
<xs:attribute name="scope" type="xs:string" use="optional"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="charplacement" type="ogr:charplacement_Type" substitutionGroup="gml:_Feature"/>
<xs:complexType name="charplacement_Type">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureType">
<xs:sequence>
<xs:element name="geometryProperty" type="gml:GeometryPropertyType" nillable="true" minOccurs="1" maxOccurs="1"/>
<xs:element name="NAME" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="60"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="CLASS" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="60"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>

View file

@ -1,25 +0,0 @@
<GMLFeatureClassList>
<GMLFeatureClass>
<Name>displacement</Name>
<ElementPath>displacement</ElementPath>
<DatasetSpecificInfo>
<FeatureCount>1</FeatureCount>
<ExtentXMin>1.00000</ExtentXMin>
<ExtentXMax>2.00000</ExtentXMax>
<ExtentYMin>1.00000</ExtentYMin>
<ExtentYMax>5.00000</ExtentYMax>
</DatasetSpecificInfo>
<PropertyDefn>
<Name>NAME</Name>
<ElementPath>NAME</ElementPath>
<Type>String</Type>
<Width>0</Width>
</PropertyDefn>
<PropertyDefn>
<Name>CLASS</Name>
<ElementPath>CLASS</ElementPath>
<Type>String</Type>
<Width>0</Width>
</PropertyDefn>
</GMLFeatureClass>
</GMLFeatureClassList>

View file

@ -1,173 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="displacement.xsd"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
<gml:Box>
<gml:coord><gml:X>0</gml:X><gml:Y>0</gml:Y></gml:coord>
<gml:coord><gml:X>13</gml:X><gml:Y>-13</gml:Y></gml:coord>
</gml:Box>
</gml:boundedBy>
<gml:featureMember>
<ogr:displacement fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>1,-3 1,-2</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road</ogr:NAME>
<ogr:CLASS>CLOCKWISE</ogr:CLASS>
</ogr:displacement>
<ogr:displacement fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>1,-2 2,-1</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road</ogr:NAME>
<ogr:CLASS>CLOCKWISE</ogr:CLASS>
</ogr:displacement>
<ogr:displacement fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>2,-1 3,-1</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road</ogr:NAME>
<ogr:CLASS>CLOCKWISE</ogr:CLASS>
</ogr:displacement>
<ogr:displacement fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>3,-1 4,-2</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road</ogr:NAME>
<ogr:CLASS>CLOCKWISE</ogr:CLASS>
</ogr:displacement>
<ogr:displacement fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>4,-2 4,-3</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road</ogr:NAME>
<ogr:CLASS>CLOCKWISE</ogr:CLASS>
</ogr:displacement>
<ogr:displacement fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>4,-3 3,-4</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road</ogr:NAME>
<ogr:CLASS>CLOCKWISE</ogr:CLASS>
</ogr:displacement>
<ogr:displacement fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>3,-4 2,-4</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road</ogr:NAME>
<ogr:CLASS>CLOCKWISE</ogr:CLASS>
</ogr:displacement>
<ogr:displacement fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>2,-4 1,-3</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road</ogr:NAME>
<ogr:CLASS>CLOCKWISE</ogr:CLASS>
</ogr:displacement>
<ogr:displacement fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>5,-3 6,-4</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road</ogr:NAME>
<ogr:CLASS>ANTICLOCKWISE</ogr:CLASS>
</ogr:displacement>
<ogr:displacement fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>6,-4 7,-4</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road</ogr:NAME>
<ogr:CLASS>ANTICLOCKWISE</ogr:CLASS>
</ogr:displacement>
<ogr:displacement fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>7,-4 8,-3</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road</ogr:NAME>
<ogr:CLASS>ANTICLOCKWISE</ogr:CLASS>
</ogr:displacement>
<ogr:displacement fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>8,-3 8,-2</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road</ogr:NAME>
<ogr:CLASS>ANTICLOCKWISE</ogr:CLASS>
</ogr:displacement>
<ogr:displacement fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>8,-2 7,-1</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road</ogr:NAME>
<ogr:CLASS>ANTICLOCKWISE</ogr:CLASS>
</ogr:displacement>
<ogr:displacement fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>7,-1 6,-1</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road</ogr:NAME>
<ogr:CLASS>ANTICLOCKWISE</ogr:CLASS>
</ogr:displacement>
<ogr:displacement fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>6,-1 5,-2</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road</ogr:NAME>
<ogr:CLASS>ANTICLOCKWISE</ogr:CLASS>
</ogr:displacement>
<ogr:displacement fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>5,-2 5,-3</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road</ogr:NAME>
<ogr:CLASS>ANTICLOCKWISE</ogr:CLASS>
</ogr:displacement>
<ogr:displacement fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>
1,-6.5 2,-5.5 3,-5 4,-5 5,-5.5 6,-6.5
</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Long Road Name To Go Around The Whole Curve!</ogr:NAME>
<ogr:CLASS>CURVE</ogr:CLASS>
</ogr:displacement>
<ogr:displacement fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>
1,-7 2,-8 3,-8.5 4,-8.5 5,-8 6,-7
</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Long Road Name To Go Around The Whole Curve!</ogr:NAME>
<ogr:CLASS>CURVE</ogr:CLASS>
</ogr:displacement>
<ogr:displacement fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>
3,-8.5 2,-9.5 1.5,-10.5 1.5,-11.5 2,-12.5 3,-13.5
</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Long Road Name To Go Around The Whole Curve!</ogr:NAME>
<ogr:CLASS>VERTCURVE</ogr:CLASS>
</ogr:displacement>
<ogr:displacement fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>
4,-8.5 5,-9.5 5.5,-10.5 5.5,-11.5 5,-12.5 4,-13.5
</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Long Road Name To Go Around The Whole Curve!</ogr:NAME>
<ogr:CLASS>VERTCURVE</ogr:CLASS>
</ogr:displacement>
<ogr:displacement fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>
9.2,-4 9,-3 10,-3 10.2,-4
</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>PARALLELOGRAM</ogr:CLASS>
</ogr:displacement>
<ogr:displacement fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>
9,-2 9.2,-1 10.2,-1 10,-2
</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>PARALLELOGRAM</ogr:CLASS>
</ogr:displacement>
<ogr:displacement fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>
11,-1 11,-2 12,-2
</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>CORNER</ogr:CLASS>
</ogr:displacement>
<ogr:displacement fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>
11,-4 12,-4 12,-3
</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>CORNER</ogr:CLASS>
</ogr:displacement>
<ogr:displacement fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>
12.5,-1 13.5,-1 13.5,-2
</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>CORNER</ogr:CLASS>
</ogr:displacement>
<ogr:displacement fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>
12.5,-4 12.5,-3 13.5,-3
</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>CORNER</ogr:CLASS>
</ogr:displacement>
</gml:featureMember>
</ogr:FeatureCollection>

View file

@ -1,36 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://ogr.maptools.org/" xmlns:ogr="http://ogr.maptools.org/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:gml="http://www.opengis.net/gml" elementFormDefault="qualified" version="1.0">
<xs:import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengeospatial.net/gml/2.1.2/feature.xsd"/><xs:element name="FeatureCollection" type="ogr:FeatureCollectionType" substitutionGroup="gml:_FeatureCollection"/>
<xs:complexType name="FeatureCollectionType">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureCollectionType">
<xs:attribute name="lockId" type="xs:string" use="optional"/>
<xs:attribute name="scope" type="xs:string" use="optional"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="displacement" type="ogr:displacement_Type" substitutionGroup="gml:_Feature"/>
<xs:complexType name="displacement_Type">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureType">
<xs:sequence>
<xs:element name="geometryProperty" type="gml:GeometryPropertyType" nillable="true" minOccurs="1" maxOccurs="1"/>
<xs:element name="NAME" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="60"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="CLASS" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="60"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>

View file

@ -1,25 +0,0 @@
<GMLFeatureClassList>
<GMLFeatureClass>
<Name>overlap</Name>
<ElementPath>overlap</ElementPath>
<DatasetSpecificInfo>
<FeatureCount>1</FeatureCount>
<ExtentXMin>1.00000</ExtentXMin>
<ExtentXMax>2.00000</ExtentXMax>
<ExtentYMin>1.00000</ExtentYMin>
<ExtentYMax>5.00000</ExtentYMax>
</DatasetSpecificInfo>
<PropertyDefn>
<Name>NAME</Name>
<ElementPath>NAME</ElementPath>
<Type>String</Type>
<Width>0</Width>
</PropertyDefn>
<PropertyDefn>
<Name>CLASS</Name>
<ElementPath>CLASS</ElementPath>
<Type>String</Type>
<Width>0</Width>
</PropertyDefn>
</GMLFeatureClass>
</GMLFeatureClassList>

View file

@ -1,127 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="overlap.xsd"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
<gml:Box>
<gml:coord><gml:X>0</gml:X><gml:Y>0</gml:Y></gml:coord>
<gml:coord><gml:X>13</gml:X><gml:Y>-13</gml:Y></gml:coord>
</gml:Box>
</gml:boundedBy>
<gml:featureMember>
<ogr:overlap fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>1,-1 1,-10</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>NETWORK</ogr:CLASS>
</ogr:overlap>
<ogr:overlap fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>1,-3 7,-3</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>NETWORK</ogr:CLASS>
</ogr:overlap>
<ogr:overlap fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>7,-3 7,-7</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>NETWORK</ogr:CLASS>
</ogr:overlap>
<ogr:overlap fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>3,-2 3,-8</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>NETWORK</ogr:CLASS>
</ogr:overlap>
<ogr:overlap fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>7,-7 1,-7</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>NETWORK</ogr:CLASS>
</ogr:overlap>
<ogr:overlap fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>5,-2 5,-8</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>NETWORK</ogr:CLASS>
</ogr:overlap>
<ogr:overlap fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>8,-3 12,-3</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>CROSS</ogr:CLASS>
</ogr:overlap>
<ogr:overlap fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>10,-1 10,-5</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>CROSS</ogr:CLASS>
</ogr:overlap>
<ogr:overlap fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>
10,-9 13,-9 13,-11 11,-11 11,-8
</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>SELFOVERLAP</ogr:CLASS>
</ogr:overlap>
<ogr:overlap fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>4,-9 4,-13</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>NETWORK2</ogr:CLASS>
</ogr:overlap>
<ogr:overlap fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>8,-9 8,-13</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>NETWORK2</ogr:CLASS>
</ogr:overlap>
<ogr:overlap fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>1,-11 9,-11</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>NETWORK2</ogr:CLASS>
</ogr:overlap>
<ogr:overlap fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>2,-9 2,-13</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>NETWORK2</ogr:CLASS>
</ogr:overlap>
<ogr:overlap fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>6,-9 6,-13</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>NETWORK2</ogr:CLASS>
</ogr:overlap>
<ogr:overlap fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>8.8,-6 8.8,-8</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Long Road Name</ogr:NAME>
<ogr:CLASS>BENDOVER</ogr:CLASS>
</ogr:overlap>
<ogr:overlap fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>8,-6 8,-7 10,-7 10,-8</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Long Road Name</ogr:NAME>
<ogr:CLASS>BENDUNDER</ogr:CLASS>
</ogr:overlap>
<ogr:overlap fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>12.2,-6 12.2,-8</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Long Road Name</ogr:NAME>
<ogr:CLASS>BENDOVER</ogr:CLASS>
</ogr:overlap>
<ogr:overlap fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>11,-6 11,-7 13,-7 13,-8</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Long Road Name</ogr:NAME>
<ogr:CLASS>BENDUNDER</ogr:CLASS>
</ogr:overlap>
<ogr:overlap fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>12.2,-3.5 12.2,-5.5</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Long Road Name</ogr:NAME>
<ogr:CLASS>BENDOVER</ogr:CLASS>
</ogr:overlap>
<ogr:overlap fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>11,-4.5 13,-4.5</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Long Road Name</ogr:NAME>
<ogr:CLASS>BENDUNDER</ogr:CLASS>
</ogr:overlap>
</gml:featureMember>
</ogr:FeatureCollection>

View file

@ -1,36 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://ogr.maptools.org/" xmlns:ogr="http://ogr.maptools.org/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:gml="http://www.opengis.net/gml" elementFormDefault="qualified" version="1.0">
<xs:import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengeospatial.net/gml/2.1.2/feature.xsd"/><xs:element name="FeatureCollection" type="ogr:FeatureCollectionType" substitutionGroup="gml:_FeatureCollection"/>
<xs:complexType name="FeatureCollectionType">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureCollectionType">
<xs:attribute name="lockId" type="xs:string" use="optional"/>
<xs:attribute name="scope" type="xs:string" use="optional"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="overlap" type="ogr:overlap_Type" substitutionGroup="gml:_Feature"/>
<xs:complexType name="overlap_Type">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureType">
<xs:sequence>
<xs:element name="geometryProperty" type="gml:GeometryPropertyType" nillable="true" minOccurs="1" maxOccurs="1"/>
<xs:element name="NAME" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="60"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="CLASS" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="60"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>

View file

@ -1,25 +0,0 @@
<GMLFeatureClassList>
<GMLFeatureClass>
<Name>textspacing</Name>
<ElementPath>textspacing</ElementPath>
<DatasetSpecificInfo>
<FeatureCount>1</FeatureCount>
<ExtentXMin>1.00000</ExtentXMin>
<ExtentXMax>2.00000</ExtentXMax>
<ExtentYMin>1.00000</ExtentYMin>
<ExtentYMax>5.00000</ExtentYMax>
</DatasetSpecificInfo>
<PropertyDefn>
<Name>NAME</Name>
<ElementPath>NAME</ElementPath>
<Type>String</Type>
<Width>0</Width>
</PropertyDefn>
<PropertyDefn>
<Name>CLASS</Name>
<ElementPath>CLASS</ElementPath>
<Type>String</Type>
<Width>0</Width>
</PropertyDefn>
</GMLFeatureClass>
</GMLFeatureClassList>

View file

@ -1,117 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="textspacing.xsd"
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
<gml:Box>
<gml:coord><gml:X>0</gml:X><gml:Y>0</gml:Y></gml:coord>
<gml:coord><gml:X>13</gml:X><gml:Y>-13</gml:Y></gml:coord>
</gml:Box>
</gml:boundedBy>
<gml:featureMember>
<ogr:textspacing fid="F0">
<ogr:geometryProperty><gml:LineString><gml:coordinates>2,-1 1,-3 2,-5</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>TRIANGLE</ogr:CLASS>
</ogr:textspacing>
<ogr:textspacing fid="F1">
<ogr:geometryProperty><gml:LineString><gml:coordinates>3,-1 4,-3 3,-5</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>TRIANGLE</ogr:CLASS>
</ogr:textspacing>
<ogr:textspacing fid="F2">
<ogr:geometryProperty><gml:LineString><gml:coordinates>1,-7 2,-7</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>STRAIGHT</ogr:CLASS>
</ogr:textspacing>
<ogr:textspacing fid="F3">
<ogr:geometryProperty><gml:LineString><gml:coordinates>1,-8 3,-8</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>STRAIGHT</ogr:CLASS>
</ogr:textspacing>
<ogr:textspacing fid="F4">
<ogr:geometryProperty><gml:LineString><gml:coordinates>1,-9 4,-9</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>STRAIGHT</ogr:CLASS>
</ogr:textspacing>
<ogr:textspacing fid="F5">
<ogr:geometryProperty><gml:LineString><gml:coordinates>1,-10 5,-10</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>STRAIGHT</ogr:CLASS>
</ogr:textspacing>
<ogr:textspacing fid="F6">
<ogr:geometryProperty><gml:LineString><gml:coordinates>1,-11 7,-11</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>STRAIGHT</ogr:CLASS>
</ogr:textspacing>
<ogr:textspacing fid="F7">
<ogr:geometryProperty><gml:LineString><gml:coordinates>
1,-12 13,-12
</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>STRAIGHT</ogr:CLASS>
</ogr:textspacing>
<ogr:textspacing fid="F8">
<ogr:geometryProperty><gml:LineString><gml:coordinates>
1,-13 2,-13 5,-13 10,-13 13,-13
</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>STRAIGHT</ogr:CLASS>
</ogr:textspacing>
<ogr:textspacing fid="F9">
<ogr:geometryProperty><gml:LineString><gml:coordinates>6,-1 5,-3 5,-5</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>BEND</ogr:CLASS>
</ogr:textspacing>
<ogr:textspacing fid="F10">
<ogr:geometryProperty><gml:LineString><gml:coordinates>7,-1 8,-3 8,-5</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>BEND</ogr:CLASS>
</ogr:textspacing>
<ogr:textspacing fid="F11">
<ogr:geometryProperty><gml:LineString><gml:coordinates>5,-6 5,-8 6,-10</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>BEND</ogr:CLASS>
</ogr:textspacing>
<ogr:textspacing fid="F12">
<ogr:geometryProperty><gml:LineString><gml:coordinates>8,-6 8,-8 7,-10</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>BEND</ogr:CLASS>
</ogr:textspacing>
<ogr:textspacing fid="F13">
<ogr:geometryProperty><gml:LineString><gml:coordinates>10.055915,-1.00031738281 10.6649858,-1.077712483 11.274056,-1.26950068 11.77921,-1.55298308 12.191993,-1.92815928 12.51529,-2.369132 12.746218,-2.8329032 12.884774,-3.2968745 12.930959,-3.875339</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>CURVE</ogr:CLASS>
</ogr:textspacing>
<ogr:textspacing fid="F14">
<ogr:geometryProperty><gml:LineString><gml:coordinates>10.0555,-8.875339 10.6645708,-8.7979439 11.273641,-8.6061557 11.778795,-8.3226733 12.191578,-7.9474971 12.514875,-7.5065244 12.745803,-7.0427532 12.884359,-6.5787819 12.930544,-6.0003174</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>CURVE</ogr:CLASS>
</ogr:textspacing>
<ogr:textspacing fid="F15">
<ogr:geometryProperty><gml:LineString><gml:coordinates>
9.055915,-2.00031738281 9.6649858,-2.077712483 10.274056,-2.26950068 10.77921,-2.55298308 11.191993,-2.92815928 11.51529,-3.369132 11.746218,-3.8329032 11.884774,-4.2968745 11.930959,-4.875339
11.930544,-5.0003174 11.884359,-5.5787819 11.745803,-6.0427532 11.514875,-6.5065244 11.191578,-6.9474971 10.778795,-7.3226733 10.273641,-7.6061557 9.6645708,-7.7979439 9.0555,-7.875339
</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>CURVE</ogr:CLASS>
</ogr:textspacing>
<ogr:textspacing fid="F16">
<ogr:geometryProperty><gml:LineString><gml:coordinates>
9.0435048,-10.5550195 9.480786,-10.2191668 9.963148,-10.0731439 10.540222,-10.2495527 10.968444,-10.525815 11.419238,-10.8336443 12.01882,-10.9565825 12.559787,-10.7996079 12.956495,-10.4089966
</gml:coordinates></gml:LineString></ogr:geometryProperty>
<ogr:NAME>Road Name</ogr:NAME>
<ogr:CLASS>SQUIGGLE</ogr:CLASS>
</ogr:textspacing>
</gml:featureMember>
</ogr:FeatureCollection>

View file

@ -1,36 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://ogr.maptools.org/" xmlns:ogr="http://ogr.maptools.org/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:gml="http://www.opengis.net/gml" elementFormDefault="qualified" version="1.0">
<xs:import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengeospatial.net/gml/2.1.2/feature.xsd"/><xs:element name="FeatureCollection" type="ogr:FeatureCollectionType" substitutionGroup="gml:_FeatureCollection"/>
<xs:complexType name="FeatureCollectionType">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureCollectionType">
<xs:attribute name="lockId" type="xs:string" use="optional"/>
<xs:attribute name="scope" type="xs:string" use="optional"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:element name="textspacing" type="ogr:textspacing_Type" substitutionGroup="gml:_Feature"/>
<xs:complexType name="textspacing_Type">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureType">
<xs:sequence>
<xs:element name="geometryProperty" type="gml:GeometryPropertyType" nillable="true" minOccurs="1" maxOccurs="1"/>
<xs:element name="NAME" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="60"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="CLASS" nillable="true" minOccurs="0" maxOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="60"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>

View file

@ -1,3 +0,0 @@
These files are for testing various rendering parts of mapnik, they have been created by hand.
The raw files are in the raw/ folder (they were created with inkscape to assist!)
Run the regenerate.sh script to regenerate the shape files from the gml files, this requires ogr2ogr to run.

View file

@ -1,20 +0,0 @@
#!/bin/sh
rm -f textspacing.shp textspacing.shx textspacing.dbf
ogr2ogr -f "ESRI Shapefile" textspacing raw/textspacing.gml
mv textspacing/* ./
rmdir textspacing
rm -f overlap.shp overlap.shx overlap.dbf
ogr2ogr -f "ESRI Shapefile" overlap raw/overlap.gml
mv overlap/* ./
rmdir overlap
rm -f displacement.shp displacement.shx displacement.dbf
ogr2ogr -f "ESRI Shapefile" displacement raw/displacement.gml
mv displacement/* ./
rmdir displacement
rm -f charplacement.shp charplacement.shx charplacement.dbf
ogr2ogr -f "ESRI Shapefile" charplacement raw/charplacement.gml
mv charplacement/* ./
rmdir charplacement

View file

@ -19,15 +19,15 @@
// qt
#include <QApplication>
#include <QtWidgets/QApplication>
#include <QStringList>
#include <QSettings>
#include <mapnik/datasource_cache.hpp>
#include <mapnik/font_engine_freetype.hpp>
#include "mainwindow.hpp"
// boost
#include <boost/algorithm/string.hpp>
#include <boost/filesystem/operations.hpp>
int main( int argc, char **argv )

View file

@ -32,7 +32,10 @@
#include <QSlider>
#include <QComboBox>
#include <QDoubleSpinBox>
#include <QFileDialog>
#include <QMenu>
#include <QMenuBar>
#include <QToolBar>
// mapnik
#ifndef Q_MOC_RUN // QT moc chokes on BOOST_JOIN

View file

@ -22,7 +22,6 @@
#define MAINWINDOW_HPP
#include <QMainWindow>
#include <QPrinter>
#include <QList>
#include <QActionGroup>
#include <QStatusBar>
@ -78,7 +77,6 @@ private:
LayerTab *layerTab_;
StyleTab * styleTab_;
MapWidget * mapWidget_;
QPrinter printer;
//actions
QList<QAction *> exportAsActs;
QActionGroup *toolsGroup;

View file

@ -20,11 +20,12 @@
#include <QtGui>
#define BOOST_CHRONO_HEADER_ONLY
#include <boost/timer/timer.hpp>
#include <boost/bind.hpp>
#include <mapnik/agg_renderer.hpp>
#include <mapnik/graphics.hpp>
#include <mapnik/grid/grid_renderer.hpp>
#include <mapnik/layer.hpp>
#include <mapnik/projection.hpp>
#include <mapnik/scale_denominator.hpp>
@ -502,7 +503,10 @@ void render_agg(mapnik::Map const& map, double scaling_factor, QPixmap & pix)
try
{
ren.apply();
{
boost::timer::auto_cpu_timer t;
ren.apply();
}
QImage image((uchar*)buf.raw_data(),width,height,QImage::Format_ARGB32);
pix = QPixmap::fromImage(image.rgbSwapped());
}
@ -523,42 +527,7 @@ void render_agg(mapnik::Map const& map, double scaling_factor, QPixmap & pix)
void render_grid(mapnik::Map const& map, double scaling_factor, QPixmap & pix)
{
unsigned width=map.width();
unsigned height=map.height();
mapnik::grid buf(width,height,"F_CODE", 1);
mapnik::grid_renderer<mapnik::grid> ren(map,buf,scaling_factor);
try
{
ren.apply();
mapnik::value_integer * imdata = static_cast<mapnik::value_integer*>(buf.raw_data());
// Not sure how to display long long values ??
//QImage image(width,height,QImage::Format_RGB32);
//for (unsigned i = 0 ; i < height ; ++i)
//{
// for (unsigned j = 0 ; j < width ; ++j)
// {
// image.setPixel(j,i,qRgb((uint8_t)(imdata[i*width+j]>>8),
// (uint8_t)(imdata[i*width+j+1]>>8),
// (uint8_t)(imdata[i*width+j+2]>>8)));
// }
//}
//pix = QPixmap::fromImage(image);
}
catch (mapnik::config_error & ex)
{
std::cerr << ex.what() << std::endl;
}
catch (const std::exception & ex)
{
std::cerr << "exception: " << ex.what() << std::endl;
}
catch (...)
{
std::cerr << "Unknown exception caught!\n";
}
std::cerr << "Not supported" << std::endl;
}

View file

@ -2,11 +2,13 @@
# Mapnik viewer - Copyright (C) 2007 Artem Pavlenko
######################################################################
TEMPLATE = app
QT += core gui widgets
QMAKE_CXX = clang++
QMAKE_CXXFLAGS += $$system(mapnik-config --cflags)
QMAKE_CXXFLAGS += $$system(mapnik-config --cxxflags)
QMAKE_CXXFLAGS += $$system(mapnik-config --includes --dep-includes)
QMAKE_LFLAGS += $$system(mapnik-config --libs)
QMAKE_LFLAGS += $$system(mapnik-config --ldflags --dep-libs)
QMAKE_LFLAGS += -lboost_timer
# Input
CONFIG += qt debug_and_release
@ -19,17 +21,17 @@ HEADERS += mainwindow.hpp \
layerwidget.hpp \
layerlistmodel.hpp \
layerdelegate.hpp \
styles_model.hpp
styles_model.hpp
HEADERS += about_dialog.hpp \
info_dialog.hpp \
layer_info_dialog.hpp
SOURCES += main.cpp \
mainwindow.cpp \
mainwindow.cpp \
mapwidget.cpp \
layerwidget.cpp \
layerlistmodel.cpp \
layerlistmodel.cpp \
layerdelegate.cpp \
styles_model.cpp

View file

@ -19,7 +19,7 @@
#ifndef AGG_ALPHA_MASK_U8_INCLUDED
#define AGG_ALPHA_MASK_U8_INCLUDED
#include <string.h>
#include <cstring>
#include "agg_basics.h"
#include "agg_rendering_buffer.h"

View file

@ -20,7 +20,7 @@
#ifndef AGG_ARC_INCLUDED
#define AGG_ARC_INCLUDED
#include <math.h>
#include <cmath>
#include "agg_basics.h"
namespace agg

View file

@ -15,8 +15,8 @@
#ifndef AGG_ARRAY_INCLUDED
#define AGG_ARRAY_INCLUDED
#include <stddef.h>
#include <string.h>
#include <cstddef>
#include <cstring>
#include "agg_basics.h"
namespace agg

View file

@ -16,7 +16,7 @@
#ifndef AGG_BASICS_INCLUDED
#define AGG_BASICS_INCLUDED
#include <math.h>
#include <cmath>
#include "agg_config.h"
//---------------------------------------------------------AGG_CUSTOM_ALLOCATOR

View file

@ -24,7 +24,7 @@
#ifndef AGG_COLOR_RGBA_INCLUDED
#define AGG_COLOR_RGBA_INCLUDED
#include <math.h>
#include <cmath>
#include "agg_basics.h"
namespace agg

View file

@ -1,312 +1,295 @@
/*******************************************************************************
* *
* Author : Angus Johnson *
* Version : 1.1 *
* Date : 4 April 2011 *
* Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2011 *
* *
* License: *
* Use, modification & distribution is subject to Boost Software License Ver 1. *
* http://www.boost.org/LICENSE_1_0.txt *
* *
*******************************************************************************/
#ifndef AGG_CONV_CLIPPER_INCLUDED
#define AGG_CONV_CLIPPER_INCLUDED
#include <cmath>
#include "agg_basics.h"
#include "agg_array.h"
#include "clipper.hpp"
namespace agg
{
enum clipper_op_e { clipper_or,
clipper_and, clipper_xor, clipper_a_minus_b, clipper_b_minus_a };
enum clipper_PolyFillType {clipper_even_odd, clipper_non_zero, clipper_positive, clipper_negative};
template<class VSA, class VSB> class conv_clipper
{
enum status { status_move_to, status_line_to, status_stop };
typedef VSA source_a_type;
typedef VSB source_b_type;
typedef conv_clipper<source_a_type, source_b_type> self_type;
private:
source_a_type* m_src_a;
source_b_type* m_src_b;
status m_status;
int m_vertex;
int m_contour;
int m_scaling_factor;
clipper_op_e m_operation;
pod_bvector<ClipperLib::IntPoint, 8> m_vertex_accumulator;
ClipperLib::Polygons m_poly_a;
ClipperLib::Polygons m_poly_b;
ClipperLib::Polygons m_result;
ClipperLib::Clipper m_clipper;
clipper_PolyFillType m_subjFillType;
clipper_PolyFillType m_clipFillType;
int Round(double val)
{
if ((val < 0)) return (int)(val - 0.5); else return (int)(val + 0.5);
}
public:
conv_clipper(source_a_type &a, source_b_type &b,
clipper_op_e op = clipper_or,
clipper_PolyFillType subjFillType = clipper_even_odd,
clipper_PolyFillType clipFillType = clipper_even_odd,
int scaling_factor = 2) :
m_src_a(&a),
m_src_b(&b),
m_status(status_move_to),
m_vertex(-1),
m_contour(-1),
m_operation(op),
m_subjFillType(subjFillType),
m_clipFillType(clipFillType)
{
m_scaling_factor = std::max(std::min(scaling_factor, 6),0);
m_scaling_factor = Round(std::pow((double)10, m_scaling_factor));
}
conv_clipper(source_a_type &a,
clipper_op_e op = clipper_and,
clipper_PolyFillType subjFillType = clipper_non_zero,
clipper_PolyFillType clipFillType = clipper_non_zero,
int scaling_factor = 6) :
m_src_a(&a),
m_status(status_move_to),
m_vertex(-1),
m_contour(-1),
m_operation(op),
m_subjFillType(subjFillType),
m_clipFillType(clipFillType)
{
m_scaling_factor = std::max(std::min(scaling_factor, 6),0);
m_scaling_factor = Round(std::pow((double)10, m_scaling_factor));
}
~conv_clipper()
{
}
unsigned type() const { return m_src_a->type(); }
void attach1(VSA &source, clipper_PolyFillType subjFillType = clipper_even_odd)
{ m_src_a = &source; m_subjFillType = subjFillType; }
void attach2(VSB &source, clipper_PolyFillType clipFillType = clipper_even_odd)
{ m_src_b = &source; m_clipFillType = clipFillType; }
void operation(clipper_op_e v) { m_operation = v; }
void rewind(unsigned path_id);
unsigned vertex(double* x, double* y);
bool next_contour();
bool next_vertex(double* x, double* y);
void start_extracting();
void add_vertex_(double &x, double &y);
void end_contour(ClipperLib::Polygons &p);
template<class VS> void add(VS &src, ClipperLib::Polygons &p){
unsigned cmd;
double x; double y; double start_x; double start_y;
bool starting_first_line;
start_x = 0.0;
start_y = 0.0;
starting_first_line = true;
p.resize(0);
cmd = src->vertex( &x , &y );
while(!is_stop(cmd))
{
if(is_vertex(cmd))
{
if(is_move_to(cmd))
{
if(!starting_first_line ) end_contour(p);
start_x = x;
start_y = y;
}
add_vertex_( x, y );
starting_first_line = false;
}
else if(is_end_poly(cmd))
{
if(!starting_first_line && is_closed(cmd))
add_vertex_( start_x, start_y );
}
cmd = src->vertex( &x, &y );
}
end_contour(p);
}
};
//------------------------------------------------------------------------
template<class VSA, class VSB>
void conv_clipper<VSA, VSB>::start_extracting()
{
m_status = status_move_to;
m_contour = -1;
m_vertex = -1;
}
//------------------------------------------------------------------------------
template<class VSA, class VSB>
void conv_clipper<VSA, VSB>::rewind(unsigned path_id)
{
m_src_a->rewind( path_id );
m_src_b->rewind( path_id );
add( m_src_a , m_poly_a );
add( m_src_b , m_poly_b );
m_result.resize(0);
ClipperLib::PolyFillType pftSubj, pftClip;
switch (m_subjFillType)
{
case clipper_even_odd: pftSubj = ClipperLib::pftEvenOdd; break;
case clipper_non_zero: pftSubj = ClipperLib::pftNonZero; break;
case clipper_positive: pftSubj = ClipperLib::pftPositive; break;
default: pftSubj = ClipperLib::pftNegative;
}
switch (m_clipFillType)
{
case clipper_even_odd: pftClip = ClipperLib::pftEvenOdd; break;
case clipper_non_zero: pftClip = ClipperLib::pftNonZero; break;
case clipper_positive: pftClip = ClipperLib::pftPositive; break;
default: pftClip = ClipperLib::pftNegative;
}
m_clipper.Clear();
switch( m_operation ) {
case clipper_or:
{
m_clipper.AddPolygons( m_poly_a , ClipperLib::ptSubject );
m_clipper.AddPolygons( m_poly_b , ClipperLib::ptClip );
m_clipper.Execute( ClipperLib::ctUnion , m_result , pftSubj, pftClip);
break;
}
case clipper_and:
{
m_clipper.AddPolygons( m_poly_a , ClipperLib::ptSubject );
m_clipper.AddPolygons( m_poly_b , ClipperLib::ptClip );
m_clipper.Execute( ClipperLib::ctIntersection , m_result, pftSubj, pftClip );
break;
}
case clipper_xor:
{
m_clipper.AddPolygons( m_poly_a , ClipperLib::ptSubject );
m_clipper.AddPolygons( m_poly_b , ClipperLib::ptClip );
m_clipper.Execute( ClipperLib::ctXor , m_result, pftSubj, pftClip );
break;
}
case clipper_a_minus_b:
{
m_clipper.AddPolygons( m_poly_a , ClipperLib::ptSubject );
m_clipper.AddPolygons( m_poly_b , ClipperLib::ptClip );
m_clipper.Execute( ClipperLib::ctDifference , m_result, pftSubj, pftClip );
break;
}
case clipper_b_minus_a:
{
m_clipper.AddPolygons( m_poly_b , ClipperLib::ptSubject );
m_clipper.AddPolygons( m_poly_a , ClipperLib::ptClip );
m_clipper.Execute( ClipperLib::ctDifference , m_result, pftSubj, pftClip );
break;
}
}
start_extracting();
}
//------------------------------------------------------------------------------
template<class VSA, class VSB>
void conv_clipper<VSA, VSB>::end_contour( ClipperLib::Polygons &p)
{
unsigned i, len;
if( m_vertex_accumulator.size() < 3 ) return;
len = p.size();
p.resize(len+1);
p[len].resize(m_vertex_accumulator.size());
for( i = 0 ; i < m_vertex_accumulator.size() ; i++ )
p[len][i] = m_vertex_accumulator[i];
m_vertex_accumulator.remove_all();
}
//------------------------------------------------------------------------------
template<class VSA, class VSB>
void conv_clipper<VSA, VSB>::add_vertex_(double &x, double &y)
{
ClipperLib::IntPoint v;
v.X = Round(x * m_scaling_factor);
v.Y = Round(y * m_scaling_factor);
m_vertex_accumulator.add( v );
}
//------------------------------------------------------------------------------
template<class VSA, class VSB>
bool conv_clipper<VSA, VSB>::next_contour()
{
m_contour++;
if(m_contour >= (int)m_result.size()) return false;
m_vertex =-1;
return true;
}
//------------------------------------------------------------------------------
template<class VSA, class VSB>
bool conv_clipper<VSA, VSB>::next_vertex(double *x, double *y)
{
m_vertex++;
if(m_vertex >= (int)m_result[m_contour].size()) return false;
*x = (double)m_result[ m_contour ][ m_vertex ].X / m_scaling_factor;
*y = (double)m_result[ m_contour ][ m_vertex ].Y / m_scaling_factor;
return true;
}
//------------------------------------------------------------------------------
template<class VSA, class VSB>
unsigned conv_clipper<VSA, VSB>::vertex(double *x, double *y)
{
if( m_status == status_move_to )
{
if( next_contour() )
{
if( next_vertex( x, y ) )
{
m_status =status_line_to;
return path_cmd_move_to;
}
else
{
m_status = status_stop;
return path_cmd_end_poly | path_flags_close;
}
}
else
return path_cmd_stop;
}
else
{
if( next_vertex( x, y ) )
{
return path_cmd_line_to;
}
else
{
m_status = status_move_to;
return path_cmd_end_poly | path_flags_close;
}
}
}
//------------------------------------------------------------------------------
} //namespace agg
#endif //AGG_CONV_CLIPPER_INCLUDED
/*******************************************************************************
* *
* Author : Angus Johnson *
* Version : 1.1 *
* Date : 4 April 2011 *
* Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2011 *
* *
* License: *
* Use, modification & distribution is subject to Boost Software License Ver 1. *
* http://www.boost.org/LICENSE_1_0.txt *
* *
*******************************************************************************/
#ifndef AGG_CONV_CLIPPER_INCLUDED
#define AGG_CONV_CLIPPER_INCLUDED
#include <cmath>
#include "agg_basics.h"
#include "agg_array.h"
#include "clipper.hpp"
namespace agg
{
enum clipper_op_e { clipper_or,
clipper_and, clipper_xor, clipper_a_minus_b, clipper_b_minus_a };
enum clipper_PolyFillType {clipper_even_odd, clipper_non_zero, clipper_positive, clipper_negative};
template<class VSA, class VSB> class conv_clipper
{
enum status { status_move_to, status_line_to, status_stop };
typedef VSA source_a_type;
typedef VSB source_b_type;
typedef conv_clipper<source_a_type, source_b_type> self_type;
private:
source_a_type* m_src_a;
source_b_type* m_src_b;
status m_status;
int m_vertex;
int m_contour;
int m_scaling_factor;
clipper_op_e m_operation;
pod_bvector<ClipperLib::IntPoint, 8> m_vertex_accumulator;
ClipperLib::Polygons m_poly_a;
ClipperLib::Polygons m_poly_b;
ClipperLib::Polygons m_result;
ClipperLib::Clipper m_clipper;
clipper_PolyFillType m_subjFillType;
clipper_PolyFillType m_clipFillType;
int Round(double val)
{
if ((val < 0)) return (int)(val - 0.5); else return (int)(val + 0.5);
}
public:
conv_clipper(source_a_type &a, source_b_type &b,
clipper_op_e op = clipper_or,
clipper_PolyFillType subjFillType = clipper_even_odd,
clipper_PolyFillType clipFillType = clipper_even_odd,
int scaling_factor = 2) :
m_src_a(&a),
m_src_b(&b),
m_status(status_move_to),
m_vertex(-1),
m_contour(-1),
m_operation(op),
m_subjFillType(subjFillType),
m_clipFillType(clipFillType)
{
m_scaling_factor = std::max(std::min(scaling_factor, 6),0);
m_scaling_factor = Round(std::pow((double)10, m_scaling_factor));
}
~conv_clipper()
{
}
void attach1(VSA &source, clipper_PolyFillType subjFillType = clipper_even_odd)
{ m_src_a = &source; m_subjFillType = subjFillType; }
void attach2(VSB &source, clipper_PolyFillType clipFillType = clipper_even_odd)
{ m_src_b = &source; m_clipFillType = clipFillType; }
void operation(clipper_op_e v) { m_operation = v; }
void rewind(unsigned path_id);
unsigned vertex(double* x, double* y);
bool next_contour();
bool next_vertex(double* x, double* y);
void start_extracting();
void add_vertex_(double &x, double &y);
void end_contour(ClipperLib::Polygons &p);
template<class VS> void add(VS &src, ClipperLib::Polygons &p){
unsigned cmd;
double x; double y; double start_x; double start_y;
bool starting_first_line;
start_x = 0.0;
start_y = 0.0;
starting_first_line = true;
p.resize(0);
cmd = src->vertex( &x , &y );
while(!is_stop(cmd))
{
if(is_vertex(cmd))
{
if(is_move_to(cmd))
{
if(!starting_first_line ) end_contour(p);
start_x = x;
start_y = y;
}
add_vertex_( x, y );
starting_first_line = false;
}
else if(is_end_poly(cmd))
{
if(!starting_first_line && is_closed(cmd))
add_vertex_( start_x, start_y );
}
cmd = src->vertex( &x, &y );
}
end_contour(p);
}
};
//------------------------------------------------------------------------
template<class VSA, class VSB>
void conv_clipper<VSA, VSB>::start_extracting()
{
m_status = status_move_to;
m_contour = -1;
m_vertex = -1;
}
//------------------------------------------------------------------------------
template<class VSA, class VSB>
void conv_clipper<VSA, VSB>::rewind(unsigned path_id)
{
m_src_a->rewind( path_id );
m_src_b->rewind( path_id );
add( m_src_a , m_poly_a );
add( m_src_b , m_poly_b );
m_result.resize(0);
ClipperLib::PolyFillType pftSubj, pftClip;
switch (m_subjFillType)
{
case clipper_even_odd: pftSubj = ClipperLib::pftEvenOdd; break;
case clipper_non_zero: pftSubj = ClipperLib::pftNonZero; break;
case clipper_positive: pftSubj = ClipperLib::pftPositive; break;
default: pftSubj = ClipperLib::pftNegative;
}
switch (m_clipFillType)
{
case clipper_even_odd: pftClip = ClipperLib::pftEvenOdd; break;
case clipper_non_zero: pftClip = ClipperLib::pftNonZero; break;
case clipper_positive: pftClip = ClipperLib::pftPositive; break;
default: pftClip = ClipperLib::pftNegative;
}
m_clipper.Clear();
switch( m_operation ) {
case clipper_or:
{
m_clipper.AddPolygons( m_poly_a , ClipperLib::ptSubject );
m_clipper.AddPolygons( m_poly_b , ClipperLib::ptClip );
m_clipper.Execute( ClipperLib::ctUnion , m_result , pftSubj, pftClip);
break;
}
case clipper_and:
{
m_clipper.AddPolygons( m_poly_a , ClipperLib::ptSubject );
m_clipper.AddPolygons( m_poly_b , ClipperLib::ptClip );
m_clipper.Execute( ClipperLib::ctIntersection , m_result, pftSubj, pftClip );
break;
}
case clipper_xor:
{
m_clipper.AddPolygons( m_poly_a , ClipperLib::ptSubject );
m_clipper.AddPolygons( m_poly_b , ClipperLib::ptClip );
m_clipper.Execute( ClipperLib::ctXor , m_result, pftSubj, pftClip );
break;
}
case clipper_a_minus_b:
{
m_clipper.AddPolygons( m_poly_a , ClipperLib::ptSubject );
m_clipper.AddPolygons( m_poly_b , ClipperLib::ptClip );
m_clipper.Execute( ClipperLib::ctDifference , m_result, pftSubj, pftClip );
break;
}
case clipper_b_minus_a:
{
m_clipper.AddPolygons( m_poly_b , ClipperLib::ptSubject );
m_clipper.AddPolygons( m_poly_a , ClipperLib::ptClip );
m_clipper.Execute( ClipperLib::ctDifference , m_result, pftSubj, pftClip );
break;
}
}
start_extracting();
}
//------------------------------------------------------------------------------
template<class VSA, class VSB>
void conv_clipper<VSA, VSB>::end_contour( ClipperLib::Polygons &p)
{
unsigned i, len;
if( m_vertex_accumulator.size() < 3 ) return;
len = p.size();
p.resize(len+1);
p[len].resize(m_vertex_accumulator.size());
for( i = 0 ; i < m_vertex_accumulator.size() ; i++ )
p[len][i] = m_vertex_accumulator[i];
m_vertex_accumulator.remove_all();
}
//------------------------------------------------------------------------------
template<class VSA, class VSB>
void conv_clipper<VSA, VSB>::add_vertex_(double &x, double &y)
{
ClipperLib::IntPoint v;
v.X = Round(x * m_scaling_factor);
v.Y = Round(y * m_scaling_factor);
m_vertex_accumulator.add( v );
}
//------------------------------------------------------------------------------
template<class VSA, class VSB>
bool conv_clipper<VSA, VSB>::next_contour()
{
m_contour++;
if(m_contour >= (int)m_result.size()) return false;
m_vertex =-1;
return true;
}
//------------------------------------------------------------------------------
template<class VSA, class VSB>
bool conv_clipper<VSA, VSB>::next_vertex(double *x, double *y)
{
m_vertex++;
if(m_vertex >= (int)m_result[m_contour].size()) return false;
*x = (double)m_result[ m_contour ][ m_vertex ].X / m_scaling_factor;
*y = (double)m_result[ m_contour ][ m_vertex ].Y / m_scaling_factor;
return true;
}
//------------------------------------------------------------------------------
template<class VSA, class VSB>
unsigned conv_clipper<VSA, VSB>::vertex(double *x, double *y)
{
if( m_status == status_move_to )
{
if( next_contour() )
{
if( next_vertex( x, y ) )
{
m_status =status_line_to;
return path_cmd_move_to;
}
else
{
m_status = status_stop;
return path_cmd_end_poly | path_flags_close;
}
}
else
return path_cmd_stop;
}
else
{
if( next_vertex( x, y ) )
{
return path_cmd_line_to;
}
else
{
m_status = status_move_to;
return path_cmd_end_poly | path_flags_close;
}
}
}
//------------------------------------------------------------------------------
} //namespace agg
#endif //AGG_CONV_CLIPPER_INCLUDED

View file

@ -24,7 +24,7 @@
#ifndef AGG_CONV_GPC_INCLUDED
#define AGG_CONV_GPC_INCLUDED
#include <math.h>
#include <cmath>
#include "agg_basics.h"
#include "agg_array.h"

View file

@ -20,7 +20,7 @@
#ifndef AGG_DDA_LINE_INCLUDED
#define AGG_DDA_LINE_INCLUDED
#include <stdlib.h>
#include <cstdlib>
#include "agg_basics.h"
namespace agg

View file

@ -21,7 +21,7 @@
#define AGG_ELLIPSE_INCLUDED
#include "agg_basics.h"
#include <math.h>
#include <cmath>
namespace agg
{

View file

@ -16,7 +16,7 @@
#ifndef AGG_FONT_CACHE_MANAGER_INCLUDED
#define AGG_FONT_CACHE_MANAGER_INCLUDED
#include <string.h>
#include <cstring>
#include "agg_array.h"
namespace agg

View file

@ -2,8 +2,8 @@
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
@ -16,7 +16,7 @@
#ifndef AGG_GAMMA_FUNCTIONS_INCLUDED
#define AGG_GAMMA_FUNCTIONS_INCLUDED
#include <math.h>
#include <cmath>
#include "agg_basics.h"
namespace agg
@ -40,6 +40,7 @@ namespace agg
double operator() (double x) const
{
if (x == 0.0) return 0.0;
return pow(x, m_gamma);
}
@ -85,7 +86,11 @@ namespace agg
{
if(x < m_start) return 0.0;
if(x > m_end) return 1.0;
return (x - m_start) / (m_end - m_start);
double delta = m_end - m_start;
// avoid nan from potential zero division
// https://github.com/mapnik/mapnik/issues/761
if (delta <= 0.0) return 0.0;
return (x - m_start) / delta;
}
private:
@ -118,6 +123,3 @@ namespace agg
}
#endif

View file

@ -16,7 +16,7 @@
#ifndef AGG_GAMMA_LUT_INCLUDED
#define AGG_GAMMA_LUT_INCLUDED
#include <math.h>
#include <cmath>
#include "agg_basics.h"
namespace agg

View file

@ -16,7 +16,7 @@
#ifndef AGG_GLYPH_RASTER_BIN_INCLUDED
#define AGG_GLYPH_RASTER_BIN_INCLUDED
#include <string.h>
#include <cstring>
#include "agg_basics.h"
namespace agg

View file

@ -15,7 +15,7 @@
#ifndef AGG_LINE_AA_BASICS_INCLUDED
#define AGG_LINE_AA_BASICS_INCLUDED
#include <stdlib.h>
#include <cstdlib>
#include "agg_basics.h"
namespace agg

View file

@ -19,7 +19,7 @@
#ifndef AGG_MATH_INCLUDED
#define AGG_MATH_INCLUDED
#include <math.h>
#include <cmath>
#include "agg_basics.h"
namespace agg

View file

@ -16,8 +16,8 @@
#ifndef AGG_PATH_STORAGE_INCLUDED
#define AGG_PATH_STORAGE_INCLUDED
#include <string.h>
#include <math.h>
#include <cstring>
#include <cmath>
#include "agg_math.h"
#include "agg_array.h"
#include "agg_bezier_arc.h"

View file

@ -16,7 +16,7 @@
#ifndef AGG_PATH_STORAGE_INTEGER_INCLUDED
#define AGG_PATH_STORAGE_INTEGER_INCLUDED
#include <string.h>
#include <cstring>
#include "agg_array.h"
namespace agg

View file

@ -17,7 +17,7 @@
#define AGG_PIXFMT_AMASK_ADAPTOR_INCLUDED
#include <string.h>
#include <cstring>
#include "agg_array.h"
#include "agg_rendering_buffer.h"

View file

@ -24,7 +24,7 @@
#ifndef AGG_PIXFMT_GRAY_INCLUDED
#define AGG_PIXFMT_GRAY_INCLUDED
#include <string.h>
#include <cstring>
#include "agg_basics.h"
#include "agg_color_gray.h"
#include "agg_rendering_buffer.h"

View file

@ -24,7 +24,7 @@
#ifndef AGG_PIXFMT_RGB_INCLUDED
#define AGG_PIXFMT_RGB_INCLUDED
#include <string.h>
#include <cstring>
#include "agg_basics.h"
#include "agg_color_rgba.h"
#include "agg_rendering_buffer.h"

View file

@ -24,7 +24,7 @@
#ifndef AGG_PIXFMT_RGB_PACKED_INCLUDED
#define AGG_PIXFMT_RGB_PACKED_INCLUDED
#include <string.h>
#include <cstring>
#include "agg_basics.h"
#include "agg_color_rgba.h"
#include "agg_rendering_buffer.h"

View file

@ -25,8 +25,8 @@
#ifndef AGG_PIXFMT_RGBA_INCLUDED
#define AGG_PIXFMT_RGBA_INCLUDED
#include <string.h>
#include <math.h>
#include <cstring>
#include <cmath>
#include "agg_basics.h"
#include "agg_color_rgba.h"
#include "agg_rendering_buffer.h"
@ -134,7 +134,7 @@ namespace agg
static AGG_INLINE void blend_pix(value_type* p,
unsigned cr, unsigned cg, unsigned cb,
unsigned alpha,
unsigned cover=0)
unsigned /*cover*/=0)
{
calc_type r = p[Order::R];
calc_type g = p[Order::G];

View file

@ -29,7 +29,7 @@
#ifndef AGG_RASTERIZER_CELLS_AA_INCLUDED
#define AGG_RASTERIZER_CELLS_AA_INCLUDED
#include <string.h>
#include <cstring>
#include <cstdlib>
#include <limits>
#include "agg_math.h"

View file

@ -16,8 +16,8 @@
#ifndef AGG_SCANLINE_BOOLEAN_ALGEBRA_INCLUDED
#define AGG_SCANLINE_BOOLEAN_ALGEBRA_INCLUDED
#include <stdlib.h>
#include <math.h>
#include <cstdlib>
#include <cmath>
#include "agg_basics.h"

View file

@ -24,9 +24,9 @@
#ifndef AGG_SCANLINE_STORAGE_AA_INCLUDED
#define AGG_SCANLINE_STORAGE_AA_INCLUDED
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include "agg_array.h"

View file

@ -25,9 +25,9 @@
#ifndef AGG_SCANLINE_STORAGE_BIN_INCLUDED
#define AGG_SCANLINE_STORAGE_BIN_INCLUDED
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include "agg_array.h"

View file

@ -19,7 +19,7 @@
#ifndef AGG_SIMUL_EQ_INCLUDED
#define AGG_SIMUL_EQ_INCLUDED
#include <math.h>
#include <cmath>
#include "agg_basics.h"
namespace agg

View file

@ -16,9 +16,9 @@
#ifndef AGG_SPAN_GRADIENT_INCLUDED
#define AGG_SPAN_GRADIENT_INCLUDED
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include "agg_basics.h"
#include "agg_math.h"
#include "agg_array.h"

View file

@ -19,7 +19,7 @@
#ifndef AGG_TRANS_AFFINE_INCLUDED
#define AGG_TRANS_AFFINE_INCLUDED
#include <math.h>
#include <cmath>
#include "agg_basics.h"
namespace agg

View file

@ -16,7 +16,7 @@
#ifndef AGG_WARP_MAGNIFIER_INCLUDED
#define AGG_WARP_MAGNIFIER_INCLUDED
#include <math.h>
#include <cmath>
#include "agg_basics.h"

View file

@ -21,7 +21,7 @@
#ifndef AGG_TRANS_VIEWPORT_INCLUDED
#define AGG_TRANS_VIEWPORT_INCLUDED
#include <string.h>
#include <cstring>
#include "agg_trans_affine.h"

View file

@ -18,6 +18,9 @@
#include "agg_basics.h"
// https://github.com/mapnik/mapnik/issues/1860
#include <mapnik/config.hpp>
namespace agg
{
@ -25,7 +28,8 @@ namespace agg
//
// See Implementation agg_vpgen_clip_polygon.cpp
//
class vpgen_clip_polygon
class MAPNIK_DECL vpgen_clip_polygon
{
public:
vpgen_clip_polygon() :

View file

@ -18,6 +18,9 @@
#include "agg_basics.h"
// https://github.com/mapnik/mapnik/issues/1860
#include <mapnik/config.hpp>
namespace agg
{
@ -25,7 +28,7 @@ namespace agg
//
// See Implementation agg_vpgen_clip_polyline.cpp
//
class vpgen_clip_polyline
class MAPNIK_DECL vpgen_clip_polyline
{
public:
vpgen_clip_polyline() :

View file

@ -16,7 +16,7 @@
#ifndef AGG_VPGEN_SEGMENTATOR_INCLUDED
#define AGG_VPGEN_SEGMENTATOR_INCLUDED
#include <math.h>
#include <cmath>
#include "agg_basics.h"
namespace agg

View file

@ -2,8 +2,8 @@
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
@ -23,84 +23,84 @@
namespace agg
{
//------------------------------------------------------------------------
arc::arc(double x, double y,
double rx, double ry,
double a1, double a2,
bool ccw) :
m_x(x), m_y(y), m_rx(rx), m_ry(ry), m_scale(1.0)
//------------------------------------------------------------------------
arc::arc(double x, double y,
double rx, double ry,
double a1, double a2,
bool ccw) :
m_x(x), m_y(y), m_rx(rx), m_ry(ry), m_scale(1.0)
{
normalize(a1, a2, ccw);
}
//------------------------------------------------------------------------
void arc::init(double x, double y,
double rx, double ry,
double a1, double a2,
bool ccw)
{
m_x = x; m_y = y;
m_rx = rx; m_ry = ry;
normalize(a1, a2, ccw);
}
//------------------------------------------------------------------------
void arc::approximation_scale(double s)
{
m_scale = s;
if(m_initialized)
{
normalize(a1, a2, ccw);
normalize(m_start, m_end, m_ccw);
}
}
//------------------------------------------------------------------------
void arc::rewind(unsigned)
{
m_path_cmd = path_cmd_move_to;
m_angle = m_start;
}
//------------------------------------------------------------------------
unsigned arc::vertex(double* x, double* y)
{
if(is_stop(m_path_cmd)) return path_cmd_stop;
if((m_angle < m_end - m_da/4) != m_ccw)
{
*x = m_x + cos(m_end) * m_rx;
*y = m_y + sin(m_end) * m_ry;
m_path_cmd = path_cmd_stop;
return path_cmd_line_to;
}
//------------------------------------------------------------------------
void arc::init(double x, double y,
double rx, double ry,
double a1, double a2,
bool ccw)
*x = m_x + cos(m_angle) * m_rx;
*y = m_y + sin(m_angle) * m_ry;
m_angle += m_da;
unsigned pf = m_path_cmd;
m_path_cmd = path_cmd_line_to;
return pf;
}
//------------------------------------------------------------------------
void arc::normalize(double a1, double a2, bool ccw)
{
double ra = (fabs(m_rx) + fabs(m_ry)) / 2;
m_da = acos(ra / (ra + 0.125 / m_scale)) * 2;
if(ccw)
{
m_x = x; m_y = y;
m_rx = rx; m_ry = ry;
normalize(a1, a2, ccw);
while(a2 < a1) a2 += pi * 2.0;
}
//------------------------------------------------------------------------
void arc::approximation_scale(double s)
else
{
m_scale = s;
if(m_initialized)
{
normalize(m_start, m_end, m_ccw);
}
}
//------------------------------------------------------------------------
void arc::rewind(unsigned)
{
m_path_cmd = path_cmd_move_to;
m_angle = m_start;
}
//------------------------------------------------------------------------
unsigned arc::vertex(double* x, double* y)
{
if(is_stop(m_path_cmd)) return path_cmd_stop;
if((m_angle < m_end - m_da/4) != m_ccw)
{
*x = m_x + cos(m_end) * m_rx;
*y = m_y + sin(m_end) * m_ry;
m_path_cmd = path_cmd_stop;
return path_cmd_line_to;
}
*x = m_x + cos(m_angle) * m_rx;
*y = m_y + sin(m_angle) * m_ry;
m_angle += m_da;
unsigned pf = m_path_cmd;
m_path_cmd = path_cmd_line_to;
return pf;
}
//------------------------------------------------------------------------
void arc::normalize(double a1, double a2, bool ccw)
{
double ra = (fabs(m_rx) + fabs(m_ry)) / 2;
m_da = acos(ra / (ra + 0.125 / m_scale)) * 2;
if(ccw)
{
while(a2 < a1) a2 += pi * 2.0;
}
else
{
while(a1 < a2) a1 += pi * 2.0;
m_da = -m_da;
}
m_ccw = ccw;
m_start = a1;
m_end = a2;
m_initialized = true;
while(a1 < a2) a1 += pi * 2.0;
m_da = -m_da;
}
m_ccw = ccw;
m_start = a1;
m_end = a2;
m_initialized = true;
}
}

View file

@ -2,8 +2,8 @@
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
@ -13,7 +13,7 @@
// http://www.antigrain.com
//----------------------------------------------------------------------------
//
// Simple arrowhead/arrowtail generator
// Simple arrowhead/arrowtail generator
//
//----------------------------------------------------------------------------
@ -22,89 +22,89 @@
namespace agg
{
//------------------------------------------------------------------------
arrowhead::arrowhead() :
m_head_d1(1.0),
m_head_d2(1.0),
m_head_d3(1.0),
m_head_d4(0.0),
m_tail_d1(1.0),
m_tail_d2(1.0),
m_tail_d3(1.0),
m_tail_d4(0.0),
m_head_flag(false),
m_tail_flag(false),
m_curr_id(0),
m_curr_coord(0)
//------------------------------------------------------------------------
arrowhead::arrowhead() :
m_head_d1(1.0),
m_head_d2(1.0),
m_head_d3(1.0),
m_head_d4(0.0),
m_tail_d1(1.0),
m_tail_d2(1.0),
m_tail_d3(1.0),
m_tail_d4(0.0),
m_head_flag(false),
m_tail_flag(false),
m_curr_id(0),
m_curr_coord(0)
{
}
//------------------------------------------------------------------------
void arrowhead::rewind(unsigned path_id)
{
m_curr_id = path_id;
m_curr_coord = 0;
if(path_id == 0)
{
}
//------------------------------------------------------------------------
void arrowhead::rewind(unsigned path_id)
{
m_curr_id = path_id;
m_curr_coord = 0;
if(path_id == 0)
if(!m_tail_flag)
{
if(!m_tail_flag)
{
m_cmd[0] = path_cmd_stop;
return;
}
m_coord[0] = m_tail_d1; m_coord[1] = 0.0;
m_coord[2] = m_tail_d1 - m_tail_d4; m_coord[3] = m_tail_d3;
m_coord[4] = -m_tail_d2 - m_tail_d4; m_coord[5] = m_tail_d3;
m_coord[6] = -m_tail_d2; m_coord[7] = 0.0;
m_coord[8] = -m_tail_d2 - m_tail_d4; m_coord[9] = -m_tail_d3;
m_coord[10] = m_tail_d1 - m_tail_d4; m_coord[11] = -m_tail_d3;
m_cmd[0] = path_cmd_move_to;
m_cmd[1] = path_cmd_line_to;
m_cmd[2] = path_cmd_line_to;
m_cmd[3] = path_cmd_line_to;
m_cmd[4] = path_cmd_line_to;
m_cmd[5] = path_cmd_line_to;
m_cmd[7] = path_cmd_end_poly | path_flags_close | path_flags_ccw;
m_cmd[6] = path_cmd_stop;
m_cmd[0] = path_cmd_stop;
return;
}
m_coord[0] = m_tail_d1; m_coord[1] = 0.0;
m_coord[2] = m_tail_d1 - m_tail_d4; m_coord[3] = m_tail_d3;
m_coord[4] = -m_tail_d2 - m_tail_d4; m_coord[5] = m_tail_d3;
m_coord[6] = -m_tail_d2; m_coord[7] = 0.0;
m_coord[8] = -m_tail_d2 - m_tail_d4; m_coord[9] = -m_tail_d3;
m_coord[10] = m_tail_d1 - m_tail_d4; m_coord[11] = -m_tail_d3;
if(path_id == 1)
m_cmd[0] = path_cmd_move_to;
m_cmd[1] = path_cmd_line_to;
m_cmd[2] = path_cmd_line_to;
m_cmd[3] = path_cmd_line_to;
m_cmd[4] = path_cmd_line_to;
m_cmd[5] = path_cmd_line_to;
m_cmd[7] = path_cmd_end_poly | path_flags_close | path_flags_ccw;
m_cmd[6] = path_cmd_stop;
return;
}
if(path_id == 1)
{
if(!m_head_flag)
{
if(!m_head_flag)
{
m_cmd[0] = path_cmd_stop;
return;
}
m_coord[0] = -m_head_d1; m_coord[1] = 0.0;
m_coord[2] = m_head_d2 + m_head_d4; m_coord[3] = -m_head_d3;
m_coord[4] = m_head_d2; m_coord[5] = 0.0;
m_coord[6] = m_head_d2 + m_head_d4; m_coord[7] = m_head_d3;
m_cmd[0] = path_cmd_move_to;
m_cmd[1] = path_cmd_line_to;
m_cmd[2] = path_cmd_line_to;
m_cmd[3] = path_cmd_line_to;
m_cmd[4] = path_cmd_end_poly | path_flags_close | path_flags_ccw;
m_cmd[5] = path_cmd_stop;
m_cmd[0] = path_cmd_stop;
return;
}
m_coord[0] = -m_head_d1; m_coord[1] = 0.0;
m_coord[2] = m_head_d2 + m_head_d4; m_coord[3] = -m_head_d3;
m_coord[4] = m_head_d2; m_coord[5] = 0.0;
m_coord[6] = m_head_d2 + m_head_d4; m_coord[7] = m_head_d3;
m_cmd[0] = path_cmd_move_to;
m_cmd[1] = path_cmd_line_to;
m_cmd[2] = path_cmd_line_to;
m_cmd[3] = path_cmd_line_to;
m_cmd[4] = path_cmd_end_poly | path_flags_close | path_flags_ccw;
m_cmd[5] = path_cmd_stop;
return;
}
}
//------------------------------------------------------------------------
unsigned arrowhead::vertex(double* x, double* y)
//------------------------------------------------------------------------
unsigned arrowhead::vertex(double* x, double* y)
{
if(m_curr_id < 2)
{
if(m_curr_id < 2)
{
unsigned curr_idx = m_curr_coord * 2;
*x = m_coord[curr_idx];
*y = m_coord[curr_idx + 1];
return m_cmd[m_curr_coord++];
}
return path_cmd_stop;
unsigned curr_idx = m_curr_coord * 2;
*x = m_coord[curr_idx];
*y = m_coord[curr_idx + 1];
return m_cmd[m_curr_coord++];
}
return path_cmd_stop;
}
}

View file

@ -2,8 +2,8 @@
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
@ -13,7 +13,7 @@
// http://www.antigrain.com
//----------------------------------------------------------------------------
//
// Arc generator. Produces at most 4 consecutive cubic bezier curves, i.e.,
// Arc generator. Produces at most 4 consecutive cubic bezier curves, i.e.,
// 4, 7, 10, or 13 vertices.
//
//----------------------------------------------------------------------------
@ -26,233 +26,233 @@
namespace agg
{
// This epsilon is used to prevent us from adding degenerate curves
// (converging to a single point).
// The value isn't very critical. Function arc_to_bezier() has a limit
// of the sweep_angle. If fabs(sweep_angle) exceeds pi/2 the curve
// becomes inaccurate. But slight exceeding is quite appropriate.
//-------------------------------------------------bezier_arc_angle_epsilon
const double bezier_arc_angle_epsilon = 0.01;
// This epsilon is used to prevent us from adding degenerate curves
// (converging to a single point).
// The value isn't very critical. Function arc_to_bezier() has a limit
// of the sweep_angle. If fabs(sweep_angle) exceeds pi/2 the curve
// becomes inaccurate. But slight exceeding is quite appropriate.
//-------------------------------------------------bezier_arc_angle_epsilon
const double bezier_arc_angle_epsilon = 0.01;
//------------------------------------------------------------arc_to_bezier
void arc_to_bezier(double cx, double cy, double rx, double ry,
double start_angle, double sweep_angle,
double* curve)
//------------------------------------------------------------arc_to_bezier
void arc_to_bezier(double cx, double cy, double rx, double ry,
double start_angle, double sweep_angle,
double* curve)
{
double x0 = cos(sweep_angle / 2.0);
double y0 = sin(sweep_angle / 2.0);
double tx = (1.0 - x0) * 4.0 / 3.0;
double ty = y0 - tx * x0 / y0;
double px[4];
double py[4];
px[0] = x0;
py[0] = -y0;
px[1] = x0 + tx;
py[1] = -ty;
px[2] = x0 + tx;
py[2] = ty;
px[3] = x0;
py[3] = y0;
double sn = sin(start_angle + sweep_angle / 2.0);
double cs = cos(start_angle + sweep_angle / 2.0);
unsigned i;
for(i = 0; i < 4; i++)
{
double x0 = cos(sweep_angle / 2.0);
double y0 = sin(sweep_angle / 2.0);
double tx = (1.0 - x0) * 4.0 / 3.0;
double ty = y0 - tx * x0 / y0;
double px[4];
double py[4];
px[0] = x0;
py[0] = -y0;
px[1] = x0 + tx;
py[1] = -ty;
px[2] = x0 + tx;
py[2] = ty;
px[3] = x0;
py[3] = y0;
curve[i * 2] = cx + rx * (px[i] * cs - py[i] * sn);
curve[i * 2 + 1] = cy + ry * (px[i] * sn + py[i] * cs);
}
}
double sn = sin(start_angle + sweep_angle / 2.0);
double cs = cos(start_angle + sweep_angle / 2.0);
unsigned i;
for(i = 0; i < 4; i++)
{
curve[i * 2] = cx + rx * (px[i] * cs - py[i] * sn);
curve[i * 2 + 1] = cy + ry * (px[i] * sn + py[i] * cs);
}
//------------------------------------------------------------------------
void bezier_arc::init(double x, double y,
double rx, double ry,
double start_angle,
double sweep_angle)
{
start_angle = fmod(start_angle, 2.0 * pi);
if(sweep_angle >= 2.0 * pi) sweep_angle = 2.0 * pi;
if(sweep_angle <= -2.0 * pi) sweep_angle = -2.0 * pi;
if(fabs(sweep_angle) < 1e-10)
{
m_num_vertices = 4;
m_cmd = path_cmd_line_to;
m_vertices[0] = x + rx * cos(start_angle);
m_vertices[1] = y + ry * sin(start_angle);
m_vertices[2] = x + rx * cos(start_angle + sweep_angle);
m_vertices[3] = y + ry * sin(start_angle + sweep_angle);
return;
}
//------------------------------------------------------------------------
void bezier_arc::init(double x, double y,
double rx, double ry,
double start_angle,
double sweep_angle)
double total_sweep = 0.0;
double local_sweep = 0.0;
double prev_sweep;
m_num_vertices = 2;
m_cmd = path_cmd_curve4;
bool done = false;
do
{
start_angle = fmod(start_angle, 2.0 * pi);
if(sweep_angle >= 2.0 * pi) sweep_angle = 2.0 * pi;
if(sweep_angle <= -2.0 * pi) sweep_angle = -2.0 * pi;
if(fabs(sweep_angle) < 1e-10)
if(sweep_angle < 0.0)
{
m_num_vertices = 4;
m_cmd = path_cmd_line_to;
m_vertices[0] = x + rx * cos(start_angle);
m_vertices[1] = y + ry * sin(start_angle);
m_vertices[2] = x + rx * cos(start_angle + sweep_angle);
m_vertices[3] = y + ry * sin(start_angle + sweep_angle);
return;
prev_sweep = total_sweep;
local_sweep = -pi * 0.5;
total_sweep -= pi * 0.5;
if(total_sweep <= sweep_angle + bezier_arc_angle_epsilon)
{
local_sweep = sweep_angle - prev_sweep;
done = true;
}
}
else
{
prev_sweep = total_sweep;
local_sweep = pi * 0.5;
total_sweep += pi * 0.5;
if(total_sweep >= sweep_angle - bezier_arc_angle_epsilon)
{
local_sweep = sweep_angle - prev_sweep;
done = true;
}
}
double total_sweep = 0.0;
double local_sweep = 0.0;
double prev_sweep;
m_num_vertices = 2;
m_cmd = path_cmd_curve4;
bool done = false;
do
{
if(sweep_angle < 0.0)
{
prev_sweep = total_sweep;
local_sweep = -pi * 0.5;
total_sweep -= pi * 0.5;
if(total_sweep <= sweep_angle + bezier_arc_angle_epsilon)
{
local_sweep = sweep_angle - prev_sweep;
done = true;
}
}
else
{
prev_sweep = total_sweep;
local_sweep = pi * 0.5;
total_sweep += pi * 0.5;
if(total_sweep >= sweep_angle - bezier_arc_angle_epsilon)
{
local_sweep = sweep_angle - prev_sweep;
done = true;
}
}
arc_to_bezier(x, y, rx, ry,
start_angle,
local_sweep,
m_vertices + m_num_vertices - 2);
arc_to_bezier(x, y, rx, ry,
start_angle,
local_sweep,
m_vertices + m_num_vertices - 2);
m_num_vertices += 6;
start_angle += local_sweep;
}
while(!done && m_num_vertices < 26);
}
m_num_vertices += 6;
start_angle += local_sweep;
}
while(!done && m_num_vertices < 26);
//--------------------------------------------------------------------
void bezier_arc_svg::init(double x0, double y0,
double rx, double ry,
double angle,
bool large_arc_flag,
bool sweep_flag,
double x2, double y2)
{
m_radii_ok = true;
if(rx < 0.0) rx = -rx;
if(ry < 0.0) ry = -rx;
// Calculate the middle point between
// the current and the final points
//------------------------
double dx2 = (x0 - x2) / 2.0;
double dy2 = (y0 - y2) / 2.0;
double cos_a = cos(angle);
double sin_a = sin(angle);
// Calculate (x1, y1)
//------------------------
double x1 = cos_a * dx2 + sin_a * dy2;
double y1 = -sin_a * dx2 + cos_a * dy2;
// Ensure radii are large enough
//------------------------
double prx = rx * rx;
double pry = ry * ry;
double px1 = x1 * x1;
double py1 = y1 * y1;
// Check that radii are large enough
//------------------------
double radii_check = px1/prx + py1/pry;
if(radii_check > 1.0)
{
rx = sqrt(radii_check) * rx;
ry = sqrt(radii_check) * ry;
prx = rx * rx;
pry = ry * ry;
if(radii_check > 10.0) m_radii_ok = false;
}
// Calculate (cx1, cy1)
//------------------------
double sign = (large_arc_flag == sweep_flag) ? -1.0 : 1.0;
double sq = (prx*pry - prx*py1 - pry*px1) / (prx*py1 + pry*px1);
double coef = sign * sqrt((sq < 0) ? 0 : sq);
double cx1 = coef * ((rx * y1) / ry);
double cy1 = coef * -((ry * x1) / rx);
//
// Calculate (cx, cy) from (cx1, cy1)
//------------------------
double sx2 = (x0 + x2) / 2.0;
double sy2 = (y0 + y2) / 2.0;
double cx = sx2 + (cos_a * cx1 - sin_a * cy1);
double cy = sy2 + (sin_a * cx1 + cos_a * cy1);
// Calculate the start_angle (angle1) and the sweep_angle (dangle)
//------------------------
double ux = (x1 - cx1) / rx;
double uy = (y1 - cy1) / ry;
double vx = (-x1 - cx1) / rx;
double vy = (-y1 - cy1) / ry;
double p, n;
//--------------------------------------------------------------------
void bezier_arc_svg::init(double x0, double y0,
double rx, double ry,
double angle,
bool large_arc_flag,
bool sweep_flag,
double x2, double y2)
// Calculate the angle start
//------------------------
n = sqrt(ux*ux + uy*uy);
p = ux; // (1 * ux) + (0 * uy)
sign = (uy < 0) ? -1.0 : 1.0;
double v = p / n;
if(v < -1.0) v = -1.0;
if(v > 1.0) v = 1.0;
double start_angle = sign * acos(v);
// Calculate the sweep angle
//------------------------
n = sqrt((ux*ux + uy*uy) * (vx*vx + vy*vy));
p = ux * vx + uy * vy;
sign = (ux * vy - uy * vx < 0) ? -1.0 : 1.0;
v = p / n;
if(v < -1.0) v = -1.0;
if(v > 1.0) v = 1.0;
double sweep_angle = sign * acos(v);
if(!sweep_flag && sweep_angle > 0)
{
m_radii_ok = true;
if(rx < 0.0) rx = -rx;
if(ry < 0.0) ry = -rx;
// Calculate the middle point between
// the current and the final points
//------------------------
double dx2 = (x0 - x2) / 2.0;
double dy2 = (y0 - y2) / 2.0;
double cos_a = cos(angle);
double sin_a = sin(angle);
// Calculate (x1, y1)
//------------------------
double x1 = cos_a * dx2 + sin_a * dy2;
double y1 = -sin_a * dx2 + cos_a * dy2;
// Ensure radii are large enough
//------------------------
double prx = rx * rx;
double pry = ry * ry;
double px1 = x1 * x1;
double py1 = y1 * y1;
// Check that radii are large enough
//------------------------
double radii_check = px1/prx + py1/pry;
if(radii_check > 1.0)
{
rx = sqrt(radii_check) * rx;
ry = sqrt(radii_check) * ry;
prx = rx * rx;
pry = ry * ry;
if(radii_check > 10.0) m_radii_ok = false;
}
// Calculate (cx1, cy1)
//------------------------
double sign = (large_arc_flag == sweep_flag) ? -1.0 : 1.0;
double sq = (prx*pry - prx*py1 - pry*px1) / (prx*py1 + pry*px1);
double coef = sign * sqrt((sq < 0) ? 0 : sq);
double cx1 = coef * ((rx * y1) / ry);
double cy1 = coef * -((ry * x1) / rx);
//
// Calculate (cx, cy) from (cx1, cy1)
//------------------------
double sx2 = (x0 + x2) / 2.0;
double sy2 = (y0 + y2) / 2.0;
double cx = sx2 + (cos_a * cx1 - sin_a * cy1);
double cy = sy2 + (sin_a * cx1 + cos_a * cy1);
// Calculate the start_angle (angle1) and the sweep_angle (dangle)
//------------------------
double ux = (x1 - cx1) / rx;
double uy = (y1 - cy1) / ry;
double vx = (-x1 - cx1) / rx;
double vy = (-y1 - cy1) / ry;
double p, n;
// Calculate the angle start
//------------------------
n = sqrt(ux*ux + uy*uy);
p = ux; // (1 * ux) + (0 * uy)
sign = (uy < 0) ? -1.0 : 1.0;
double v = p / n;
if(v < -1.0) v = -1.0;
if(v > 1.0) v = 1.0;
double start_angle = sign * acos(v);
// Calculate the sweep angle
//------------------------
n = sqrt((ux*ux + uy*uy) * (vx*vx + vy*vy));
p = ux * vx + uy * vy;
sign = (ux * vy - uy * vx < 0) ? -1.0 : 1.0;
v = p / n;
if(v < -1.0) v = -1.0;
if(v > 1.0) v = 1.0;
double sweep_angle = sign * acos(v);
if(!sweep_flag && sweep_angle > 0)
{
sweep_angle -= pi * 2.0;
}
else
if (sweep_flag && sweep_angle < 0)
sweep_angle -= pi * 2.0;
}
else
if (sweep_flag && sweep_angle < 0)
{
sweep_angle += pi * 2.0;
}
// We can now build and transform the resulting arc
//------------------------
m_arc.init(0.0, 0.0, rx, ry, start_angle, sweep_angle);
trans_affine mtx = trans_affine_rotation(angle);
mtx *= trans_affine_translation(cx, cy);
for(unsigned i = 2; i < m_arc.num_vertices()-2; i += 2)
{
mtx.transform(m_arc.vertices() + i, m_arc.vertices() + i + 1);
}
// We can now build and transform the resulting arc
//------------------------
m_arc.init(0.0, 0.0, rx, ry, start_angle, sweep_angle);
trans_affine mtx = trans_affine_rotation(angle);
mtx *= trans_affine_translation(cx, cy);
// We must make sure that the starting and ending points
// exactly coincide with the initial (x0,y0) and (x2,y2)
m_arc.vertices()[0] = x0;
m_arc.vertices()[1] = y0;
if(m_arc.num_vertices() > 2)
{
m_arc.vertices()[m_arc.num_vertices() - 2] = x2;
m_arc.vertices()[m_arc.num_vertices() - 1] = y2;
}
for(unsigned i = 2; i < m_arc.num_vertices()-2; i += 2)
{
mtx.transform(m_arc.vertices() + i, m_arc.vertices() + i + 1);
}
// We must make sure that the starting and ending points
// exactly coincide with the initial (x0,y0) and (x2,y2)
m_arc.vertices()[0] = x0;
m_arc.vertices()[1] = y0;
if(m_arc.num_vertices() > 2)
{
m_arc.vertices()[m_arc.num_vertices() - 2] = x2;
m_arc.vertices()[m_arc.num_vertices() - 1] = y2;
}
}
}

View file

@ -2,8 +2,8 @@
// Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
//
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose.
//
@ -21,242 +21,242 @@
namespace agg
{
//------------------------------------------------------------------------
bspline::bspline() :
m_max(0),
m_num(0),
m_x(0),
m_y(0),
m_last_idx(-1)
{
}
//------------------------------------------------------------------------
bspline::bspline() :
m_max(0),
m_num(0),
m_x(0),
m_y(0),
m_last_idx(-1)
{
}
//------------------------------------------------------------------------
bspline::bspline(int num) :
m_max(0),
m_num(0),
m_x(0),
m_y(0),
m_last_idx(-1)
//------------------------------------------------------------------------
bspline::bspline(int num) :
m_max(0),
m_num(0),
m_x(0),
m_y(0),
m_last_idx(-1)
{
init(num);
}
//------------------------------------------------------------------------
bspline::bspline(int num, const double* x, const double* y) :
m_max(0),
m_num(0),
m_x(0),
m_y(0),
m_last_idx(-1)
{
init(num, x, y);
}
//------------------------------------------------------------------------
void bspline::init(int max)
{
if(max > 2 && max > m_max)
{
m_am.resize(max * 3);
m_max = max;
m_x = &m_am[m_max];
m_y = &m_am[m_max * 2];
}
m_num = 0;
m_last_idx = -1;
}
//------------------------------------------------------------------------
void bspline::add_point(double x, double y)
{
if(m_num < m_max)
{
m_x[m_num] = x;
m_y[m_num] = y;
++m_num;
}
}
//------------------------------------------------------------------------
void bspline::prepare()
{
if(m_num > 2)
{
int i, k, n1;
double* temp;
double* r;
double* s;
double h, p, d, f, e;
for(k = 0; k < m_num; k++)
{
m_am[k] = 0.0;
}
n1 = 3 * m_num;
pod_array<double> al(n1);
temp = &al[0];
for(k = 0; k < n1; k++)
{
temp[k] = 0.0;
}
r = temp + m_num;
s = temp + m_num * 2;
n1 = m_num - 1;
d = m_x[1] - m_x[0];
e = (m_y[1] - m_y[0]) / d;
for(k = 1; k < n1; k++)
{
h = d;
d = m_x[k + 1] - m_x[k];
f = e;
e = (m_y[k + 1] - m_y[k]) / d;
al[k] = d / (d + h);
r[k] = 1.0 - al[k];
s[k] = 6.0 * (e - f) / (h + d);
}
for(k = 1; k < n1; k++)
{
p = 1.0 / (r[k] * al[k - 1] + 2.0);
al[k] *= -p;
s[k] = (s[k] - r[k] * s[k - 1]) * p;
}
m_am[n1] = 0.0;
al[n1 - 1] = s[n1 - 1];
m_am[n1 - 1] = al[n1 - 1];
for(k = n1 - 2, i = 0; i < m_num - 2; i++, k--)
{
al[k] = al[k] * al[k + 1] + s[k];
m_am[k] = al[k];
}
}
m_last_idx = -1;
}
//------------------------------------------------------------------------
void bspline::init(int num, const double* x, const double* y)
{
if(num > 2)
{
init(num);
}
//------------------------------------------------------------------------
bspline::bspline(int num, const double* x, const double* y) :
m_max(0),
m_num(0),
m_x(0),
m_y(0),
m_last_idx(-1)
{
init(num, x, y);
}
//------------------------------------------------------------------------
void bspline::init(int max)
{
if(max > 2 && max > m_max)
int i;
for(i = 0; i < num; i++)
{
m_am.resize(max * 3);
m_max = max;
m_x = &m_am[m_max];
m_y = &m_am[m_max * 2];
add_point(*x++, *y++);
}
m_num = 0;
m_last_idx = -1;
prepare();
}
m_last_idx = -1;
}
//------------------------------------------------------------------------
void bspline::add_point(double x, double y)
//------------------------------------------------------------------------
void bspline::bsearch(int n, const double *x, double x0, int *i)
{
int j = n - 1;
int k;
for(*i = 0; (j - *i) > 1; )
{
if(m_num < m_max)
if(x0 < x[k = (*i + j) >> 1]) j = k;
else *i = k;
}
}
//------------------------------------------------------------------------
double bspline::interpolation(double x, int i) const
{
int j = i + 1;
double d = m_x[i] - m_x[j];
double h = x - m_x[j];
double r = m_x[i] - x;
double p = d * d / 6.0;
return (m_am[j] * r * r * r + m_am[i] * h * h * h) / 6.0 / d +
((m_y[j] - m_am[j] * p) * r + (m_y[i] - m_am[i] * p) * h) / d;
}
//------------------------------------------------------------------------
double bspline::extrapolation_left(double x) const
{
double d = m_x[1] - m_x[0];
return (-d * m_am[1] / 6 + (m_y[1] - m_y[0]) / d) *
(x - m_x[0]) +
m_y[0];
}
//------------------------------------------------------------------------
double bspline::extrapolation_right(double x) const
{
double d = m_x[m_num - 1] - m_x[m_num - 2];
return (d * m_am[m_num - 2] / 6 + (m_y[m_num - 1] - m_y[m_num - 2]) / d) *
(x - m_x[m_num - 1]) +
m_y[m_num - 1];
}
//------------------------------------------------------------------------
double bspline::get(double x) const
{
if(m_num > 2)
{
int i;
// Extrapolation on the left
if(x < m_x[0]) return extrapolation_left(x);
// Extrapolation on the right
if(x >= m_x[m_num - 1]) return extrapolation_right(x);
// Interpolation
bsearch(m_num, m_x, x, &i);
return interpolation(x, i);
}
return 0.0;
}
//------------------------------------------------------------------------
double bspline::get_stateful(double x) const
{
if(m_num > 2)
{
// Extrapolation on the left
if(x < m_x[0]) return extrapolation_left(x);
// Extrapolation on the right
if(x >= m_x[m_num - 1]) return extrapolation_right(x);
if(m_last_idx >= 0)
{
m_x[m_num] = x;
m_y[m_num] = y;
++m_num;
}
}
//------------------------------------------------------------------------
void bspline::prepare()
{
if(m_num > 2)
{
int i, k, n1;
double* temp;
double* r;
double* s;
double h, p, d, f, e;
for(k = 0; k < m_num; k++)
// Check if x is not in current range
if(x < m_x[m_last_idx] || x > m_x[m_last_idx + 1])
{
m_am[k] = 0.0;
}
n1 = 3 * m_num;
pod_array<double> al(n1);
temp = &al[0];
for(k = 0; k < n1; k++)
{
temp[k] = 0.0;
}
r = temp + m_num;
s = temp + m_num * 2;
n1 = m_num - 1;
d = m_x[1] - m_x[0];
e = (m_y[1] - m_y[0]) / d;
for(k = 1; k < n1; k++)
{
h = d;
d = m_x[k + 1] - m_x[k];
f = e;
e = (m_y[k + 1] - m_y[k]) / d;
al[k] = d / (d + h);
r[k] = 1.0 - al[k];
s[k] = 6.0 * (e - f) / (h + d);
}
for(k = 1; k < n1; k++)
{
p = 1.0 / (r[k] * al[k - 1] + 2.0);
al[k] *= -p;
s[k] = (s[k] - r[k] * s[k - 1]) * p;
}
m_am[n1] = 0.0;
al[n1 - 1] = s[n1 - 1];
m_am[n1 - 1] = al[n1 - 1];
for(k = n1 - 2, i = 0; i < m_num - 2; i++, k--)
{
al[k] = al[k] * al[k + 1] + s[k];
m_am[k] = al[k];
}
}
m_last_idx = -1;
}
//------------------------------------------------------------------------
void bspline::init(int num, const double* x, const double* y)
{
if(num > 2)
{
init(num);
int i;
for(i = 0; i < num; i++)
{
add_point(*x++, *y++);
}
prepare();
}
m_last_idx = -1;
}
//------------------------------------------------------------------------
void bspline::bsearch(int n, const double *x, double x0, int *i)
{
int j = n - 1;
int k;
for(*i = 0; (j - *i) > 1; )
{
if(x0 < x[k = (*i + j) >> 1]) j = k;
else *i = k;
}
}
//------------------------------------------------------------------------
double bspline::interpolation(double x, int i) const
{
int j = i + 1;
double d = m_x[i] - m_x[j];
double h = x - m_x[j];
double r = m_x[i] - x;
double p = d * d / 6.0;
return (m_am[j] * r * r * r + m_am[i] * h * h * h) / 6.0 / d +
((m_y[j] - m_am[j] * p) * r + (m_y[i] - m_am[i] * p) * h) / d;
}
//------------------------------------------------------------------------
double bspline::extrapolation_left(double x) const
{
double d = m_x[1] - m_x[0];
return (-d * m_am[1] / 6 + (m_y[1] - m_y[0]) / d) *
(x - m_x[0]) +
m_y[0];
}
//------------------------------------------------------------------------
double bspline::extrapolation_right(double x) const
{
double d = m_x[m_num - 1] - m_x[m_num - 2];
return (d * m_am[m_num - 2] / 6 + (m_y[m_num - 1] - m_y[m_num - 2]) / d) *
(x - m_x[m_num - 1]) +
m_y[m_num - 1];
}
//------------------------------------------------------------------------
double bspline::get(double x) const
{
if(m_num > 2)
{
int i;
// Extrapolation on the left
if(x < m_x[0]) return extrapolation_left(x);
// Extrapolation on the right
if(x >= m_x[m_num - 1]) return extrapolation_right(x);
// Interpolation
bsearch(m_num, m_x, x, &i);
return interpolation(x, i);
}
return 0.0;
}
//------------------------------------------------------------------------
double bspline::get_stateful(double x) const
{
if(m_num > 2)
{
// Extrapolation on the left
if(x < m_x[0]) return extrapolation_left(x);
// Extrapolation on the right
if(x >= m_x[m_num - 1]) return extrapolation_right(x);
if(m_last_idx >= 0)
{
// Check if x is not in current range
if(x < m_x[m_last_idx] || x > m_x[m_last_idx + 1])
// Check if x between next points (most probably)
if(m_last_idx < m_num - 2 &&
x >= m_x[m_last_idx + 1] &&
x <= m_x[m_last_idx + 2])
{
// Check if x between next points (most probably)
if(m_last_idx < m_num - 2 &&
x >= m_x[m_last_idx + 1] &&
x <= m_x[m_last_idx + 2])
{
++m_last_idx;
}
else
if(m_last_idx > 0 &&
x >= m_x[m_last_idx - 1] &&
++m_last_idx;
}
else
if(m_last_idx > 0 &&
x >= m_x[m_last_idx - 1] &&
x <= m_x[m_last_idx])
{
// x is between pevious points
@ -267,18 +267,18 @@ namespace agg
// Else perform full search
bsearch(m_num, m_x, x, &m_last_idx);
}
}
return interpolation(x, m_last_idx);
}
else
{
// Interpolation
bsearch(m_num, m_x, x, &m_last_idx);
return interpolation(x, m_last_idx);
}
return interpolation(x, m_last_idx);
}
else
{
// Interpolation
bsearch(m_num, m_x, x, &m_last_idx);
return interpolation(x, m_last_idx);
}
return 0.0;
}
return 0.0;
}
}

Some files were not shown because too many files have changed in this diff Show more