Automatically triggering export as PDF from openstreetmap.org -> share?

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Automatically triggering export as PDF from openstreetmap.org -> share?

Bjoern Hassler
Dear friends,

Suppose I have a standard OSM URL, e.g. as follows:

Is it possible to automatically produce a PDF, say via URL something like this:

URL2 = URL1?format=PDF&dimensions=800x1000&scale=2500

The idea would be to produce a PDF in the same way as manually going to export, selecting format PDF, scale 1:2500 and dimensions 800x1000?

I suppose there would be some kind of POST request that could be done, that simulates the form input? Would be great to have a script I could use, rather than trying to figure it out. I would be most grateful for any suggestions!!

Many thanks,
Bjoern

_______________________________________________
dev mailing list
[hidden email]
https://lists.openstreetmap.org/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: Automatically triggering export as PDF from openstreetmap.org -> share?

Frederik Ramm
Bjoern,

On 12/21/2017 09:40 PM, Bjoern Hassler wrote:
> The idea would be to produce a PDF in the same way as manually going to
> export, selecting format PDF, scale 1:2500 and dimensions 800x1000?

The current usage policies in

https://operations.osmfoundation.org/policies/tiles/

say that

"Calls to /cgi-bin/export may only be triggered by direct end-user
action. (For example: “click here to export”.) The export call is an
expensive (CPU+RAM) function to run and will frequently reject when
server is under high load."

so using a script to produce these PDFs would violate the policy except
in rare circumstances where running the script is triggered by a user
request.

What you could do instead:

* download and stitch tiles, convert to PDF; search for "OSM bigmap" for
different implementations.

* use the "staticmap" script on openstreetmap.de like this:
http://staticmap.openstreetmap.de/staticmap.php?center=40,-50&zoom=2&size=500x350

Both will only give you standard resolution raster images. You could
also try

* https://maposmatic.osm-baustelle.de/ (a working fork of the
discontinued MapOsMatic project, does PDFs)

or the somewhat idiosyncratic but powerful

* http://printmaps-osm.de:8080/ (Europe only, quarterly data updates,
does PDFs in theory but currently only PNG works)

or if you're on Windows or willing to use Mono, Maperitive can also
generate PDFs for any region using data from Overpass, and it's
scriptable (even headless).

Of course, the canonical solution is "install your own
postgres/mapnik/nik4.py and run it locally" ;)

Bye
Frederik

--
Frederik Ramm  ##  eMail [hidden email]  ##  N49°00'09" E008°23'33"

_______________________________________________
dev mailing list
[hidden email]
https://lists.openstreetmap.org/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: Automatically triggering export as PDF from openstreetmap.org -> share?

Paul Norman
On 12/21/2017 2:01 PM, Frederik Ramm wrote:
> Of course, the canonical solution is "install your own
> postgres/mapnik/nik4.py and run it locally";)

If you are intending to generate a PDF with Mapnik I recommend
generating a 300-600 dpi raster PNG and embedding it in a PDF.

_______________________________________________
dev mailing list
[hidden email]
https://lists.openstreetmap.org/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: Automatically triggering export as PDF from openstreetmap.org -> share?

Bjoern Hassler
In reply to this post by Frederik Ramm
Dear Frederik, dear Paul,

Thank you for your message! I suppose I made the mistake of asking for a technical fix, rather than fully explaining the problem...

I have 40 small, discontinues areas in Ghana (the 40 public colleges of education), like this
and I want to produce print. The files itself will be downloaded locally (or emailed), and then printed locally. So the file needs to be small, and print resolution (say for A2 or A3).

We're actively editing this at the moment (and have been over the last year), so we'd like to print from up-to-date data.

Print + small files, means PDF, as its vector, and can be printed at any size. I assume PNG at 300dpi, A3, would be massive.

There aren't loads of areas, and manual export would be ok. However, because the areas are discontinuous, I am looking for a solution where I can work from lat/lon, rather than having to manually select areas. Once this would be ok, but we'd like to be able to repeat the export later. Most tools don't allow you to go back to maps that you've already produced, to reprint simply with data a year on.



https://operations.osmfoundation.org/policies/tiles/
...
so using a script to produce these PDFs would violate the policy except
in rare circumstances where running the script is triggered by a user
request.

I'd be quite happy to click manually. At the moment, I enter the values for scale manually, resize the browser window so it gives me the right nominal dimensions (for PDF), then export. However, it would be helpful to have a preconfigured link, that gives me my settings (scale, dimensions). 

* download and stitch tiles, convert to PDF; search for "OSM bigmap" for
different implementations.
* use the "staticmap" script on openstreetmap.de like this:
http://staticmap.openstreetmap.de/staticmap.php?center=40,-50&zoom=2&size=500x350

Both will only give you standard resolution raster images.

As above, vector would be preferable.
 
You could
also try

* https://maposmatic.osm-baustelle.de/ (a working fork of the
discontinued MapOsMatic project, does PDFs)

I'll see whether it's possible to generate maps of predefined areas or re-print maps (with the same boundaries). At least from the web UI, it doesn't look like it.
 
* http://printmaps-osm.de:8080/ (Europe only, quarterly data updates,
does PDFs in theory but currently only PNG works)

I'm outside Europe, and need up-to-date data.
 
or if you're on Windows or willing to use Mono, Maperitive can also
generate PDFs for any region using data from Overpass, and it's
scriptable (even headless).

OK, I'll have a look. However, it looks like it produces only SVG, which I'd then have to process. 
 

Of course, the canonical solution is "install your own
postgres/mapnik/nik4.py and run it locally" ;)


Paul, why is the recommendation to produce PNG first?
 
Thanks both for you input - much appreciated!!
Bjoern


_______________________________________________
dev mailing list
[hidden email]
https://lists.openstreetmap.org/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: Automatically triggering export as PDF from openstreetmap.org -> share?

Yves
Have a look at the print function at Opensnowmap.org, it's just a bit of Javascript and Leaflet or Openlayers to achieve a pdf printing from a browser.
Yves

Le 22 décembre 2017 10:06:00 GMT+01:00, Bjoern Hassler <[hidden email]> a écrit :
Dear Frederik, dear Paul,

Thank you for your message! I suppose I made the mistake of asking for a technical fix, rather than fully explaining the problem...

I have 40 small, discontinues areas in Ghana (the 40 public colleges of education), like this
and I want to produce print. The files itself will be downloaded locally (or emailed), and then printed locally. So the file needs to be small, and print resolution (say for A2 or A3).

We're actively editing this at the moment (and have been over the last year), so we'd like to print from up-to-date data.

Print + small files, means PDF, as its vector, and can be printed at any size. I assume PNG at 300dpi, A3, would be massive.

There aren't loads of areas, and manual export would be ok. However, because the areas are discontinuous, I am looking for a solution where I can work from lat/lon, rather than having to manually select areas. Once this would be ok, but we'd like to be able to repeat the export later. Most tools don't allow you to go back to maps that you've already produced, to reprint simply with data a year on.



https://operations.osmfoundation.org/policies/tiles/
...
so using a script to produce these PDFs would violate the policy except
in rare circumstances where running the script is triggered by a user
request.

I'd be quite happy to click manually. At the moment, I enter the values for scale manually, resize the browser window so it gives me the right nominal dimensions (for PDF), then export. However, it would be helpful to have a preconfigured link, that gives me my settings (scale, dimensions). 

* download and stitch tiles, convert to PDF; search for "OSM bigmap" for
different implementations.
* use the "staticmap" script on openstreetmap.de like this:
http://staticmap.openstreetmap.de/staticmap.php?center=40,-50&zoom=2&size=500x350

Both will only give you standard resolution raster images.

As above, vector would be preferable.
 
You could
also try

* https://maposmatic.osm-baustelle.de/ (a working fork of the
discontinued MapOsMatic project, does PDFs)

I'll see whether it's possible to generate maps of predefined areas or re-print maps (with the same boundaries). At least from the web UI, it doesn't look like it.
 
* http://printmaps-osm.de:8080/ (Europe only, quarterly data updates,
does PDFs in theory but currently only PNG works)

I'm outside Europe, and need up-to-date data.
 
or if you're on Windows or willing to use Mono, Maperitive can also
generate PDFs for any region using data from Overpass, and it's
scriptable (even headless).

OK, I'll have a look. However, it looks like it produces only SVG, which I'd then have to process. 
 

Of course, the canonical solution is "install your own
postgres/mapnik/nik4.py and run it locally" ;)


Paul, why is the recommendation to produce PNG first?
 
Thanks both for you input - much appreciated!!
Bjoern


_______________________________________________
dev mailing list
[hidden email]
https://lists.openstreetmap.org/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: Automatically triggering export as PDF from openstreetmap.org -> share?

joost
In reply to this post by Bjoern Hassler
I'm not familiar with the exact workflow in QGIS, but I think you could probably fully automate this process with it.

On the data side, just download a county PBF file (for example from geofabrik), and convert it to a database. I always use spatialite for things like this, here's a manual: https://github.com/osmbe/qgis_rendering/blob/master/qgis-loves-spatialite.md
Or you could use the shapefiles provided there.

Then you need a set of rendering rules. There seem to be some basic styles around that you could reuse:
Updating your maps would just be a matter of replacing the source files.

Third, you should be able to rotate through the set of places with the Atlas function.
Last, export to PDF; I have no idea if QGIS can produce the kind of PDFs you need.

2017-12-22 10:06 GMT+01:00 Bjoern Hassler <[hidden email]>:
Dear Frederik, dear Paul,

Thank you for your message! I suppose I made the mistake of asking for a technical fix, rather than fully explaining the problem...

I have 40 small, discontinues areas in Ghana (the 40 public colleges of education), like this
and I want to produce print. The files itself will be downloaded locally (or emailed), and then printed locally. So the file needs to be small, and print resolution (say for A2 or A3).

We're actively editing this at the moment (and have been over the last year), so we'd like to print from up-to-date data.

Print + small files, means PDF, as its vector, and can be printed at any size. I assume PNG at 300dpi, A3, would be massive.

There aren't loads of areas, and manual export would be ok. However, because the areas are discontinuous, I am looking for a solution where I can work from lat/lon, rather than having to manually select areas. Once this would be ok, but we'd like to be able to repeat the export later. Most tools don't allow you to go back to maps that you've already produced, to reprint simply with data a year on.



https://operations.osmfoundation.org/policies/tiles/
...
so using a script to produce these PDFs would violate the policy except
in rare circumstances where running the script is triggered by a user
request.

I'd be quite happy to click manually. At the moment, I enter the values for scale manually, resize the browser window so it gives me the right nominal dimensions (for PDF), then export. However, it would be helpful to have a preconfigured link, that gives me my settings (scale, dimensions). 

* download and stitch tiles, convert to PDF; search for "OSM bigmap" for
different implementations.
* use the "staticmap" script on openstreetmap.de like this:
http://staticmap.openstreetmap.de/staticmap.php?center=40,-50&zoom=2&size=500x350

Both will only give you standard resolution raster images.

As above, vector would be preferable.
 
You could
also try

* https://maposmatic.osm-baustelle.de/ (a working fork of the
discontinued MapOsMatic project, does PDFs)

I'll see whether it's possible to generate maps of predefined areas or re-print maps (with the same boundaries). At least from the web UI, it doesn't look like it.
 
* http://printmaps-osm.de:8080/ (Europe only, quarterly data updates,
does PDFs in theory but currently only PNG works)

I'm outside Europe, and need up-to-date data.
 
or if you're on Windows or willing to use Mono, Maperitive can also
generate PDFs for any region using data from Overpass, and it's
scriptable (even headless).

OK, I'll have a look. However, it looks like it produces only SVG, which I'd then have to process. 
 

Of course, the canonical solution is "install your own
postgres/mapnik/nik4.py and run it locally" ;)


Paul, why is the recommendation to produce PNG first?
 
Thanks both for you input - much appreciated!!
Bjoern


_______________________________________________
dev mailing list
[hidden email]
https://lists.openstreetmap.org/listinfo/dev




--
Joost Schouppe

_______________________________________________
dev mailing list
[hidden email]
https://lists.openstreetmap.org/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: Automatically triggering export as PDF from openstreetmap.org -> share?

dieterdreist
2017-12-22 10:27 GMT+01:00 joost schouppe <[hidden email]>:

Third, you should be able to rotate through the set of places with the Atlas function.
Last, export to PDF; I have no idea if QGIS can produce the kind of PDFs you need.


I've also recently made some maps for print with QGIS. As Joost says, you will usually get a pbf osm file, import it into a database (I'm using the standard osm2pgsql with latlong for this with hstore, although my QGIS versions requires to create views for selecting hstore fields, which makes it a bit more tedious, in the end I got it working). I'm using latlong because I'm reprojecting on the fly to different systems in different areas.

QGIS lets you export / print to raster (png), pdf (AFAIK both, raster and vector, there's an option "print as raster") and svg (not working well, e.g. I had problems with uncropped lines at the border). Depending on your settings (resolution, scale and feature density on the map), it is not a given that a vector representation will produce smaller files in any case (when zoomed in you will usually get smaller files, if there is a lot of detail in a large scale map, you will not see it in the print, but it will inflate your file).

Cheers,
Martin

_______________________________________________
dev mailing list
[hidden email]
https://lists.openstreetmap.org/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: Automatically triggering export as PDF from openstreetmap.org -> share?

Bjoern Hassler
Hi Joost, hi Martin,

thanks for the comments - I'll have a look. I may just print the maps by hand from the OSM site for now, and look into more advanced options in the future.

QGIS lets you export / print to raster (png), pdf (AFAIK both, raster and vector, there's an option "print as raster") and svg (not working well, e.g. I had problems with uncropped lines at the border). Depending on your settings (resolution, scale and feature density on the map), it is not a given that a vector representation will produce smaller files in any case (when zoomed in you will usually get smaller files, if there is a lot of detail in a large scale map, you will not see it in the print, but it will inflate your file).

Yes of course - that's very true! In my case, I'm producing maps a few 100m across (the size of a college).
 
Many thanks again!
Bjoern

_______________________________________________
dev mailing list
[hidden email]
https://lists.openstreetmap.org/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: Automatically triggering export as PDF from openstreetmap.org -> share?

Hartmut Holzgraefe-2
In reply to this post by Bjoern Hassler
Am 22. Dezember 2017 10:06:00 MEZ schrieb Bjoern Hassler <[hidden email]>:

>Dear Frederik, dear Paul,
>
>Thank you for your message! I suppose I made the mistake of asking for
>a
>technical fix, rather than fully explaining the problem...
>
>I have 40 small, discontinues areas in Ghana (the 40 public colleges of
>education), like this
>http://www.openstreetmap.org/way/450562441#map=16/7.4129/0.4631
>and I want to produce print. The files itself will be downloaded
>locally
>(or emailed), and then printed locally. So the file needs to be small,
>and
>print resolution (say for A2 or A3).
>
>We're actively editing this at the moment (and have been over the last
>year), so we'd like to print from up-to-date data.
>
>Print + small files, means PDF, as its vector, and can be printed at
>any
>size. I assume PNG at 300dpi, A3, would be massive.
>
>There aren't loads of areas, and manual export would be ok. However,
>because the areas are discontinuous, I am looking for a solution where
>I
>can work from lat/lon, rather than having to manually select areas.
>Once
>this would be ok, but we'd like to be able to repeat the export later.

Maposmatic allows for this, it renders several vector and bitmap formats and you can then select the smallest.

Rendered results are only stored for a limited time, but you can request re-render with same settings, but up-to-date
data later if you save the result URL

On mobile right now, will write a
bit more later ...

>Most
>tools don't allow you to go back to maps that you've already produced,
>to
>reprint simply with data a year on.
>
>
>
>> https://operations.osmfoundation.org/policies/tiles/
>> ...
>
>so using a script to produce these PDFs would violate the policy except
>> in rare circumstances where running the script is triggered by a user
>> request.
>>
>
>I'd be quite happy to click manually. At the moment, I enter the values
>for
>scale manually, resize the browser window so it gives me the right
>nominal
>dimensions (for PDF), then export. However, it would be helpful to have
>a
>preconfigured link, that gives me my settings (scale, dimensions).
>
>>
>> * download and stitch tiles, convert to PDF; search for "OSM bigmap"
>for
>> different implementations.
>
>* use the "staticmap" script on openstreetmap.de like this:
>>
>http://staticmap.openstreetmap.de/staticmap.php?center=40,-50&zoom=2&size=
>> 500x350
>>
>> Both will only give you standard resolution raster images.
>
>
>As above, vector would be preferable.
>
>
>> You could
>> also try
>>
>> * https://maposmatic.osm-baustelle.de/ (a working fork of the
>> discontinued MapOsMatic project, does PDFs)
>>
>
>I'll see whether it's possible to generate maps of predefined areas or
>re-print maps (with the same boundaries). At least from the web UI, it
>doesn't look like it.
>
>
>> * http://printmaps-osm.de:8080/ (Europe only, quarterly data updates,
>> does PDFs in theory but currently only PNG works)
>>
>
>I'm outside Europe, and need up-to-date data.
>
>
>> or if you're on Windows or willing to use Mono, Maperitive can also
>> generate PDFs for any region using data from Overpass, and it's
>> scriptable (even headless).
>>
>
>OK, I'll have a look. However, it looks like it produces only SVG,
>which
>I'd then have to process.
>
>
>>
>> Of course, the canonical solution is "install your own
>> postgres/mapnik/nik4.py and run it locally" ;)
>>
>>
>Paul, why is the recommendation to produce PNG first?
>
>Thanks both for you input - much appreciated!!
>Bjoern


--
Sent from my Android device with K-9 Mail. Please excuse my brevity.

_______________________________________________
dev mailing list
[hidden email]
https://lists.openstreetmap.org/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: Automatically triggering export as PDF from openstreetmap.org -> share?

Hartmut Holzgraefe-2
In reply to this post by Bjoern Hassler
Hello Bjoern,

On 22.12.2017 10:06, Bjoern Hassler wrote:

> Dear Frederik, dear Paul,
>
> Thank you for your message! I suppose I made the mistake of asking for a
> technical fix, rather than fully explaining the problem...
>
> I have 40 small, discontinues areas in Ghana (the 40 public colleges of
> education), like this
> http://www.openstreetmap.org/way/450562441#map=16/7.4129/0.4631 
> <http://www.openstreetmap.org/way/450562441#map=16/7.4129/0.4631>
> and I want to produce print. The files itself will be downloaded locally
> (or emailed), and then printed locally. So the file needs to be small,
> and print resolution (say for A2 or A3).

See

https://maposmatic.osm-baustelle.de/maps/10931

for a A2 example of Jasikan

> We're actively editing this at the moment (and have been over the last
> year), so we'd like to print from up-to-date data.
>
> Print + small files, means PDF, as its vector, and can be printed at any
> size. I assume PNG at 300dpi, A3, would be massive.

At DIN A2 SVG has ~100KB, PDF ~200KB, 300dpi PNG 1.3MB (~650K when using
reduced color space)


> There aren't loads of areas, and manual export would be ok. However,
> because the areas are discontinuous, I am looking for a solution where I
> can work from lat/lon, rather than having to manually select areas.

You can manually enter lat/lon ranges in the selection form, but it is
not very convenient yet.

Selecting by city name is also possible, but only if border polygons
exist.

But at least search works just fine and can give you correct position
at least.

> Once
> this would be ok, but we'd like to be able to repeat the export later.
 >
> Most tools don't allow you to go back to maps that you've already
> produced, to reprint simply with data a year on.

You can re-render the map at any time using the "recreate" icon in
the result page. Unfortunately that's a POST request for now, so
not easy to automate


>     You could
>     also try
>
>     * https://maposmatic.osm-baustelle.de/
>     <https://maposmatic.osm-baustelle.de/> (a working fork of the
>     discontinued MapOsMatic project, does PDFs)
>
>
> I'll see whether it's possible to generate maps of predefined areas or
> re-print maps (with the same boundaries). At least from the web UI, it
> doesn't look like it.

So an API for generating maps from given parameters automatically is
missing, but at least the "re-print with same settings" functionality
is actually there (just not that easy to spot, the "recreate" button
should have a clear label instead of just the icon.


Good news is that I plan to work on this on 34c3 (chaos communication
congress) between christmas and new year, and better automation is high
on the todo list ...

--
hartmut


_______________________________________________
dev mailing list
[hidden email]
https://lists.openstreetmap.org/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: Automatically triggering export as PDF from openstreetmap.org -> share?

Bjoern Hassler
Hi Hartmut,

thank you!

https://maposmatic.osm-baustelle.de/maps/10931

Thanks! 

At DIN A2 SVG has ~100KB, PDF ~200KB, 300dpi PNG 1.3MB (~650K when using
reduced color space)

That's very useful to know, and as suspected. 
 
You can re-render the map at any time using the "recreate" icon in
the result page.

That's also useful!
 
Good news is that I plan to work on this on 34c3 (chaos communication congress) between christmas and new year, and better automation is high
on the todo list ...

That's great! Do keep me informed!

Bjoern
 


--
hartmut



_______________________________________________
dev mailing list
[hidden email]
https://lists.openstreetmap.org/listinfo/dev


_______________________________________________
dev mailing list
[hidden email]
https://lists.openstreetmap.org/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: Automatically triggering export as PDF from openstreetmap.org -> share?

Bjoern Hassler
Dear friends,

thanks for your suggestions so far! 

Another possibility that I have come across is https://inkatlas.com, which offers an API (https://inkatlas.com/docs/), however only as part of the "Pro" paid-for package. As our project is non-profit, the dev's are going to give us access to the API, so we can try this out.

In case people are interested in our project (an atlas of the Ghanaian Colleges of Education), I'll send a link to the final (collated) PDF when we have it.

Suggestions and updates remain very welcome!

Thanks again!
Bjoern

On 23 December 2017 at 13:36, Bjoern Hassler <[hidden email]> wrote:
Hi Hartmut,

thank you!

https://maposmatic.osm-baustelle.de/maps/10931

Thanks! 

At DIN A2 SVG has ~100KB, PDF ~200KB, 300dpi PNG 1.3MB (~650K when using
reduced color space)

That's very useful to know, and as suspected. 
 
You can re-render the map at any time using the "recreate" icon in
the result page.

That's also useful!
 
Good news is that I plan to work on this on 34c3 (chaos communication congress) between christmas and new year, and better automation is high
on the todo list ...

That's great! Do keep me informed!

Bjoern
 


--
hartmut



_______________________________________________
dev mailing list
[hidden email]
https://lists.openstreetmap.org/listinfo/dev



_______________________________________________
dev mailing list
[hidden email]
https://lists.openstreetmap.org/listinfo/dev