27 #include "../annotationtext/Attributes.h" 28 #include "../annotationtext/Element.h" 29 #include "../annotationtext/Text.h" 30 #include "../common/StringUtils.h" 31 #include "../geometry/Coord2D.h" 32 #include "../geometry/Geometry.h" 33 #include "../geometry/GeometryCollection.h" 34 #include "../geometry/LineString.h" 35 #include "../geometry/LinearRing.h" 36 #include "../geometry/MultiLineString.h" 37 #include "../geometry/MultiPoint.h" 38 #include "../geometry/MultiPolygon.h" 39 #include "../geometry/Point.h" 40 #include "../geometry/PointM.h" 41 #include "../geometry/PointZ.h" 42 #include "../geometry/PointZM.h" 43 #include "../geometry/Polygon.h" 44 #include "../postgis/EWKBReader.h" 45 #include "../postgis/Utils.h" 47 #include "../common/FileDirUtils.h" 52 #include <agg_renderer_markers.h> 54 #include <agg_conv_transform.h> 55 #include <agg_conv_stroke.h> 56 #include <agg_renderer_scanline.h> 57 #include <agg_image_accessors.h> 58 #include <agg_span_pattern_rgb.h> 59 #include <agg_span_allocator.h> 60 #include <agg_conv_smooth_poly1.h> 61 #include <agg_pattern_filters_rgba.h> 62 #include <agg_renderer_outline_image.h> 63 #include <agg_renderer_outline_aa.h> 64 #include <agg_rasterizer_outline_aa.h> 65 #include <agg_span_interpolator_linear.h> 66 #include <agg_span_image_filter_rgba.h> 67 #include <agg_trans_single_path.h> 84 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
85 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
86 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
87 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
88 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
89 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
90 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
91 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
92 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
93 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 254, 254, 254, 254, 254,
94 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
95 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
96 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
97 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
98 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
99 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
100 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
101 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
102 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
103 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
104 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
105 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
106 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
107 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 253, 253,
108 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 252,
109 252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 251, 251, 251, 251, 251,
110 251, 251, 251, 251, 250, 250, 250, 250, 250, 250, 250, 250, 249, 249, 249, 249,
111 249, 249, 249, 248, 248, 248, 248, 248, 248, 248, 247, 247, 247, 247, 247, 246,
112 246, 246, 246, 246, 246, 245, 245, 245, 245, 245, 244, 244, 244, 244, 243, 243,
113 243, 243, 243, 242, 242, 242, 242, 241, 241, 241, 241, 240, 240, 240, 239, 239,
114 239, 239, 238, 238, 238, 238, 237, 237, 237, 236, 236, 236, 235, 235, 235, 234,
115 234, 234, 233, 233, 233, 232, 232, 232, 231, 231, 230, 230, 230, 229, 229, 229,
116 228, 228, 227, 227, 227, 226, 226, 225, 225, 224, 224, 224, 223, 223, 222, 222,
117 221, 221, 220, 220, 219, 219, 219, 218, 218, 217, 217, 216, 216, 215, 214, 214,
118 213, 213, 212, 212, 211, 211, 210, 210, 209, 209, 208, 207, 207, 206, 206, 205,
119 204, 204, 203, 203, 202, 201, 201, 200, 200, 199, 198, 198, 197, 196, 196, 195,
120 194, 194, 193, 192, 192, 191, 190, 190, 189, 188, 188, 187, 186, 186, 185, 184,
121 183, 183, 182, 181, 180, 180, 179, 178, 177, 177, 176, 175, 174, 174, 173, 172,
122 171, 171, 170, 169, 168, 167, 166, 166, 165, 164, 163, 162, 162, 161, 160, 159,
123 158, 157, 156, 156, 155, 154, 153, 152, 151, 150, 149, 148, 148, 147, 146, 145,
124 144, 143, 142, 141, 140, 139, 138, 137, 136, 135, 134, 133, 132, 131, 130, 129,
125 128, 128, 127, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113,
126 112, 111, 110, 109, 108, 107, 106, 105, 104, 102, 101, 100, 99, 98, 97, 96,
127 95, 94, 93, 91, 90, 89, 88, 87, 86, 85, 84, 82, 81, 80, 79, 78,
128 77, 75, 74, 73, 72, 71, 70, 69, 67, 66, 65, 64, 63, 61, 60, 59,
129 58, 57, 56, 54, 53, 52, 51, 50, 48, 47, 46, 45, 44, 42, 41, 40,
130 39, 37, 36, 35, 34, 33, 31, 30, 29, 28, 27, 25, 24, 23, 22, 20,
131 19, 18, 17, 15, 14, 13, 12, 11, 9, 8, 7, 6, 4, 3, 2, 1
142 agg::rgba8
pixel(
int x,
int y)
const 144 agg::rgba8 c =
m_pf.pixel(x, y);
164 m_fontManager =
new agg::font_cache_manager<agg::font_engine_win32_tt_int16>(*m_fontEngine);
165 m_fontEngine->create_font(
"Verdana", agg::glyph_ren_outline);
166 m_fontEngine->height(16.);
206 ::ReleaseDC(0,
m_hdc);
217 const double& urx,
const double& ury)
224 double xScale =
static_cast<double>(
m_dwidth) / (urx - llx);
225 double yScale =
static_cast<double>(
m_dheight) / (ury - lly);
229 m_matrix *= agg::trans_affine_scaling(xScale, yScale);
233 const HAlignType& ha,
const VAlignType& va)
235 double ww = urx - llx;
236 double wh = ury - lly;
238 if(widthByHeight > ww/wh)
241 ww = wh * widthByHeight;
249 llx = llx - (ww - v) / 2.;
256 wh = ww / widthByHeight;
264 lly = lly - (wh - v) / 2.;
304 unsigned int wkbGeomType = *((
unsigned int*)(geom + 1));
353 double x = *((
double*)(point + 5));
354 double y = *((
double*)(point + 13));
359 agg::renderer_markers<agg::renderer_base<pixfmt> > m_rendMarker(
m_rendererBase);
372 agg::renderer_base<pixfmt_pre> rb_pre(pixf_pre);
382 typedef agg::span_allocator<color_type> span_alloc_type;
384 agg::image_filter_bilinear filter_kernel;
385 agg::image_filter_lut filter(filter_kernel,
true);
387 typedef agg::image_accessor_clone<pixfmt> source_type;
388 source_type source(pixf_img);
390 agg::trans_affine tr;
391 tr.translate(-(x-w), -(y-h));
392 double scale = (double)pixf_img.width() / (double)
m_ptWidth;
393 tr.scale(scale, scale);
395 typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
396 interpolator_type interpolator(tr);
398 agg::span_image_filter_rgba_2x2<source_type, interpolator_type> sg(source, interpolator, filter);
436 const unsigned int nPts = *((
unsigned int*)(mpoint));
440 for(
register unsigned int i = 0; i != nPts; ++i)
452 const unsigned int nPoints = *((
unsigned int*)(line + 5));
454 assert(nPoints >= 2);
459 size_t size = nPoints*2;
460 double* v =
new double[size];
465 for(
register unsigned int i = 0; i != nPoints; ++i)
467 v[j++] = coords[i].
x;
468 v[j++] = coords[i].
y;
473 line += 16 * nPoints;
485 const unsigned int nLines = *((
unsigned int*)(mline));
489 for(
register unsigned int i = 0; i !=
nLines; ++i)
501 const unsigned int nRings = *((
unsigned int*)(poly + 5));
505 agg::path_storage path;
506 int pathIndex = path.start_new_path();
509 char* ptr = poly + 9;
511 for(
register unsigned int i = 0; i != nRings; ++i)
513 const unsigned int nPoints = *((
unsigned int*)ptr);
519 double* v =
new double[nPoints*2];
520 memcpy(v, (
double*)ptr, 16 * nPoints);
522 ptr += (16 * nPoints);
524 path.concat_poly(v, nPoints,
true);
540 const unsigned int nPolygons = *((
unsigned int*)mpoly);
542 assert(nPolygons > 0);
546 for(
unsigned int i = 0; i != nPolygons; ++i)
559 const unsigned int nGeoms = *((
unsigned int*)g);
565 for(
register unsigned int i = 0; i != nGeoms; ++i)
579 draw(static_cast<te::gm::MultiPolygon*>(geom));
586 draw(static_cast<te::gm::Point*>(geom));
593 draw(static_cast<te::gm::LineString*>(geom));
600 draw(static_cast<te::gm::Polygon*>(geom));
607 draw(static_cast<te::gm::MultiLineString*>(geom));
614 draw(static_cast<te::gm::MultiPoint*>(geom));
621 draw(static_cast<te::gm::GeometryCollection*>(geom));
631 double x = point->
getX();
632 double y = point->
getY();
637 agg::renderer_markers<agg::renderer_base<pixfmt> > m_rendMarker(
m_rendererBase);
647 agg::renderer_base<pixfmt_pre> rb_pre(pixf_pre);
657 typedef agg::span_allocator<color_type> span_alloc_type;
659 agg::image_filter_bilinear filter_kernel;
660 agg::image_filter_lut filter(filter_kernel,
true);
662 typedef agg::image_accessor_clone<pixfmt> source_type;
663 source_type source(pixf_img);
665 agg::trans_affine tr;
666 tr.translate(-(x-w), -(y-h));
667 double scale = (double)pixf_img.width() / (double)
m_ptWidth;
668 tr.scale(scale, scale);
670 typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
671 interpolator_type interpolator(tr);
673 agg::span_image_filter_rgba_2x2<source_type, interpolator_type> sg(source, interpolator, filter);
701 for(
size_t i = 0; i < size; ++i)
707 for(
size_t i = 0; i < size; ++i)
713 for(
size_t i = 0; i < size; ++i)
719 for(
size_t i = 0; i < size; ++i)
733 double* v =
new double[size*2];
736 for(
register size_t i = 0; i != size; ++i)
738 v[j++] = coords[i].
x;
739 v[j++] = coords[i].
y;
749 agg::path_storage path;
750 int pathIndex = path.start_new_path();
751 path.concat_poly(v, size,
false);
756 agg::conv_transform<agg::path_storage> fill(path,
m_matrix);
757 agg::conv_stroke<agg::conv_transform<agg::path_storage> > stroke(fill);
769 agg::pattern_filter_bilinear_rgba8 fltr;
778 typedef agg::line_image_pattern<agg::pattern_filter_bilinear_rgba8> pattern_type;
779 typedef agg::renderer_base<pixfmt> base_ren_type;
780 typedef agg::renderer_outline_image<base_ren_type, pattern_type> renderer_img_type;
781 typedef agg::rasterizer_outline_aa<renderer_img_type, agg::line_coord_sat> rasterizer_img_type;
783 typedef agg::renderer_outline_aa<base_ren_type> renderer_line_type;
784 typedef agg::rasterizer_outline_aa<renderer_line_type, agg::line_coord_sat> rasterizer_line_type;
787 pattern_type patt(fltr);
790 rasterizer_img_type ras_img(ren_img);
793 agg::line_profile_aa profile;
794 profile.smoother_width(p1.
height());
795 profile.width(p1.
height()-4);
797 ren_line.color(agg::rgba8(200,200,200));
798 rasterizer_line_type ras_line(ren_line);
803 ren_img.start_x(p1.
width()/2.);
805 agg::poly_plain_adaptor<double> vs(v, size,
false);
806 agg::conv_transform<agg::poly_plain_adaptor<double> > trans(vs,
m_matrix);
807 ras_line.add_path(trans);
808 ras_img.add_path(trans);
818 for(
size_t i = 0; i < size; ++i)
828 agg::path_storage path;
829 int pathIndex = path.start_new_path();
831 for(
register size_t i = 0; i != nRings; ++i)
839 double* v =
new double[nPoints*2];
842 path.concat_poly(v, nPoints,
true);
851 agg::conv_transform<agg::path_storage> transPath(path,
m_matrix);
867 agg::int8u* buf =
new agg::int8u[width * height *
DEPTH/8];
868 memset(buf, 0, width * height *
DEPTH/8);
869 agg::rendering_buffer rbuf(buf, width, height, -width *
DEPTH/8);
873 agg::renderer_base<pixfmt_pre> rb_pre(pixf_pre);
881 typedef agg::span_allocator<color_type> span_alloc_type;
883 agg::image_filter_bilinear filter_kernel;
884 agg::image_filter_lut filter(filter_kernel,
true);
886 typedef agg::image_accessor_clone<pixfmt> source_type;
887 source_type source(pixf_img);
889 agg::trans_affine tr;
890 double scale = (double)pixf_img.width() / (double)width;
891 tr.scale(scale, scale);
893 typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
894 interpolator_type interpolator(tr);
896 agg::span_image_filter_rgba_2x2<source_type, interpolator_type> sg(source, interpolator, filter);
905 agg::renderer_base<pixfmt_pre> rb_pre(*pixf_pre);
907 typedef agg::wrap_mode_repeat_auto_pow2 repeat_x_type;
908 typedef agg::wrap_mode_repeat_auto_pow2 repeat_y_type;
909 typedef agg::image_accessor_wrap<pixfmt, repeat_x_type, repeat_y_type> img_source_type;
910 typedef agg::span_pattern_rgb<img_source_type> span_gen_type;
912 agg::span_allocator<color_type> sa;
914 img_source_type img_src(img_pixf);
915 span_gen_type sg(img_src, 0, 0);
926 agg::conv_stroke<agg::conv_transform<agg::path_storage> > stroke(transPath);
935 agg::pattern_filter_bilinear_rgba8 fltr;
944 typedef agg::line_image_pattern<agg::pattern_filter_bilinear_rgba8> pattern_type;
945 typedef agg::renderer_base<pixfmt> base_ren_type;
946 typedef agg::renderer_outline_image<base_ren_type, pattern_type> renderer_img_type;
947 typedef agg::rasterizer_outline_aa<renderer_img_type, agg::line_coord_sat> rasterizer_img_type;
949 typedef agg::renderer_outline_aa<base_ren_type> renderer_line_type;
950 typedef agg::rasterizer_outline_aa<renderer_line_type, agg::line_coord_sat> rasterizer_line_type;
953 pattern_type patt(fltr);
956 rasterizer_img_type ras_img(ren_img);
959 agg::line_profile_aa profile;
960 profile.smoother_width(p1.
height());
961 profile.width(p1.
height()-4);
963 ren_line.color(agg::rgba8(200,200,200));
964 rasterizer_line_type ras_line(ren_line);
969 ren_img.start_x(p1.
width()/2.);
975 int size = path.total_vertices();
977 for(k = i = 0; i < size; ++i)
979 if(path.vertex(i, &x, &y) != 79)
983 v =
new double[(k+1)<<1];
987 path.vertex(j, &x, &y);
995 agg::poly_plain_adaptor<double> vs(v, k+1,
false);
996 agg::conv_transform<agg::poly_plain_adaptor<double> > trans(vs,
m_matrix);
997 ras_line.add_path(trans);
998 ras_img.add_path(trans);
1011 for(
size_t i = 0; i < size; ++i)
1019 for(
size_t i = 0; i < size; ++i)
1090 agg::int8u* buf =
new agg::int8u[h * w *
DEPTH/8];
1091 for(i = 0; i < h; ++i)
1094 for(j = 0; j < w; ++j)
1098 buf[n] = (agg::int8u)c.
getRed();
1099 buf[n + 1] = (agg::int8u)c.
getGreen();
1100 buf[n + 2] = (agg::int8u)c.
getBlue();
1101 buf[n + 3] = (agg::int8u)c.
getAlpha();
1104 agg::rendering_buffer rbuf(buf, w, h, -w *
DEPTH/8);
1108 agg::renderer_base<pixfmt_pre> rb_pre(pixf_pre);
1110 typedef agg::span_allocator<color_type> span_alloc_type;
1112 agg::image_filter_bilinear filter_kernel;
1113 agg::image_filter_lut filter(filter_kernel,
true);
1115 typedef agg::image_accessor_clone<pixfmt> source_type;
1116 source_type source(pixf_img);
1118 agg::trans_affine tr;
1120 tr.translate(0, -ty);
1122 typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
1123 interpolator_type interpolator(tr);
1131 agg::span_image_filter_rgba_2x2<source_type, interpolator_type> sg(source, interpolator, filter);
1150 agg::int8u* buf =
new agg::int8u[h * w *
DEPTH/8];
1151 for(i = 0; i < h; ++i)
1154 for(j = 0; j < w; ++j)
1158 buf[n] = (agg::int8u)c.
getRed();
1159 buf[n + 1] = (agg::int8u)c.
getGreen();
1160 buf[n + 2] = (agg::int8u)c.
getBlue();
1161 buf[n + 3] = (agg::int8u)c.
getAlpha();
1164 agg::rendering_buffer rbuf(buf, w, h, -w *
DEPTH/8);
1168 agg::renderer_base<pixfmt_pre> rb_pre(pixf_pre);
1170 typedef agg::span_allocator<color_type> span_alloc_type;
1172 agg::image_filter_bilinear filter_kernel;
1173 agg::image_filter_lut filter(filter_kernel,
true);
1175 typedef agg::image_accessor_clone<pixfmt> source_type;
1176 source_type source(pixf_img);
1178 agg::trans_affine tr;
1180 tr.translate(-x, -ty);
1182 typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
1183 interpolator_type interpolator(tr);
1191 agg::span_image_filter_rgba_2x2<source_type, interpolator_type> sg(source, interpolator, filter);
1210 agg::int8u* buf =
new agg::int8u[srch * srcw *
DEPTH/8];
1211 for(i = 0; i < srch; ++i)
1214 for(j = 0; j < srcw; ++j)
1218 buf[n] = (agg::int8u)c.
getRed();
1219 buf[n + 1] = (agg::int8u)c.
getGreen();
1220 buf[n + 2] = (agg::int8u)c.
getBlue();
1221 buf[n + 3] = (agg::int8u)c.
getAlpha();
1224 agg::rendering_buffer rbuf(buf, srcw, srch, -srcw *
DEPTH/8);
1228 agg::renderer_base<pixfmt_pre> rb_pre(pixf_pre);
1230 typedef agg::span_allocator<color_type> span_alloc_type;
1232 agg::image_filter_bilinear filter_kernel;
1233 agg::image_filter_lut filter(filter_kernel,
true);
1235 typedef agg::image_accessor_clone<pixfmt> source_type;
1236 source_type source(pixf_img);
1238 agg::trans_affine tr;
1239 double xscale = (double)pixf_img.width() / (double)w;
1240 double yscale = (double)pixf_img.height() / (double)h;
1241 int nh = (
int)((
double)(rbuf.height())/yscale + .5);
1243 tr.translate(-x, -ty);
1244 tr.scale(xscale, yscale);
1246 typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
1247 interpolator_type interpolator(tr);
1255 agg::span_image_filter_rgba_2x2<source_type, interpolator_type> sg(source, interpolator, filter);
1260 void te::ag::Canvas::drawImage(
int x,
int y,
int w,
int h,
char* src,
int size,
te::map::Canvas::ImageType t,
int sx,
int sy,
int sw,
int sh)
1274 agg::int8u* buf =
new agg::int8u[sh * sw *
DEPTH/8];
1275 for(i = sy; i < sh; ++i)
1277 k = (i - sy) * 4 * sw;
1278 for(j = sx; j < sw; ++j)
1281 n = k + 4 * (j - sx);
1282 buf[n] = (agg::int8u)c.
getRed();
1283 buf[n + 1] = (agg::int8u)c.
getGreen();
1284 buf[n + 2] = (agg::int8u)c.
getBlue();
1285 buf[n + 3] = (agg::int8u)c.
getAlpha();
1288 agg::rendering_buffer rbuf(buf, sw, sh, -sw *
DEPTH/8);
1292 agg::renderer_base<pixfmt_pre> rb_pre(pixf_pre);
1294 typedef agg::span_allocator<color_type> span_alloc_type;
1296 agg::image_filter_bilinear filter_kernel;
1297 agg::image_filter_lut filter(filter_kernel,
true);
1299 typedef agg::image_accessor_clone<pixfmt> source_type;
1300 source_type source(pixf_img);
1302 agg::trans_affine tr;
1303 double xscale = (double)pixf_img.width() / (double)w;
1304 double yscale = (double)pixf_img.height() / (double)h;
1305 int nh = (
int)((
double)(rbuf.height())/yscale + .5);
1307 tr.translate(-x, -ty);
1308 tr.scale(xscale, yscale);
1310 typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
1311 interpolator_type interpolator(tr);
1319 agg::span_image_filter_rgba_2x2<source_type, interpolator_type> sg(source, interpolator, filter);
1337 const std::string& tx,
1342 agg::trans_affine matrix;
1347 const char*
p = tx.c_str();
1358 xa += glyph->advance_x;
1359 ya += glyph->advance_y;
1363 double txWidth = xa;
1368 matrix.translate(-xi, -yi);
1369 matrix.rotate(-angle *
PI / 180.);
1370 matrix.translate(xi, yi);
1373 xi = x + txWidth / 2.;
1384 matrix.transform(&xi, &yi);
1387 double xx = x - (xi - x);
1392 matrix.translate(-xx, -yy);
1394 matrix.rotate(-angle *
PI / 180.);
1395 matrix.translate(xx, yy);
1396 matrix.transform(&xf, &yf);
1398 agg::path_storage path;
1399 int pathIndex = path.start_new_path();
1400 path.move_to(xx, yy);
1401 path.line_to(xf, yf);
1403 agg::renderer_scanline_aa_solid<agg::renderer_base<pixfmt> > rendererSolid(
m_rendererBase);
1405 agg::trans_single_path tcurve;
1406 tcurve.add_path(path);
1407 tcurve.preserve_x_scale(
true);
1413 fsegm.approximation_scale(3.0);
1414 fcurves.approximation_scale(2.0);
1425 if(xa > tcurve.total_length())
1431 if(glyph->data_type == agg::glyph_data_outline)
1440 xa += glyph->advance_x;
1441 ya += glyph->advance_y;
1451 matrix.translate(-xx, -yy);
1452 matrix.rotate(-angle *
PI / 180.);
1453 matrix.translate(xx, yy);
1466 pathIndex = path.start_new_path();
1470 matrix.transform(&a, &b);
1474 matrix.transform(&a, &b);
1476 path.close_polygon(
false);
1479 agg::conv_transform<agg::path_storage> fill(path, matrix);
1480 agg::conv_stroke<agg::conv_transform<agg::path_storage> > stroke(fill);
1499 if(matrix.is_identity() ==
false)
1501 v =
new double[size<<1];
1508 matrix.transform(&x, &y);
1509 v[i++] = (
int)(x+.5);
1510 v[i++] = (
int)(y+.5);
1513 distx += abs((
int)(v[i-2] - v[i-4]));
1514 disty += abs((
int)(v[i-1] - v[i-3]));
1523 if(distx == 0 && disty == 0)
1535 distx += abs((
int)(v[i-2] - v[i-4]));
1536 disty += abs((
int)(v[i-1] - v[i-3]));
1541 int len = (
int)tx.size() * fontSize/2;
1542 int dist = (
int)sqrt((
double)(distx * distx + disty * disty));
1549 agg::path_storage path;
1550 path.start_new_path();
1552 path.concat_poly(v, size,
false);
1555 agg::renderer_scanline_aa_solid<agg::renderer_base<pixfmt> > rendererSolid(
m_rendererBase);
1557 agg::trans_single_path tcurve;
1558 tcurve.add_path(path);
1559 tcurve.preserve_x_scale(
true);
1565 fsegm.approximation_scale(3.0);
1566 fcurves.approximation_scale(2.0);
1572 if(font.find(
"Californian FB") == std::string::npos)
1573 b =
m_fontEngine->create_font(
"Californian FB", agg::glyph_ren_outline);
1577 double x = (double)dist/2. - (
double)len/2.;
1579 const char*
p = tx.c_str();
1586 if(x > tcurve.total_length())
1592 if(glyph->data_type == agg::glyph_data_outline)
1596 rendererSolid.color(agg::rgba8(0, 0, 0));
1601 x += glyph->advance_x;
1602 y += glyph->advance_y;
1612 const std::string& tx,
1617 double x = wp.
getX();
1618 double y = wp.
getY();
1621 drawText((
int)x, (
int)y, tx, angle, hAlign, vAlign);
1625 const std::string& tx,
1634 drawText((
int)x, (
int)y, tx, angle, hAlign, vAlign);
1644 while(tx->
getElements()[i]->getAttributes() == 0 && i < size)
1732 std::string text = element->
getValue();
1733 size_t p = text.find(
"\n");
1736 if(p != std::string::npos)
1746 while(p != std::string::npos)
1748 std::string t = text.substr(0, p);
1749 drawText(*pclone, t, 0., hAlign, vAlign);
1750 text = text.substr(p+1);
1751 p = text.find(
"\n");
1752 pclone->
setY(pclone->
getY() - hline);
1755 drawText(*pclone, text, 0., hAlign, vAlign);
1757 drawText(*pt, text, 0., hAlign, vAlign);
1769 agg::trans_affine matrix;
1774 const char*
p = tx.c_str();
1785 xa += glyph->advance_x;
1786 ya += glyph->advance_y;
1790 double txWidth = xa;
1795 matrix.translate(-xi, -yi);
1796 matrix.rotate(-angle *
PI / 180.);
1797 matrix.translate(xi, yi);
1800 xi = x + txWidth / 2.;
1811 matrix.transform(&xi, &yi);
1814 double xx = x - (xi - x);
1819 matrix.translate(-xx, -yy);
1821 matrix.rotate(-angle *
PI / 180.);
1822 matrix.translate(xx, yy);
1823 matrix.transform(&xf, &yf);
1825 agg::path_storage path;
1826 int pathIndex = path.start_new_path();
1827 path.move_to(xx, yy);
1828 path.line_to(xf, yf);
1830 agg::renderer_scanline_aa_solid<agg::renderer_base<pixfmt> > rendererSolid(
m_rendererBase);
1832 agg::trans_single_path tcurve;
1833 tcurve.add_path(path);
1834 tcurve.preserve_x_scale(
true);
1840 fsegm.approximation_scale(3.0);
1841 fcurves.approximation_scale(2.0);
1856 xa += glyph->advance_x;
1857 ya += glyph->advance_y;
1866 matrix.translate(-xx, -yy);
1867 matrix.rotate(-angle *
PI / 180.);
1868 matrix.translate(xx, yy);
1875 pathIndex = path.start_new_path();
1879 matrix.transform(&a, &b);
1883 matrix.transform(&a, &b);
1887 matrix.transform(&a, &b);
1891 matrix.transform(&a, &b);
1893 path.close_polygon(
true);
1897 agg::conv_transform<agg::path_storage> fill(path, matrix);
1898 agg::conv_stroke<agg::conv_transform<agg::path_storage> > stroke(fill);
1909 double x = wp.
getX();
1910 double y = wp.
getY();
1927 agg::trans_affine matrix;
1932 const char*
p = tx.c_str();
1943 xa += glyph->advance_x;
1944 ya += glyph->advance_y;
1948 double txWidth = xa;
1953 matrix.translate(-xi, -yi);
1954 matrix.rotate(-angle *
PI / 180.);
1955 matrix.translate(xi, yi);
1958 xi = x + txWidth / 2.;
1969 matrix.transform(&xi, &yi);
1972 double xx = x - (xi - x);
1977 matrix.translate(-xx, -yy);
1979 matrix.rotate(-angle *
PI / 180.);
1980 matrix.translate(xx, yy);
1981 matrix.transform(&xf, &yf);
1983 agg::path_storage path;
1984 path.start_new_path();
1986 path.move_to(xx, yy);
1987 path.line_to(xf, yf);
1989 agg::renderer_scanline_aa_solid<agg::renderer_base<pixfmt> > rendererSolid(
m_rendererBase);
1991 agg::trans_single_path tcurve;
1992 tcurve.add_path(path);
1993 tcurve.preserve_x_scale(
true);
1999 fsegm.approximation_scale(3.0);
2000 fcurves.approximation_scale(2.0);
2015 xa += glyph->advance_x;
2016 ya += glyph->advance_y;
2025 matrix.translate(-xx, -yy);
2026 matrix.rotate(-angle *
PI / 180.);
2027 matrix.translate(xx, yy);
2040 matrix.transform(&a, &b);
2041 m_matrix.invert().transform(&a, &b);
2046 matrix.transform(&a, &b);
2047 m_matrix.invert().transform(&a, &b);
2052 matrix.transform(&a, &b);
2053 m_matrix.invert().transform(&a, &b);
2058 matrix.transform(&a, &b);
2059 m_matrix.invert().transform(&a, &b);
2067 double x = wp.
getX();
2068 double y = wp.
getY();
2090 double v = (double)opacity/255.;
2096 if(
m_fontEngine->create_font(family.c_str(), agg::glyph_ren_outline) ==
false)
2097 m_fontEngine->create_font(
"Verdana", agg::glyph_ren_outline);
2102 double size = 1.8 * psize;
2105 size_t i = f.find(
",");
2106 if(i != std::string::npos)
2119 size_t i = f.find(
",");
2120 if(i != std::string::npos)
2129 size_t i = f.find(
",");
2130 if(i != std::string::npos)
2181 double v = (double)opacity/255.;
2204 m_ptPatternBuffer = 0;
2221 unsigned int tam = ncols * nrows *
DEPTH/8;
2223 for(i = 0; i < nrows; ++i)
2226 for(j = 0; j < ncols; ++j)
2259 int i, j, wdata, hdata;
2260 unsigned char* data = (
unsigned char*)
getData(fileName, wdata, hdata);
2265 unsigned int tam = wdata * hdata *
DEPTH/8;
2269 for(i = 0; i < hdata; ++i)
2271 int c = i * 3 * wdata;
2272 int d = i * 4 * wdata;
2273 for(j = 0; j < wdata; ++j)
2277 if(data[a] != 0 && data[a+1] != 0 && data[a+2] != 0)
2294 m_linePatternBuffer = 0;
2301 unsigned int tam = ncols * nrows *
DEPTH/8;
2303 for(i = 0; i < nrows; ++i)
2306 for(j = 0; j < ncols; ++j)
2340 int i, j, wdata, hdata;
2341 unsigned char* data = (
unsigned char*)
getData(fileName, wdata, hdata);
2348 for(i = 0; i < hdata; ++i)
2350 int c = i * 3 * wdata;
2351 int d = i * 4 * wdata;
2352 for(j = 0; j < wdata; ++j)
2375 m_polyPatternBuffer = 0;
2382 m_contourPatternBuffer = 0;
2389 unsigned int tam = ncols * nrows *
DEPTH/8;
2391 for(i = 0; i < nrows; ++i)
2394 for(j = 0; j < ncols; ++j)
2426 int a,
b, c,
d, i, j, wdata, hdata;
2427 unsigned char* data = (
unsigned char*)
getData(fileName, wdata, hdata);
2434 for(i = 0; i < hdata; ++i)
2438 for(j = 0; j < wdata; ++j)
2497 unsigned int tam = ncols * nrows *
DEPTH/8;
2499 for(i = 0; i < nrows; ++i)
2502 for(j = 0; j < ncols; ++j)
2536 int i, j, wdata, hdata;
2537 unsigned char* data = (
unsigned char*)
getData(fileName, wdata, hdata);
2544 for(i = 0; i < hdata; ++i)
2546 int c = i * 3 * wdata;
2547 int d = i * 4 * wdata;
2548 for(j = 0; j < wdata; ++j)
2760 if(x == 0 && y == 0 && w == 0 && h == 0)
2780 for(i = 0; i < h; ++i)
2783 for(i = 0; i < h; ++i)
2786 for(j = 0; j < w; ++j)
2801 FILE* fp = fopen(file_name.c_str(),
"wb");
2829 FILE* fp = fopen(file_name.c_str(),
"wb");
2832 fprintf(fp,
"P6 %d %d 255 ",
m_dwidth, m_dheight);
2833 fwrite(buf, 1,
m_dwidth * m_dheight * 3, fp);
2845 std::string fe = te::common::GetFileExtension(fileName);
2855 FILE* fp = fopen(fileName.c_str(),
"rb");
2859 fread(buf, 1, 256, fp);
2867 ss = s.substr(pp, p-pp);
2868 sscanf(ss.c_str(),
"%d", &w);
2871 ss = s.substr(pp, p-pp);
2872 sscanf(ss.c_str(),
"%d", &h);
2882 ss = s.substr(pp, p-pp);
2883 sscanf(ss.c_str(),
"%d %d", &w, &h);
2890 char* data =
new char[size];
2891 fread(data, 1, size, fp);
double m_wllx
Lower left x-coordinate of the World (in the spatial coordinate system of the datasets to be drawn)...
std::size_t getNumRings() const
It returns the number of rings in this CurvePolygon.
agg::trans_affine m_matrix
Matrix that transforms the world coordinate to device coordinate.
std::size_t getNumGeometries() const
It returns the number of geometries in this GeometryCollection.
void setFontFamily(const std::string &family)
It sets the text font family.
char * drawPointZ(char *point)
It draws the point in WKB format on canvas.
agg::pixfmt_rgba32 pixfmt
ImageType
This enum specifies the possible input and output image formats supported by the canvas API...
void save(const char *fileName, te::map::Canvas::ImageType t, int quality=75, int fg=0) const
It saves the canvas content to a file image in the specified format type.
MultiPolygon is a MultiSurface whose elements are Polygons.
void setBackgroundColor(const te::color::RGBAColor &color)
It sets the canvas background color.
TextDecoration getDecoration() const
It returns the font decoration.
void setPolygonFillStyle(te::color::RGBAColor **style, int ncols, int nrows)
It sets the polygon fill style.
font_engine_type * m_fontEngine
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
const double & getLetterSpacing() const
It returns the letter spacing.
int getHeight() const
It returns the canvas height.
void setWindow(const double &llx, const double &lly, const double &urx, const double &ury)
It sets the world (or window) coordinates area (supposing a cartesian reference system).
FontWeight
Font weight for drawing text.
char * getImage(te::map::Canvas::ImageType t, size_t &size) const
It returns the internal contents as an image.
const double & getTextOpacity() const
It returns the text opacity.
void setLineStyle(te::color::RGBAColor **style, int ncols, int nrows)
It sets the line style.
void adjustWorldWindow(double &llx, double &lly, double &urx, double &ury, const HAlignType &ha=HCenter, const VAlignType &va=VCenter)
It adjusts the world (or window) coordinates area (supposing a cartesian reference system)...
int m_dwidth
The device width.
int getRed() const
It returns the red component color value (a value from 0 to 255).
te::color::RGBAColor getBackgroundColor() const
It returns the canvas background color.
double m_wurx
Upper right x-coordinate of the World (in the spatial coordinate system of the datasets to be drawn)...
Coord2D * getCoordinates() const
It returns a pointer to the internal array of coordinates.
void setPolygonContourStyle(te::color::RGBAColor **style, int ncols, int nrows)
It sets the pen style used to draw the boundary of polygon geometries.
color_type m_ptColor
Point color.
int getWidth() const
It returns the canvas width.
void setTextStyle(te::at::FontStyle style)
It sets the text style.
agg::rendering_buffer m_polyPatternRenderingBuffer
void drawPixel(int x, int y)
It sets a pixel using the point pen.
int m_txDecorationType
none=0, underline=1, overline=2 or strikeout=3.
agg::rendering_buffer m_contourPatternRenderingBuffer
const std::string & getFamily() const
It returns the font family.
LineJustification
Line justification for drawing multi line text.
color_type m_polyFillColor
Polygon fill color.
FontStyle
Font style for drawing text.
GeomType getGeomTypeId() const _NOEXCEPT_OP(true)
It returns the geometry subclass type identifier.
double m_wlly
Lower left y-coordinate of the World (in the spatial coordinate system of the datasets to be drawn)...
unsigned char * getBuffer() const
It gets a RGBA colors from buffer.
agg::rendering_buffer * m_rb
int m_dheight
The device height.
color_type m_bgColor
Canvas background color. Defaults: white fully transparent.
void clear()
It clears the canvas content and fills with the background color.
const double & getPointSize() const
It returns the font point size.
int getBlue() const
It returns the blue component color value (a value from 0 to 255).
char * drawGeometry(char *geom)
It draws the geometry in WKB format on canvas.
int getGreen() const
It returns the green component color value (a value from 0 to 255).
agg::int8u * m_contourPatternBuffer
agg::rendering_buffer m_ptPatternRenderingBuffer
color_type m_polyContourColor
Polygon contoyr color.
void drawImage(char *src, int size, te::map::Canvas::ImageType t)
It draws the src pixmap over the canvas.
agg::conv_transform< conv_font_segm_type, agg::trans_single_path > conv_font_trans_type
std::string Convert2UCase(const std::string &value)
It converts a string to upper case.
agg::pixfmt_rgba32_pre pixfmt_pre
agg::conv_segmentator< conv_font_curve_type > conv_font_segm_type
A Text may contain 1 or more Text Elements.
font_manager_type * m_fontManager
unsigned int m_polyPatternWidth
The pattern width used to fill a polygon.
An utility struct for representing 2D coordinates.
void setPointStyle(te::color::RGBAColor **style, int ncols, int nrows)
It sets the point style.
HorizontalAlignment getHorizontalAlignment() const
It returns the horizontal text alignment.
agg::rasterizer_scanline_aa m_rasterizer
double m_wury
Upper right y-coordinate of the World (in the spatial coordinate system of the datasets to be drawn)...
int m_textLineJustification
Text multi line justification.
char * drawMultiPolygon(char *mpoly)
It draws the MultiPolygon in WKB format on canvas.
agg::int8u * m_ptPatternBuffer
#define TE_EWKB_SRID_FLAG
void setPolygonContourColor(const te::color::RGBAColor &color)
It sets the pen color used to draw the boundary of polygon geometries.
void setPolygonPatternWidth(const int &w)
It sets the polycon brush icon width.
void setLineColor(const te::color::RGBAColor &color)
It sets the pen color used to draw line geometries.
const Attributes * getAttributes() const
it returns the text attributes.
const te::gm::Geometry * getLeaderLine() const
it returns the text leader line.
unsigned char m_polyPatternOpacity
The pattern opacity.
color_type m_txBoundaryColor
Text boundary color.
FontStyle getStyle() const
It returns the font style.
TextDecoration
Text decoration for drawing text.
void draw(te::gm::Geometry *geom)
It draws the geometry on canvas.
void setTextWeight(te::at::FontWeight weight)
It sets the text weight.
A LinearRing is a LineString that is both closed and simple.
char * drawMultiPoint(char *mpoint)
It draws the multipoint in WKB format on canvas.
void setLineWidth(const int &w)
It sets the line width.
MultiPoint is a GeometryCollection whose elements are restricted to points.
void setTextMultiLineSpacing(const int &spacing)
It sets the multi line text spacing.
void setTextColor(const te::color::RGBAColor &color)
It sets the text drawing color.
char * getData(const std::string &file_name, int &w, int &h)
LineString is a curve with linear interpolation between points.
char * drawPolygon(char *poly)
It draws the polygon in WKB format on canvas.
HorizontalAlignment
Horizontal alignment for drawing text.
bool write_ppm(const std::string &file_name)
It draws a text.
void setTextUnderline(bool b)
It sets the text underline flag.
te::gm::Polygon * getTextBoundary(int x, int y, const std::string &tx, float angle=0.0, te::at::HorizontalAlignment hAlign=te::at::Start, te::at::VerticalAlignment vAlign=te::at::Baseline)
It returns text boundary.
const double & getY() const
It returns the Point y-coordinate value.
void setTextBoundaryWidth(const int &width)
It sets the text boundary width.
A point with x and y coordinate values.
void setPoint(std::size_t i, const double &x, const double &y)
It sets the value of the specified point.
VerticalAlignment getVerticalAlignment() const
It returns the vertical text alignment.
An Envelope defines a 2D rectangular region.
virtual te::dt::AbstractData * clone() const
It clones the point.
void setTextOpacity(const int &opacity)
It sets the text opacity.
agg::marker_e m_ptMarkerType
const std::vector< Element * > & getElements() const
It returns the elements.
const double & getLineSpacing() const
It returns the multi line spacing.
void drawText(int x, int y, const std::string &tx, float angle=0.0, te::at::HorizontalAlignment hAlign=te::at::Start, te::at::VerticalAlignment vAlign=te::at::Baseline)
It draws a text.
char * drawLineString(char *line)
It draws the line string in WKB format on canvas.
static te::dt::DateTime d(2010, 8, 9, 15, 58, 39)
agg::int8u * m_polyPatternBuffer
int getAlpha() const
It returns the alpha component color value (a value from 0 to 255).
void setTextDecorationColor(const te::color::RGBAColor &color)
It sets the text strike out flag.
std::size_t getNPoints() const
It returns the number of points (vertexes) in the linestring.
void setPointColor(const te::color::RGBAColor &color)
It sets the point drawing color.
void drawTextBoundary(int x, int y, const std::string &tx, float angle=0.0, te::at::HorizontalAlignment hAlign=te::at::Start, te::at::VerticalAlignment vAlign=te::at::Baseline)
It draws the text boundary.
double m_textWordSpacing
Text word spacing.
const std::string & getValue() const
it returns the text string.
char * drawPointM(char *point)
It draws the point in WKB format on canvas.
void setTextOverline(bool b)
It sets the text overline flag.
double m_textLineSpacing
Text multi line spacing.
agg::int8u * m_linePatternBuffer
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
void setTextMultiLineJustification(const te::at::LineJustification &just)
It sets the multi line text justification.
FontWeight getWeight() const
It returns the font weight.
double m_lly
Lower left corner y-coordinate.
Geometry * getGeometryN(std::size_t i) const
It returns the n-th geometry in this GeometryCollection.
void setTextPointSize(double psize)
It sets the text Point Size.
double m_textLetterSpacing
Text letter spacing.
MultiLineString is a MultiCurve whose elements are LineStrings.
pattern_src_brightness_to_alpha_rgba8(agg::rendering_buffer &rb)
void setTextDecorationWidth(int width)
It sets the text strike out flag.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
te::color::RGBAColor ** getColorsFromBuffer(int x=0, int y=0, int w=0, int h=0) const
It gets a RGBA colors from buffer.
void setTextStrikeOut(bool b)
It sets the text strike out flag.
VerticalAlignment
Vertical alignment for drawing text.
double m_ury
Upper right corner y-coordinate.
void setPolygonFillColor(const te::color::RGBAColor &color)
It sets the color used to fill the draw of polygon geometries.
void Convert2OGCWKBType(unsigned int &gType)
It converts the PostGIS geometry type to a pure OGC WKB code.
char * drawPointZM(char *point)
It draws the point in WKB format on canvas.
const te::gm::Geometry * getLocation() const
it returns the text location.
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
color_type m_txColor
Text color.
void setTextBoundaryColor(const te::color::RGBAColor &color)
It sets the text boundary drawing color.
virtual Geometry * getBoundary() const _NOEXCEPT_OP(false)
It returns the geometry boundary.
agg::rendering_buffer m_linePatternRenderingBuffer
LineJustification getLineJustification() const
It returns the multi line justification.
double m_txBoundaryWidth
Text boundary color.
double m_lineWidth
Line width.
char * drawPoint(char *point)
It draws the point in WKB format on canvas.
agg::rendering_buffer m_renderingBuffer
void setPointMarkerType(const ptMarkerType &type)
It sets the point marker type.
agg::rgba8 pixel(int x, int y) const
double m_polyContourWidth
Polygon contour width.
void setPolygonContourWidth(const int &w)
It sets the polycon contour width.
void setY(const double &y)
It sets the Point y-coordinate value.
color_type m_lineColor
Line color.
int m_ptWidth
Point width.
agg::scanline_p8 m_scanline
It is a collection of other geometric objects.
agg::conv_curve< font_manager_type::path_adaptor_type > conv_font_curve_type
char * drawGeometryCollection(char *g)
It draws the GeometryCollection in WKB format on canvas.
char * drawMultiLineString(char *mline)
It draws the MultiLineString in WKB format on canvas.
color_type m_txDecorationColor
void freeImage(char *img) const
This is the method that you should use to release a image generated by the canvas.
const double & getX() const
It returns the Point x-coordinate value.
void resize(int w, int h)
It adjusts the canvas size (width and height).
void setTextBoundaryOpacity(const int &opacity)
It sets the text boundary opacity.
void setPolygonPatternOpacity(const unsigned char &opac)
It sets the polycon brush icon width.
double m_txDecorationWidth
Curve * getRingN(std::size_t i) const
It returns the n-th ring for this curve polygon as a curve.
void setTextStretch(size_t stretch)
It sets the text stretch.
void setRingN(std::size_t i, Curve *r)
It sets the informed position ring to the new one.
agg::renderer_base< pixfmt > m_rendererBase
static agg::int8u brightness_to_alpha[256 *3]
void setPointWidth(int w)
It sets the point drawing color.