Merge branch 'master' of github.com:mapnik/mapnik into image_data_any
This commit is contained in:
commit
954d0db46c
17 changed files with 69 additions and 77 deletions
|
@ -66,12 +66,12 @@ private:
|
|||
class MAPNIK_DECL datasource : private mapnik::noncopyable
|
||||
{
|
||||
public:
|
||||
enum datasource_t {
|
||||
enum datasource_t : std::uint8_t {
|
||||
Vector,
|
||||
Raster
|
||||
};
|
||||
|
||||
enum geometry_t {
|
||||
enum geometry_t : std::uint8_t {
|
||||
Point = 1,
|
||||
LineString = 2,
|
||||
Polygon = 3,
|
||||
|
|
|
@ -57,7 +57,7 @@ class raster;
|
|||
|
||||
|
||||
//! \brief Enumerates the modes of interpolation
|
||||
enum colorizer_mode_enum
|
||||
enum colorizer_mode_enum : std::uint8_t
|
||||
{
|
||||
COLORIZER_INHERIT = 0, //!< The stop inherits the mode from the colorizer
|
||||
COLORIZER_LINEAR = 1, //!< Linear interpolation between colors
|
||||
|
|
|
@ -100,7 +100,7 @@ public:
|
|||
pos_(0)
|
||||
{}
|
||||
|
||||
enum status
|
||||
enum status : std::uint8_t
|
||||
{
|
||||
initial,
|
||||
process,
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
namespace mapnik {
|
||||
|
||||
enum line_cap_enum
|
||||
enum line_cap_enum : std::uint8_t
|
||||
{
|
||||
BUTT_CAP,
|
||||
SQUARE_CAP,
|
||||
|
@ -37,7 +37,7 @@ enum line_cap_enum
|
|||
|
||||
DEFINE_ENUM( line_cap_e, line_cap_enum );
|
||||
|
||||
enum line_join_enum
|
||||
enum line_join_enum : std::uint8_t
|
||||
{
|
||||
MITER_JOIN,
|
||||
MITER_REVERT_JOIN,
|
||||
|
@ -48,7 +48,7 @@ enum line_join_enum
|
|||
|
||||
DEFINE_ENUM( line_join_e, line_join_enum );
|
||||
|
||||
enum line_rasterizer_enum
|
||||
enum line_rasterizer_enum : std::uint8_t
|
||||
{
|
||||
RASTERIZER_FULL, // agg::renderer_scanline_aa_solid
|
||||
RASTERIZER_FAST, // agg::rasterizer_outline_aa, twice as fast but only good for thin lines
|
||||
|
@ -58,7 +58,7 @@ enum line_rasterizer_enum
|
|||
DEFINE_ENUM( line_rasterizer_e, line_rasterizer_enum );
|
||||
|
||||
|
||||
enum halo_rasterizer_enum
|
||||
enum halo_rasterizer_enum : std::uint8_t
|
||||
{
|
||||
HALO_RASTERIZER_FULL,
|
||||
HALO_RASTERIZER_FAST,
|
||||
|
@ -67,7 +67,7 @@ enum halo_rasterizer_enum
|
|||
|
||||
DEFINE_ENUM(halo_rasterizer_e, halo_rasterizer_enum);
|
||||
|
||||
enum point_placement_enum
|
||||
enum point_placement_enum : std::uint8_t
|
||||
{
|
||||
CENTROID_POINT_PLACEMENT,
|
||||
INTERIOR_POINT_PLACEMENT,
|
||||
|
@ -76,7 +76,7 @@ enum point_placement_enum
|
|||
|
||||
DEFINE_ENUM( point_placement_e, point_placement_enum );
|
||||
|
||||
enum pattern_alignment_enum
|
||||
enum pattern_alignment_enum : std::uint8_t
|
||||
{
|
||||
LOCAL_ALIGNMENT,
|
||||
GLOBAL_ALIGNMENT,
|
||||
|
@ -85,7 +85,7 @@ enum pattern_alignment_enum
|
|||
|
||||
DEFINE_ENUM( pattern_alignment_e, pattern_alignment_enum );
|
||||
|
||||
enum debug_symbolizer_mode_enum
|
||||
enum debug_symbolizer_mode_enum : std::uint8_t
|
||||
{
|
||||
DEBUG_SYM_MODE_COLLISION,
|
||||
DEBUG_SYM_MODE_VERTEX,
|
||||
|
@ -97,7 +97,7 @@ DEFINE_ENUM( debug_symbolizer_mode_e, debug_symbolizer_mode_enum );
|
|||
|
||||
// markers
|
||||
// TODO - consider merging with text_symbolizer label_placement_e
|
||||
enum marker_placement_enum
|
||||
enum marker_placement_enum : std::uint8_t
|
||||
{
|
||||
MARKER_POINT_PLACEMENT,
|
||||
MARKER_INTERIOR_PLACEMENT,
|
||||
|
@ -109,7 +109,7 @@ enum marker_placement_enum
|
|||
|
||||
DEFINE_ENUM( marker_placement_e, marker_placement_enum );
|
||||
|
||||
enum marker_multi_policy_enum
|
||||
enum marker_multi_policy_enum : std::uint8_t
|
||||
{
|
||||
MARKER_EACH_MULTI, // each component in a multi gets its marker
|
||||
MARKER_WHOLE_MULTI, // consider all components of a multi as a whole
|
||||
|
@ -119,7 +119,7 @@ enum marker_multi_policy_enum
|
|||
|
||||
DEFINE_ENUM( marker_multi_policy_e, marker_multi_policy_enum );
|
||||
|
||||
enum text_transform_enum
|
||||
enum text_transform_enum : std::uint8_t
|
||||
{
|
||||
NONE = 0,
|
||||
UPPERCASE,
|
||||
|
@ -130,7 +130,7 @@ enum text_transform_enum
|
|||
|
||||
DEFINE_ENUM(text_transform_e, text_transform_enum);
|
||||
|
||||
enum label_placement_enum
|
||||
enum label_placement_enum : std::uint8_t
|
||||
{
|
||||
POINT_PLACEMENT,
|
||||
LINE_PLACEMENT,
|
||||
|
@ -141,7 +141,7 @@ enum label_placement_enum
|
|||
|
||||
DEFINE_ENUM(label_placement_e, label_placement_enum);
|
||||
|
||||
enum vertical_alignment_enum
|
||||
enum vertical_alignment_enum : std::uint8_t
|
||||
{
|
||||
V_TOP = 0,
|
||||
V_MIDDLE,
|
||||
|
@ -152,7 +152,7 @@ enum vertical_alignment_enum
|
|||
|
||||
DEFINE_ENUM(vertical_alignment_e, vertical_alignment_enum);
|
||||
|
||||
enum horizontal_alignment_enum
|
||||
enum horizontal_alignment_enum : std::uint8_t
|
||||
{
|
||||
H_LEFT = 0,
|
||||
H_MIDDLE,
|
||||
|
@ -164,7 +164,7 @@ enum horizontal_alignment_enum
|
|||
|
||||
DEFINE_ENUM(horizontal_alignment_e, horizontal_alignment_enum);
|
||||
|
||||
enum justify_alignment_enum
|
||||
enum justify_alignment_enum : std::uint8_t
|
||||
{
|
||||
J_LEFT = 0,
|
||||
J_MIDDLE,
|
||||
|
@ -175,7 +175,7 @@ enum justify_alignment_enum
|
|||
|
||||
DEFINE_ENUM(justify_alignment_e, justify_alignment_enum);
|
||||
|
||||
enum text_upright_enum
|
||||
enum text_upright_enum : std::uint8_t
|
||||
{
|
||||
UPRIGHT_AUTO,
|
||||
UPRIGHT_LEFT,
|
||||
|
@ -187,7 +187,8 @@ enum text_upright_enum
|
|||
|
||||
DEFINE_ENUM(text_upright_e, text_upright_enum);
|
||||
|
||||
enum gamma_method_enum {
|
||||
enum gamma_method_enum : std::uint8_t
|
||||
{
|
||||
GAMMA_POWER, //agg::gamma_power
|
||||
GAMMA_LINEAR, //agg::gamma_linear
|
||||
GAMMA_NONE, //agg::gamma_none
|
||||
|
|
|
@ -84,7 +84,7 @@ struct evaluated_text_properties : noncopyable
|
|||
|
||||
using evaluated_text_properties_ptr = std::unique_ptr<detail::evaluated_text_properties>;
|
||||
|
||||
enum directions_e
|
||||
enum directions_e : std::uint8_t
|
||||
{
|
||||
NORTH,
|
||||
EAST,
|
||||
|
|
|
@ -28,16 +28,9 @@
|
|||
|
||||
extern "C"
|
||||
{
|
||||
#ifdef HAVE_GEOTIFF
|
||||
#include <xtiffio.h>
|
||||
#include <geotiffio.h>
|
||||
#define RealTIFFOpen XTIFFClientOpen
|
||||
#define RealTIFFClose XTIFFClose
|
||||
#else
|
||||
#include <tiffio.h>
|
||||
#define RealTIFFOpen TIFFClientOpen
|
||||
#define RealTIFFClose TIFFClose
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace mapnik {
|
||||
|
@ -206,30 +199,6 @@ void save_as_tiff(T1 & file, T2 const& image)
|
|||
// TIFFSetField(output, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_PALETTE);
|
||||
// TIFFSetField(output, TIFFTAG_COLORMAP, r, g, b);
|
||||
|
||||
#ifdef HAVE_GEOTIFF
|
||||
GTIF* geotiff = GTIFNew(output);
|
||||
if (! geotiff)
|
||||
{
|
||||
// throw ?
|
||||
}
|
||||
|
||||
GTIFKeySet(geotiff, GTModelTypeGeoKey, TYPE_SHORT, 1, ModelGeographic);
|
||||
GTIFKeySet(geotiff, GTRasterTypeGeoKey, TYPE_SHORT, 1, RasterPixelIsPoint);
|
||||
GTIFKeySet(geotiff, GeographicTypeGeoKey, TYPE_SHORT, 1, 4326); // parameter needed !
|
||||
GTIFKeySet(geotiff, GeogAngularUnitsGeoKey, TYPE_SHORT, 1, Angular_Degree);
|
||||
GTIFKeySet(geotiff, GeogLinearUnitsGeoKey, TYPE_SHORT, 1, Linear_Meter);
|
||||
|
||||
double lowerLeftLon = 130.0f; // parameter needed !
|
||||
double upperRightLat = 32.0; // parameter needed !
|
||||
double tiepoints[] = { 0.0, 0.0, 0.0, lowerLeftLon, upperRightLat, 0.0 };
|
||||
TIFFSetField(output, TIFFTAG_GEOTIEPOINTS, sizeof(tiepoints)/sizeof(double), tiepoints);
|
||||
|
||||
double pixelScaleX = 0.0001; // parameter needed !
|
||||
double pixelScaleY = 0.0001; // parameter needed !
|
||||
double pixscale[] = { pixelScaleX, pixelScaleY, 0.0 };
|
||||
TIFFSetField(output, TIFFTAG_GEOPIXELSCALE, sizeof(pixscale)/sizeof(double), pixscale);
|
||||
#endif
|
||||
|
||||
int next_scanline = 0;
|
||||
unsigned char* row = reinterpret_cast<unsigned char*>(::operator new(scanline_size));
|
||||
|
||||
|
@ -250,11 +219,6 @@ void save_as_tiff(T1 & file, T2 const& image)
|
|||
|
||||
::operator delete(row);
|
||||
|
||||
#ifdef HAVE_GEOTIFF
|
||||
GTIFWriteKeys(geotiff);
|
||||
GTIFFree(geotiff);
|
||||
#endif
|
||||
|
||||
RealTIFFClose(output);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <mapnik/noncopyable.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
|
||||
// stl
|
||||
// std
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
|
@ -43,7 +43,6 @@ public:
|
|||
mapnik::value_unicode_string transcode(const char* data, std::int32_t length = -1) const;
|
||||
~transcoder();
|
||||
private:
|
||||
bool ok_;
|
||||
UConverter * conv_;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ std::string to_hex(const char* blob, unsigned size)
|
|||
return s.str();
|
||||
}
|
||||
|
||||
enum wkbByteOrder {
|
||||
enum wkbByteOrder : std::uint8_t {
|
||||
wkbXDR=0,
|
||||
wkbNDR=1
|
||||
};
|
||||
|
|
|
@ -24,11 +24,12 @@
|
|||
#define MAPNIK_VERTEX_HPP
|
||||
|
||||
#include <utility>
|
||||
#include <cstdint>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
||||
enum CommandType {
|
||||
enum CommandType : std::uint8_t {
|
||||
SEG_END = 0,
|
||||
SEG_MOVETO = 1,
|
||||
SEG_LINETO = 2,
|
||||
|
@ -44,7 +45,7 @@ struct vertex {
|
|||
template <typename T>
|
||||
struct vertex<T,2>
|
||||
{
|
||||
enum no_init_t { no_init };
|
||||
enum no_init_t : std::uint8_t { no_init };
|
||||
|
||||
using coord_type = T;
|
||||
coord_type x;
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
namespace mapnik {
|
||||
|
||||
enum well_known_srs_enum {
|
||||
enum well_known_srs_enum : std::uint8_t {
|
||||
WGS_84,
|
||||
G_MERC,
|
||||
well_known_srs_enum_MAX
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace mapnik
|
|||
* the Open Geospatial Consortium (OGC) and described in their Simple Feature
|
||||
* Access and Coordinate Transformation Service specifications.
|
||||
*/
|
||||
enum wkbFormat
|
||||
enum wkbFormat : std::uint8_t
|
||||
{
|
||||
wkbAuto=1,
|
||||
wkbGeneric=2,
|
||||
|
|
|
@ -24,9 +24,8 @@
|
|||
#include <mapnik/unicode.hpp>
|
||||
#include <mapnik/value_types.hpp>
|
||||
|
||||
// stl
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
// std
|
||||
#include <stdexcept>
|
||||
|
||||
// icu
|
||||
#include <unicode/ucnv.h>
|
||||
|
@ -34,13 +33,15 @@
|
|||
namespace mapnik {
|
||||
|
||||
transcoder::transcoder (std::string const& encoding)
|
||||
: ok_(false),
|
||||
conv_(0)
|
||||
: conv_(0)
|
||||
{
|
||||
UErrorCode err = U_ZERO_ERROR;
|
||||
conv_ = ucnv_open(encoding.c_str(),&err);
|
||||
if (U_SUCCESS(err)) ok_ = true;
|
||||
// TODO ??
|
||||
if (!U_SUCCESS(err))
|
||||
{
|
||||
// NOT: conv_ should be null on error so no need to call ucnv_close
|
||||
throw std::runtime_error(std::string("could not create converter for ") + encoding);
|
||||
}
|
||||
}
|
||||
|
||||
mapnik::value_unicode_string transcoder::transcode(const char* data, std::int32_t length) const
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <iostream>
|
||||
#include <mapnik/projection.hpp>
|
||||
#include <mapnik/unicode.hpp>
|
||||
#include <mapnik/map.hpp>
|
||||
#include <mapnik/save_map.hpp>
|
||||
#include <mapnik/graphics.hpp>
|
||||
|
@ -53,6 +54,13 @@ int main(int argc, char** argv)
|
|||
BOOST_TEST(true);
|
||||
}
|
||||
|
||||
try {
|
||||
mapnik::transcoder tr("bogus encoding");
|
||||
BOOST_TEST(false);
|
||||
} catch (...) {
|
||||
BOOST_TEST(true);
|
||||
}
|
||||
|
||||
mapnik::Map map(256,256);
|
||||
mapnik::rule r;
|
||||
r.set_filter(mapnik::parse_expression("[foo]='bar'"));
|
||||
|
|
BIN
tests/python_tests/images/support/dataraster_coloring.png
Normal file
BIN
tests/python_tests/images/support/dataraster_coloring.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
BIN
tests/python_tests/images/support/raster_warping.png
Normal file
BIN
tests/python_tests/images/support/raster_warping.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
|
@ -52,9 +52,14 @@ def test_dataraster_coloring():
|
|||
|
||||
im = mapnik.Image(_map.width,_map.height)
|
||||
mapnik.render(_map, im)
|
||||
imdata = im.tostring()
|
||||
# we have some values in the [20,30) interval so check that they're colored
|
||||
assert contains_word('\xff\xff\x00\xff', imdata)
|
||||
expected_file = './images/support/dataraster_coloring.png'
|
||||
actual_file = '/tmp/' + os.path.basename(expected_file)
|
||||
im.save(actual_file,'png32')
|
||||
if not os.path.exists(expected_file) or os.environ.get('UPDATE'):
|
||||
im.save(expected_file,'png32')
|
||||
actual = mapnik.Image.open(actual_file)
|
||||
expected = mapnik.Image.open(expected_file)
|
||||
eq_(actual.tostring('png32'),expected.tostring('png32'), 'failed comparing actual (%s) and expected (%s)' % (actual_file,expected_file))
|
||||
|
||||
def test_dataraster_query_point():
|
||||
srs = '+init=epsg:32630'
|
||||
|
@ -165,8 +170,14 @@ def test_raster_warping():
|
|||
|
||||
im = mapnik.Image(_map.width,_map.height)
|
||||
mapnik.render(_map, im)
|
||||
imdata = im.tostring()
|
||||
assert contains_word('\xff\xff\x00\xff', imdata)
|
||||
expected_file = './images/support/raster_warping.png'
|
||||
actual_file = '/tmp/' + os.path.basename(expected_file)
|
||||
im.save(actual_file,'png32')
|
||||
if not os.path.exists(expected_file) or os.environ.get('UPDATE'):
|
||||
im.save(expected_file,'png32')
|
||||
actual = mapnik.Image.open(actual_file)
|
||||
expected = mapnik.Image.open(expected_file)
|
||||
eq_(actual.tostring('png32'),expected.tostring('png32'), 'failed comparing actual (%s) and expected (%s)' % (actual_file,expected_file))
|
||||
|
||||
def test_raster_warping_does_not_overclip_source():
|
||||
lyrSrs = "+init=epsg:32630"
|
||||
|
@ -192,7 +203,14 @@ def test_raster_warping_does_not_overclip_source():
|
|||
|
||||
im = mapnik.Image(_map.width,_map.height)
|
||||
mapnik.render(_map, im)
|
||||
assert im.view(0,200,1,1).tostring()=='\xff\xff\x00\xff'
|
||||
expected_file = './images/support/raster_warping_does_not_overclip_source.png'
|
||||
actual_file = '/tmp/' + os.path.basename(expected_file)
|
||||
im.save(actual_file,'png32')
|
||||
if not os.path.exists(expected_file) or os.environ.get('UPDATE'):
|
||||
im.save(expected_file,'png32')
|
||||
actual = mapnik.Image.open(actual_file)
|
||||
expected = mapnik.Image.open(expected_file)
|
||||
eq_(actual.tostring('png32'),expected.tostring('png32'), 'failed comparing actual (%s) and expected (%s)' % (actual_file,expected_file))
|
||||
|
||||
if __name__ == "__main__":
|
||||
setup()
|
||||
|
|
Loading…
Add table
Reference in a new issue