Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Main Repositories
otb
Commits
3e982a14
Commit
3e982a14
authored
Mar 25, 2009
by
Emmanuel Christophe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New version
parent
45fa7ce5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
97 additions
and
0 deletions
+97
-0
myOwnMapnik.cxx
myOwnMapnik.cxx
+97
-0
No files found.
myOwnMapnik.cxx
0 → 100644
View file @
3e982a14
#define BOOST_SPIRIT_THREADSAFE
#include <mapnik/map.hpp>
#include <mapnik/datasource_cache.hpp>
#include <mapnik/font_engine_freetype.hpp>
#include <mapnik/agg_renderer.hpp>
#include <mapnik/filter_factory.hpp>
#include <mapnik/color_factory.hpp>
#include <mapnik/image_util.hpp>
#include <mapnik/config_error.hpp>
#include <mapnik/memory_datasource.hpp>
#include <iostream>
int
main
(
int
argc
,
char
**
argv
)
{
using
namespace
mapnik
;
datasource_cache
::
instance
()
->
register_datasources
(
"/home/christop/opensource/mapnik/plugins/input/shape"
);
freetype_engine
::
register_font
(
"/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf"
);
Map
m
(
800
,
600
);
m
.
set_background
(
color_factory
::
from_string
(
"cadetblue"
));
// {
// feature_type_style style;
// rule_type rule;
// rule.append(polygon_symbolizer(color(250, 190, 183)));
// rule.append(line_symbolizer(color('rgb(50%,50%,50%)'),0.1));
// style.add_rule(rule);
// m.insert_style("world",style);
// }
{
feature_type_style
style
;
rule_type
rule
;
rule
.
set_max_scale
(
250000000000LLU
);
rule
.
set_min_scale
(
600000
);
rule
.
append
(
polygon_symbolizer
(
color
(
"#f2efe9"
)));
style
.
add_rule
(
rule
);
m
.
insert_style
(
"world"
,
style
);
}
{
feature_type_style
style
;
rule_type
rule
;
rule
.
set_max_scale
(
600000
);
rule
.
append
(
polygon_symbolizer
(
color
(
"#f2efe9"
)));
style
.
add_rule
(
rule
);
m
.
insert_style
(
"coast-poly"
,
style
);
}
typedef
vertex
<
double
,
2
>
vertex2d
;
typedef
line_string
<
vertex2d
,
vertex_vector2
>
line2d
;
typedef
boost
::
shared_ptr
<
line2d
>
line_ptr
;
geometry2d
*
line
=
new
line2d
;
// vertex2d.x = 0;
// vertex2d.y = 0;
std
::
cout
<<
line
->
num_points
()
<<
std
::
endl
;
line
->
line_to
(
0
,
0
);
line
->
line_to
(
45
,
45
);
line
->
line_to
(
50
,
30
);
line
->
line_to
(
0
,
-
30
);
std
::
cout
<<
line
->
num_points
()
<<
std
::
endl
;
typedef
boost
::
shared_ptr
<
raster
>
raster_ptr
;
typedef
feature
<
geometry2d
,
raster_ptr
>
Feature
;
typedef
boost
::
shared_ptr
<
Feature
>
feature_ptr
;
feature_ptr
mfeature
=
feature_ptr
(
new
Feature
(
1
));
mfeature
->
add_geometry
(
line
);
typedef
boost
::
shared_ptr
<
memory_datasource
>
datasource_ptr
;
datasource_ptr
mDatasource
=
datasource_ptr
(
new
memory_datasource
);
mDatasource
->
push
(
mfeature
);
parameters
p
;
p
[
"type"
]
=
"shape"
;
p
[
"file"
]
=
"world_borders"
;
Layer
lyr
(
"world"
);
// lyr.set_datasource(datasource_cache::instance()->create(p));
lyr
.
set_datasource
(
mDatasource
);
lyr
.
add_style
(
"world"
);
m
.
addLayer
(
lyr
);
m
.
zoomToBox
(
lyr
.
envelope
());
Image32
buf
(
m
.
getWidth
(),
m
.
getHeight
());
agg_renderer
<
Image32
>
ren
(
m
,
buf
);
ren
.
apply
();
save_to_file
<
ImageData32
>
(
buf
.
data
(),
"myOwn.png"
,
"png"
);
return
EXIT_SUCCESS
;
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment