Skip to content

Commit 6c0e9b5

Browse files
authored
Merge pull request #262 from mapnik/proj6
Proj6
2 parents a2c2a86 + ca66af6 commit 6c0e9b5

19 files changed

+84
-83
lines changed

mapnik/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def forward(self, projection):
156156
Example: Project the geographic coordinates of the
157157
city center of Stuttgart into the local
158158
map projection (GK Zone 3/DHDN, EPSG 31467)
159-
>>> p = Projection('+init=epsg:31467')
159+
>>> p = Projection('epsg:31467')
160160
>>> Coord(9.1, 48.7).forward(p)
161161
Coord(3507360.12813,5395719.2749)
162162
"""
@@ -176,7 +176,7 @@ def inverse(self, projection):
176176
city center of Stuttgart in the local
177177
map projection (GK Zone 3/DHDN, EPSG 31467)
178178
into geographic coordinates:
179-
>>> p = Projection('+init=epsg:31467')
179+
>>> p = Projection('epsg:31467')
180180
>>> Coord(3507360.12813,5395719.2749).inverse(p)
181181
Coord(9.1, 48.7)
182182
"""

src/mapnik_layer.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,13 @@ void export_layer()
146146
class_<layer>("Layer", "A Mapnik map layer.", init<std::string const&,optional<std::string const&> >(
147147
"Create a Layer with a named string and, optionally, an srs string.\n"
148148
"\n"
149-
"The srs can be either a Proj.4 epsg code ('+init=epsg:<code>') or\n"
150-
"of a Proj.4 literal ('+proj=<literal>').\n"
151-
"If no srs is specified it will default to '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'\n"
149+
"The srs can be either a Proj epsg code ('epsg:<code>') or\n"
150+
"of a Proj literal ('+proj=<literal>').\n"
151+
"If no srs is specified it will default to 'epsg:4326'\n"
152152
"\n"
153153
"Usage:\n"
154154
">>> from mapnik import Layer\n"
155-
">>> lyr = Layer('My Layer','+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')\n"
155+
">>> lyr = Layer('My Layer','epsg:4326')\n"
156156
">>> lyr\n"
157157
"<mapnik._mapnik.Layer object at 0x6a270>\n"
158158
))
@@ -166,7 +166,7 @@ void export_layer()
166166
"\n"
167167
"Usage:\n"
168168
">>> from mapnik import Layer\n"
169-
">>> lyr = Layer('My Layer','+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')\n"
169+
">>> lyr = Layer('My Layer','epsg:4326')\n"
170170
">>> lyr.envelope()\n"
171171
"box2d(-1.0,-1.0,0.0,0.0) # default until a datasource is loaded\n"
172172
)
@@ -183,7 +183,7 @@ void export_layer()
183183
"\n"
184184
"Usage:\n"
185185
">>> from mapnik import Layer\n"
186-
">>> lyr = Layer('My Layer','+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')\n"
186+
">>> lyr = Layer('My Layer','epsg:4326')\n"
187187
">>> lyr.visible(1.0/1000000)\n"
188188
"True\n"
189189
">>> lyr.active = False\n"
@@ -198,7 +198,7 @@ void export_layer()
198198
"\n"
199199
"Usage:\n"
200200
">>> from mapnik import Layer\n"
201-
">>> lyr = Layer('My Layer','+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')\n"
201+
">>> lyr = Layer('My Layer','epsg:4326')\n"
202202
">>> lyr.active\n"
203203
"True # Active by default\n"
204204
">>> lyr.active = False # set False to disable layer rendering\n"
@@ -213,7 +213,7 @@ void export_layer()
213213
"\n"
214214
"Usage:\n"
215215
">>> from mapnik import Layer\n"
216-
">>> lyr = Layer('My Layer','+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')\n"
216+
">>> lyr = Layer('My Layer','epsg:4326')\n"
217217
">>> lyr.status\n"
218218
"True # Active by default\n"
219219
">>> lyr.status = False # set False to disable layer rendering\n"
@@ -250,7 +250,7 @@ void export_layer()
250250
"\n"
251251
"Usage:\n"
252252
">>> from mapnik import Layer, Datasource\n"
253-
">>> lyr = Layer('My Layer','+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')\n"
253+
">>> lyr = Layer('My Layer','epsg:4326')\n"
254254
">>> lyr.datasource = Datasource(type='shape',file='world_borders')\n"
255255
">>> lyr.datasource\n"
256256
"<mapnik.Datasource object at 0x65470>\n"
@@ -285,7 +285,7 @@ void export_layer()
285285
"\n"
286286
"Usage:\n"
287287
">>> from mapnik import Layer\n"
288-
">>> lyr = Layer('My Layer','+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')\n"
288+
">>> lyr = Layer('My Layer','epsg:4326')\n"
289289
">>> lyr.maximum_scale_denominator\n"
290290
"1.7976931348623157e+308 # default is the numerical maximum\n"
291291
">>> lyr.maximum_scale_denominator = 1.0/1000000\n"
@@ -300,7 +300,7 @@ void export_layer()
300300
"\n"
301301
"Usage:\n"
302302
">>> from mapnik import Layer\n"
303-
">>> lyr = Layer('My Layer','+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')\n"
303+
">>> lyr = Layer('My Layer','epsg:4326')\n"
304304
">>> lyr.minimum_scale_denominator # default is 0\n"
305305
"0.0\n"
306306
">>> lyr.minimum_scale_denominator = 1.0/1000000\n"
@@ -315,7 +315,7 @@ void export_layer()
315315
"\n"
316316
"Usage:\n"
317317
">>> from mapnik import Layer\n"
318-
">>> lyr = Layer('My Layer','+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')\n"
318+
">>> lyr = Layer('My Layer','epsg:4326')\n"
319319
">>> lyr.name\n"
320320
"'My Layer'\n"
321321
">>> lyr.name = 'New Name'\n"
@@ -330,7 +330,7 @@ void export_layer()
330330
"\n"
331331
"Usage:\n"
332332
">>> from mapnik import layer\n"
333-
">>> lyr = layer('My layer','+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')\n"
333+
">>> lyr = layer('My layer','epsg:4326')\n"
334334
">>> lyr.queryable\n"
335335
"False # Not queryable by default\n"
336336
">>> lyr.queryable = True\n"
@@ -345,12 +345,12 @@ void export_layer()
345345
"\n"
346346
"Usage:\n"
347347
">>> from mapnik import layer\n"
348-
">>> lyr = layer('My layer','+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')\n"
348+
">>> lyr = layer('My layer','epsg:4326')\n"
349349
">>> lyr.srs\n"
350-
"'+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' # The default srs if not initialized with custom srs\n"
351-
">>> # set to google mercator with Proj.4 literal\n"
350+
"'epsg:4326' # The default srs if not initialized with custom srs\n"
351+
">>> # set to google mercator with Proj literal\n"
352352
"... \n"
353-
">>> lyr.srs = '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over'\n"
353+
">>> lyr.srs = 'epsg:3857'\n"
354354
)
355355

356356
.add_property("group_by",
@@ -367,7 +367,7 @@ void export_layer()
367367
"\n"
368368
"Usage:\n"
369369
">>> from mapnik import layer\n"
370-
">>> lyr = layer('My layer','+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')\n"
370+
">>> lyr = layer('My layer','epsg:4326')\n"
371371
">>> lyr.styles\n"
372372
"<mapnik._mapnik.Names object at 0x6d3e8>\n"
373373
">>> len(lyr.styles)\n"

src/mapnik_map.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -165,17 +165,17 @@ void export_map()
165165
class_<Map>("Map","The map object.",init<int,int,optional<std::string const&> >(
166166
( arg("width"),arg("height"),arg("srs") ),
167167
"Create a Map with a width and height as integers and, optionally,\n"
168-
"an srs string either with a Proj.4 epsg code ('+init=epsg:<code>')\n"
169-
"or with a Proj.4 literal ('+proj=<literal>').\n"
170-
"If no srs is specified the map will default to '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'\n"
168+
"an srs string either with a Proj epsg code ('epsg:<code>')\n"
169+
"or with a Proj literal ('+proj=<literal>').\n"
170+
"If no srs is specified the map will default to 'epsg:4326'\n"
171171
"\n"
172172
"Usage:\n"
173173
">>> from mapnik import Map\n"
174174
">>> m = Map(600,400)\n"
175175
">>> m\n"
176176
"<mapnik._mapnik.Map object at 0x6a240>\n"
177177
">>> m.srs\n"
178-
"'+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'\n"
178+
"'epsg:4326'\n"
179179
))
180180

181181
.def("append_style",insert_style,
@@ -502,22 +502,22 @@ void export_map()
502502
.add_property("srs",
503503
make_function(&Map::srs,return_value_policy<copy_const_reference>()),
504504
&Map::set_srs,
505-
"Spatial reference in Proj.4 format.\n"
505+
"Spatial reference in Proj format.\n"
506506
"Either an epsg code or proj literal.\n"
507507
"For example, a proj literal:\n"
508-
"\t'+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'\n"
508+
"\t'epsg:4326'\n"
509509
"and a proj epsg code:\n"
510-
"\t'+init=epsg:4326'\n"
510+
"\t'epsg:4326'\n"
511511
"\n"
512512
"Note: using epsg codes requires the installation of\n"
513-
"the Proj.4 'epsg' data file normally found in '/usr/local/share/proj'\n"
513+
"the Proj 'epsg' data file normally found in '/usr/local/share/proj'\n"
514514
"\n"
515515
"Usage:\n"
516516
">>> m.srs\n"
517-
"'+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' # The default srs if not initialized with custom srs\n"
517+
"'epsg:4326' # The default srs if not initialized with custom srs\n"
518518
">>> # set to google mercator with Proj.4 literal\n"
519519
"... \n"
520-
">>> m.srs = '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over'\n"
520+
">>> m.srs = 'epsg:3857'\n"
521521
)
522522

523523
.add_property("width",

src/mapnik_proj_transform.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct proj_transform_pickle_suite : boost::python::pickle_suite
4848
getinitargs(const proj_transform& p)
4949
{
5050
using namespace boost::python;
51-
return boost::python::make_tuple(p.source(),p.dest());
51+
return boost::python::make_tuple(p.definition());
5252
}
5353
};
5454

@@ -62,7 +62,7 @@ mapnik::coord2d forward_transform_c(mapnik::proj_transform& t, mapnik::coord2d c
6262
if (!t.forward(x,y,z)) {
6363
std::ostringstream s;
6464
s << "Failed to forward project "
65-
<< "from " << t.source().params() << " to: " << t.dest().params();
65+
<< t.definition();
6666
throw std::runtime_error(s.str());
6767
}
6868
return mapnik::coord2d(x,y);
@@ -76,7 +76,7 @@ mapnik::coord2d backward_transform_c(mapnik::proj_transform& t, mapnik::coord2d
7676
if (!t.backward(x,y,z)) {
7777
std::ostringstream s;
7878
s << "Failed to back project "
79-
<< "from " << t.dest().params() << " to: " << t.source().params();
79+
<< t.definition();
8080
throw std::runtime_error(s.str());
8181
}
8282
return mapnik::coord2d(x,y);
@@ -88,7 +88,7 @@ mapnik::box2d<double> forward_transform_env(mapnik::proj_transform& t, mapnik::b
8888
if (!t.forward(new_box)) {
8989
std::ostringstream s;
9090
s << "Failed to forward project "
91-
<< "from " << t.source().params() << " to: " << t.dest().params();
91+
<< t.definition();
9292
throw std::runtime_error(s.str());
9393
}
9494
return new_box;
@@ -100,7 +100,7 @@ mapnik::box2d<double> backward_transform_env(mapnik::proj_transform& t, mapnik::
100100
if (!t.backward(new_box)){
101101
std::ostringstream s;
102102
s << "Failed to back project "
103-
<< "from " << t.dest().params() << " to: " << t.source().params();
103+
<< t.definition();
104104
throw std::runtime_error(s.str());
105105
}
106106
return new_box;
@@ -112,7 +112,7 @@ mapnik::box2d<double> forward_transform_env_p(mapnik::proj_transform& t, mapnik:
112112
if (!t.forward(new_box,points)) {
113113
std::ostringstream s;
114114
s << "Failed to forward project "
115-
<< "from " << t.source().params() << " to: " << t.dest().params();
115+
<< t.definition();
116116
throw std::runtime_error(s.str());
117117
}
118118
return new_box;
@@ -124,7 +124,7 @@ mapnik::box2d<double> backward_transform_env_p(mapnik::proj_transform& t, mapnik
124124
if (!t.backward(new_box,points)){
125125
std::ostringstream s;
126126
s << "Failed to back project "
127-
<< "from " << t.dest().params() << " to: " << t.source().params();
127+
<< t.definition();
128128
throw std::runtime_error(s.str());
129129
}
130130
return new_box;
@@ -136,14 +136,15 @@ void export_proj_transform ()
136136
{
137137
using namespace boost::python;
138138

139-
class_<proj_transform, boost::noncopyable>("ProjTransform", init< projection const&, projection const& >())
139+
class_<proj_transform, boost::noncopyable>("ProjTransform", init<projection const&, projection const&>())
140140
.def_pickle(proj_transform_pickle_suite())
141141
.def("forward", forward_transform_c)
142142
.def("backward",backward_transform_c)
143143
.def("forward", forward_transform_env)
144144
.def("backward",backward_transform_env)
145145
.def("forward", forward_transform_env_p)
146146
.def("backward",backward_transform_env_p)
147+
.def("definition",&proj_transform::definition)
147148
;
148149

149150
}

src/mapnik_projection.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ void export_projection ()
9595
using namespace boost::python;
9696

9797
class_<projection>("Projection", "Represents a map projection.",init<std::string const&>(
98-
(arg("proj4_string")),
99-
"Constructs a new projection from its PROJ.4 string representation.\n"
98+
(arg("proj_string")),
99+
"Constructs a new projection from its PROJ string representation.\n"
100100
"\n"
101101
"The constructor will throw a RuntimeError in case the projection\n"
102102
"cannot be initialized.\n"
@@ -105,9 +105,9 @@ void export_projection ()
105105
.def_pickle(projection_pickle_suite())
106106
.def ("params", make_function(&projection::params,
107107
return_value_policy<copy_const_reference>()),
108-
"Returns the PROJ.4 string for this projection.\n")
108+
"Returns the PROJ string for this projection.\n")
109109
.def ("expanded",&projection::expanded,
110-
"normalize PROJ.4 definition by expanding +init= syntax\n")
110+
"normalize PROJ definition by expanding epsg:XXXX syntax\n")
111111
.add_property ("geographic", &projection::is_geographic,
112112
"This property is True if the projection is a geographic projection\n"
113113
"(i.e. it uses lon/lat coordinates)\n")

src/mapnik_python.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -598,9 +598,9 @@ std::string mapnik_version_string()
598598
return MAPNIK_VERSION_STRING;
599599
}
600600

601-
bool has_proj4()
601+
bool has_proj()
602602
{
603-
#if defined(MAPNIK_USE_PROJ4)
603+
#if defined(MAPNIK_USE_PROJ)
604604
return true;
605605
#else
606606
return false;
@@ -1035,8 +1035,8 @@ BOOST_PYTHON_MODULE(_mapnik)
10351035
">>> m = Map(256,256)\n"
10361036
">>> load_map(m,'mapfile_wgs84.xml')\n"
10371037
">>> m.srs\n"
1038-
"'+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'\n"
1039-
">>> m.srs = '+init=espg:3395'\n"
1038+
"'epsg:4326'\n"
1039+
">>> m.srs = 'espg:3395'\n"
10401040
">>> save_map(m,'mapfile_mercator.xml')\n"
10411041
"\n"
10421042
);
@@ -1045,7 +1045,7 @@ BOOST_PYTHON_MODULE(_mapnik)
10451045
def("save_map_to_string", &save_map_to_string, save_map_to_string_overloads());
10461046
def("mapnik_version", &mapnik_version,"Get the Mapnik version number");
10471047
def("mapnik_version_string", &mapnik_version_string,"Get the Mapnik version string");
1048-
def("has_proj4", &has_proj4, "Get proj4 status");
1048+
def("has_proj", &has_proj, "Get proj status");
10491049
def("has_jpeg", &has_jpeg, "Get jpeg read/write support status");
10501050
def("has_png", &has_png, "Get png read/write support status");
10511051
def("has_tiff", &has_tiff, "Get tiff read/write support status");

test/data

Submodule data updated 85 files

test/data-visual

Submodule data-visual updated 2658 files

test/python_tests/agg_rasterizer_integer_overflow_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
def test_that_coordinates_do_not_overflow_and_polygon_is_rendered_memory():
2929
expected_color = mapnik.Color('white')
30-
projection = '+init=epsg:4326'
30+
projection = 'epsg:4326'
3131
ds = mapnik.MemoryDatasource()
3232
context = mapnik.Context()
3333
feat = mapnik.Feature.from_geojson(json.dumps(geojson), context)
@@ -57,7 +57,7 @@ def test_that_coordinates_do_not_overflow_and_polygon_is_rendered_memory():
5757

5858
def test_that_coordinates_do_not_overflow_and_polygon_is_rendered_csv():
5959
expected_color = mapnik.Color('white')
60-
projection = '+init=epsg:4326'
60+
projection = 'epsg:4326'
6161
ds = mapnik.MemoryDatasource()
6262
context = mapnik.Context()
6363
feat = mapnik.Feature.from_geojson(json.dumps(geojson), context)

test/python_tests/datasource_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def test_that_datasources_exist():
2929

3030
@raises(RuntimeError)
3131
def test_vrt_referring_to_missing_files():
32-
srs = '+init=epsg:32630'
32+
srs = 'epsg:32630'
3333
if 'gdal' in mapnik.DatasourceCache.plugin_names():
3434
lyr = mapnik.Layer('dataraster')
3535
lyr.datasource = mapnik.Gdal(

0 commit comments

Comments
 (0)