We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

Printing maps in the browser with InkMap

00:00

Formale Metadaten

Titel
Printing maps in the browser with InkMap
Serientitel
Anzahl der Teile
237
Autor
Mitwirkende
Lizenz
CC-Namensnennung 3.0 Unported:
Sie dürfen das Werk bzw. den Inhalt zu jedem legalen Zweck nutzen, verändern und in unveränderter oder veränderter Form vervielfältigen, verbreiten und öffentlich zugänglich machen, sofern Sie den Namen des Autors/Rechteinhabers in der von ihm festgelegten Weise nennen.
Identifikatoren
Herausgeber
Erscheinungsjahr
Sprache

Inhaltliche Metadaten

Fachgebiet
Genre
Abstract
Printing web maps is a challenge in terms of performance, precision and flexibility. InkMap aims to conquer this challenge on the front-end. As an open source Javascript library, it facilitates usage and provides fast results without limiting browser performance. Under the hood InkMap makes use of other open source libraries and modern web technologies. Most solutions for printing maps on the web are based on a backend component. They provide a solid and scalable printing engine, but reach their limitations when it comes to flexibility and user interaction, that are usually constrained by static templates. Front end solutions have the potential to enhance user experience and make print compositions possible that can be customized via gestures like drag and drop. While they have traditionally been limited in performance and the data volume they can process, InkMap wants to eliminate this bottleneck with modern web technologies, that allow multi threading inside the browser. The library uses OpenLayers internally to render the printed map.This means that the library can handle many different formats, both for raster or vector data, and rely on a very performant rendering engine. A JSON specification including layers, resolution, scale, etc. defines a print job and serves as input to the print process. As a result, InkMap generates a map in PNG format, that can easily be embedded in a PDF. Inkmap delegates the print job to a service worker. This enables to run the asynchronous task in multiple threads and speed up performance. The application currently in use stays available to the user without affecting its performance. It also implies that multiple print jobs can run in parallel and their progresses can be tracked. The application can even be shut down as long as the browser keeps running. The service worker makes use of the OffscreenCanvas API to print the canvas outside the window. While service workers are widely supported in modern web browsers today, this cannot yet be said for the OffscreenCanvas API. For this case InkMap uses a fallback, to run in the main thread. The presentation will provide an overview of used technologies, the library’s API and configuration. It will demonstrate the integration of InkMap into an existing web mapping library and application on a use case of the French ministry of the ecological transition, which not least was the initiator of the project.
VideokonferenzMetropolitan area networkMathematikBitMultiplikationsoperatorTextur-MappingBenutzerbeteiligungDiagrammBesprechung/Interview
Open SourceTwitter <Softwareplattform>SoftwareentwicklerMaßstabMAPServerAppletDichte <Stochastik>ClientService providerFunktion <Mathematik>Web ServicesKonfiguration <Informatik>BrowserTouchscreenProgrammbibliothekKontrollstrukturHochdruckSpezialrechnerCoxeter-GruppeMAPBenutzerbeteiligungZentrische StreckungBildgebendes VerfahrenTouchscreenLeistung <Physik>Textur-MappingVerkehrsinformationServerGüte der AnpassungElektronische PublikationZentralisatorMapping <Computergraphik>Inverser LimesMultiplikationsoperatorAssemblerHochdruckFitnessfunktionSpielkonsolePlug inDichte <Stochastik>Dienst <Informatik>Projektive EbeneBrowserProgrammbibliothekWeb-ApplikationAbstandZoomFunktion <Mathematik>VektorraumVerzerrungstensorIndexberechnungProzess <Informatik>NeuroinformatikAppletSkalarproduktMereologieMobiles InternetOffene MengeWeb ServicesEinflussgrößeSpannweite <Stochastik>Delisches ProblemOpen SourceSoftwareentwicklerKomplex <Algebra>TemplateFront-End <Software>E-MailGamecontrollerTabellePunktService providerPRINCE2CAN-BusPixelTwitter <Softwareplattform>Rechter WinkelComputerspielCantor-DiskontinuumServiceorientierte ArchitekturFamilie <Mathematik>ParametersystemTopologieWeb SiteWeb-SeiteInformationsspeicherungLastFortsetzung <Mathematik>RuhmasseForcingYouTubeLesen <Datenverarbeitung>JSONXMLUML
ProgrammbibliothekSpezialrechnerOrtsoperatorMetrisches SystemMaßstabOffene MengeDichte <Stochastik>Elektronische PublikationFunktion <Mathematik>PunktZeitbereichTaskClientWeb ServicesThreadDemoszene <Programmierung>Open SourceMapping <Computergraphik>Dichte <Stochastik>BrowserKalkülEin-AusgabeProgrammbibliothekGüte der AnpassungSchlussregelE-MailKartesische KoordinatenProxy ServerZentrische StreckungUmwandlungsenthalpieTextur-MappingProjektive EbeneOffene MengeVektorraumProzess <Informatik>HochdruckFunktion <Mathematik>ThreadMultiplikationsoperatorBimodulFramework <Informatik>DämpfungBildgebendes VerfahrenPunktDomain <Netzwerk>MereologieDemoszene <Programmierung>Attributierte GrammatikMeterRechenwerkDienst <Informatik>VerkehrsinformationMailing-ListeClientDifferenteMixed RealityTabelleObjekt <Kategorie>SchnittmengeGemeinsamer SpeicherGrenzschichtablösungEntscheidungstheorieKontextbezogenes SystemComputerunterstützte ÜbersetzungBitVorhersagbarkeitMehrschichten-PerzeptronCASE <Informatik>DatenverwaltungMinkowski-MetrikTypentheorieTopologieRechter WinkelMinimalgradLesen <Datenverarbeitung>StrömungsrichtungGreen-FunktionOpen SourceMaßerweiterungRenderingPhysikalischer EffektKlasse <Mathematik>Formation <Mathematik>Familie <Mathematik>Komplex <Algebra>Design by ContractSchreib-Lese-KopfWechselsprungWort <Informatik>Überlagerung <Mathematik>Physikalisches SystemWorkstation <Musikinstrument>InternetworkingComputeranimation
MagnettrommelspeicherVorhersagbarkeitSkalarproduktHochdruckElement <Gruppentheorie>QR-CodeDemo <Programm>MereologieMaßerweiterungGenerator <Informatik>BitTextur-MappingKartesische KoordinatenPersonal Area NetworkTouchscreenIndexberechnungCodeInjektivitätResultanteAutomatische HandlungsplanungRechter WinkelDruckverlaufComputersicherheitComputeranimation
MereologieTextur-MappingKartesische KoordinatenDemo <Programm>Bildgebendes VerfahrenVideokonferenzMaßerweiterungQR-CodeResultanteWeb-SeiteRechter WinkelVerschlingungFlächentheorieFlächeninhalt
StichprobeInstallation <Informatik>Open SourceWeb-SeiteDemo <Programm>VerschlingungFlächeninhaltWeb-SeiteDemo <Programm>FlächentheorieMultiplikationsoperatorOffene MengeLesezeichen <Internet>Open SourcePhysikalischer EffektTextur-MappingGüte der AnpassungDienst <Informatik>CASE <Informatik>Coxeter-GruppeComputeranimation
Transkript: Englisch(automatisch erzeugt)
Sorry for being a bit late. There are some unexpected changes here. I will, first of all, welcome everybody to this session in the Humahuaca session room.
We're going to have a session with a couple of web mapping topics today. The first man out will be Oliver Gouyot. And he has sent us a prerecorded video
that I'm going to play now. And then there will be time for questions about it afterwards. So here's the video.
Hello everyone, and welcome to this presentation. We're going to talk about InkMap and about printing maps. So my name is Olivier Gouyot, and I'm a developer at Camp2Camp. This presentation was also prepared by my colleague, Toby Atzkor,
who is also a developer at Camp2Camp. Printing maps is not that simple. Let's see why. So let's talk about a common scenario that you probably have encountered. You have a web application with an interactive map in it.
And it's great because it's very easy to navigate inside your map. You can zoom in, zoom out, you can pan, and you can also change what's inside the map and how data looks inside it. And maybe after a while, you'll be happy with how the map looks like. And you'll think, well, I'd like to have this map on paper.
This is called printing, of course. So things can be harder than expected when printing a map. There is first the issue of scale. When you're on an interactive map in your browser,
you sometimes have a scale indication, but you often have measure tools. And this allows you to measure distances pretty precisely, right? On the paper map, you don't have these, so you need a very precise and accurate scale indication.
And also on the same topic, using web Mercator projection, which is very common in web maps, isn't a good fit for paper maps because you may have pretty strong distortions from one part of your map to the other. Also, printed maps need to have more dots
than the maps on the computer screen. So it means on the same zoom level, you need to have more detail on the paper maps. And this means that you need more data. And more data means that you need more time to download it. There is also something called a DPI
that you probably have seen or have heard of because it shows up every time you want to print something, anything, even text or any images. So DPI means a dot per range. It's just a measure of how many dots you have in one inch, all right?
So a high DPI means you have a higher dot density. This is simple, but actually the problem is that computer screens, they have a DPI as well, right? Because their dots are pixels, but we don't know their density. And also we know that when we print something,
anything, we want to have at least 150 DPI and 300 DPI is a good value for a quality print. Also some devices have double DPIs, for example, mobile devices with retina screens. And when we print something,
we want to maintain the scale. So the scale on the screen has to be pretty much the same as the scale on the paper map. And this introduces kind of complex computations, which can give you headache. And you know, that's okay, don't be afraid
because there are solutions for this, of course. Here I've listed three backend solutions that have been around for a long time. The first is Mapfish Print, and you probably have heard of it. It's pretty common. So it's a print server in Java and it's open source
and it has a very powerful PDF layout engine. So you basically prepare templates with Jasper reports and then Mapfish Print will use them to actually print the map, but it will also print the legend of the map and it can also do attribute tables
and it can also handle large asynchronous jobs by sending an email when it's done, for example. So it's very powerful. It has some limitations. For example, it won't print vector ties. I think it won't. I'm pretty sure it won't. And QGIS also has, of course, strong PDF output and reports functionalities.
So these are available in QGIS server. So it means that you can make QGIS a powerful print service because you have access to all these features through the web and you can do Atlas, multi-page layout. So it's very rich,
but it needs a QGIS file to work on, right? This is QGIS, so it needs a project to work on. The last is the ArcGIS printing services. So in the ArcGIS suite, you have pretty powerful printing services. And what's interesting is also that you have a client-side connector in JavaScript.
So it's made to make your life easy. It supports custom layouts and it also has limited rendering capabilities. And it's not open source, of course. Okay, so you may think, I don't have a server, all right, and that's fine. I don't have a server either.
And maybe that's a good thing because servers can be expensive over time, especially if you want a centralized printing service. It can become expensive because you have a lot of requests with a lot of data to store. And you also have a lot of processing power required
to do all this stuff. Also, when you think of it, a browser, at least a modern browser, can do anything you need to print a map. It has many rendering possibilities. There are several map rendering libraries. It can assemble PDF documents. This is doable. There are several libraries for that.
A browser, of course, is capable of handling asynchronous jobs because it does all the time. And you can load a large amount of data in the browser. There are no real limit. The only limit is how much data you're willing to download and how much time you have.
So there are already some client-side printing tools around. I've found a few, and there are probably more that I haven't found. Most of these have limitations, and here I've listed the three more common limitations.
The first one is the tools that rely on just making a snapshot of the map and transforming it into an image, and then you can print the image. And this is very limited because, for example, so the DPI of your image will be too low. That's for sure, because the map on the screen is usually
around 70 or 90 DPI. Also, you may have problems with aspects because your map on the screen may not have the aspect that you want when you print the document. So this is a very simple approach. It's pretty cheap, but it's very limited,
and I think it's not a good fit for what we want to do. There are tools that work with Mapbox as well. So I found a few, and they're very powerful, and they allow you to make very detailed maps. So that's great. The only issue is that Mapbox will only work
with Web Mercator. And as I said earlier, this is a strong limitation as well. A third problem that I've seen is that many printing tools or libraries are actually tied to a specific library. And here's an example that I think is a good example. This is from a leaflet print plugin
from GitHub user Aradcliff. And so you can see here that if you want to enable printing on your application, so you need to define a provider, and then you need to define a console that use this provider, and then you need to add the control to your leaflet map.
And obviously this is not going to work if you're not using leaflets. So these are some of the reasons why InkMap is born. So InkMap, what is InkMap? It's a JavaScript library, okay? And its goal is to print detailed maps at scale.
So generating maps that will look good on paper. InkMap is built to work in the background, in the background process, and to give you progress report. So it really embraces the asynchronous aspect
of the whole topic by, you know, its approach is, you know, maybe a print job will take a long time, so that's okay. I'm going to take the time in the background. I'm going to give you progress reports. You can cancel the job. You can start another job. That's fine. InkMap also only requires as input a JSON document.
So it's specification for what you want in your map. And it's pretty simple. You have to give it the layers, the center and scale of the map, the size of the final image, and the DPI, of course. So you can see here, this is an example of a JSON document that you can give to InkMap, all right?
So you see here, layers have a type. It can be XYZ for types, for example. It can be WMS, WMTS. There is a size, which is specified in real world units. So it's millimeters in this case. Center is longitude and latitude. The DPI, of course, the scale.
You can have a scale bar. You can have custom projections, not the row, and attributions. It's very straightforward. So InkMap internally uses open layers for rendering the layers, right? And this is important because this is very technical consideration,
but it's worth mentioning because open layers has many, many capabilities for rendering stuff, right? It can handle custom projections without issue. It can re-project ties. So you can mix layers with different native projections,
and that's gonna work out. You also have decluttering. Open layers will do decluttering on vector data. It has many advanced styling possibilities. It will do Mapbox vector ties, no problem, and also Mapbox ties. You can transform them to open layer styles, and that's gonna work.
And also, since the 6.7 release, it can actually do geotiff and cloud-optimized geotiff, and that's awesome. So of course, all these items in the list are not available in InkMap right now, not all of them, because they haven't been implemented yet in InkMap,
but they're possible because the rendering engine that InkMap relies on support this. So it's just a matter of writing an API to use them. InkMap is also made to work with any framework and any mapping library.
And this is really something that I want to emphasize. You should not think that because your application uses Mapbox, for example, then you won't be able to use InkMap. That's not true. You, InkMap doesn't care, right? It's self-contained. So you can be in any framework, any context,
even maybe other things as JavaScript, or maybe theoretically, this could even work in Node, for example, in the backend, that's theoretical, right? But you know, the context doesn't matter. InkMap is self-contained, it just wants JSON documents, and then it will give you an image.
And also it's worth mentioning that it relies on off-screen Canvas API. So it's an API that allows rendering stuff on the separate thread. It means it will not impact the experience of the user and the experience of the browser.
This is not supported in Firefox, but there is a fallback, so it should be pretty seamless. So InkMap has limitations, and what are these? There is a first limitation, is that InkMap will not output a PDF file for you.
All right, its job is to output an image and it will give you a PNG image, according to what you asked it for. To make a PDF document, you need to use a PDF libraries. And this is really on purpose, because doing all the layout of a PDF document is a completely different topic.
It's also complex, but it's a really different topic. And we felt that it was really out of scope for InkMap. Besides, you're free to use whatever library you want to do PDF, there are several already. And you know, they're not that hard to use, they're very well documented.
So it's really something that we let the user decide. Also, InkMap will not output maps with vector data in it. So for example, PDF with separate objects for each feature or SVG, because that would be too hard
with the current rendering engine, that would need a completely different rendering engine. And, you know, since these maps are supposed to be printed at some point on paper, you know, I don't think it's relevant to have like separate objects in your PDF file, for example, the only thing that you really want
is a crisp aspect of your features once on the paper. And this you can have with a high DPI value. Another thing that InkMap doesn't do is printing legends. This is not done correctly, but maybe we're considering it and maybe at some point we'll do it. If we consider that it brings value to the library.
A fourth item is attribute tables and atlas. So this is a pretty advanced functionality. Maybe in the long run we'll do it if there is interest and funding for it. For now, it's really out of scope. Okay, a quick talk about course
because course is something that you may have heard of, probably actually, and probably also you heard about it because it caused you trouble. So course is short for cross origin resource sharing. It's a big set of rules. It's pretty complex, but the gist of it is
if you fetching data from another domain, then the data needs to come with course headers in it. Otherwise your browser will block it and you won't be able to use it to print it. So there is really no way around that. You need these headers
because otherwise your browser will block it. We all know people or projects where there were like proxies that were made to fool the system and add headers along the way. But this is not, I don't think this is a good idea. The course rules are there to protect you. They're here for your own good. Your browser wants your own good.
So you should instead, if you want to use data from another domain and the data doesn't come with course headers, you need to contact the people there and ask them to do their work and add the headers. Otherwise there's no point in publishing data anyway.
Okay, so let's close this topic for now. A quick look at how InkMap works behind the scene. I'm not going to spend too much time on this. So I just want to show that InkMap works with two parallel threads. So the main thread will receive the print request and will transmit them to the printed thread.
And the printed thread will really do all the work and it will generate the layers, fetch the data. When all the layers have been rendered, it will assemble the layers together. And once it's done, it will send back the final image to the main thread. And all the big work and the printing work
is done in a service worker. Okay, so who made this possible? InkMap was 100% funded by the French Ministry of Ecology. You can see their logo here, it's big. They wanted this because they wanted to,
they wanted this as part of their Descartes mapping framework, which is a mapping, a very fit to reach mapping framework. It's open source, you can find it at the URL below. So Descartes has had a printing module for a long time that now they wanted to rewrite it from scratch because it was too limited.
And they went with a client side, a fully client side solution. And that's because they wanted to give a lot of flexibility to the user when defining the layout of the printed document. So you'll see afterwards, there is a demo, a quick demo of how it works in an application.
This is an application that uses the Descartes framework, right? So here I've opened the print preview. I changed the layout to a portrait aspect. You can see on the preview, the different elements that are going to be printed in the document. And you can see what I'm doing now is I'm panning and zooming in the map
to select the extent that I want to print. Once I'm happy with the extent, I can actually move the elements around. I can actually choose whether elements will be shown or not. I'm going to move the QR code to be at the top part of the document. I'm going to move the legend a bit.
And when I'm happy, I'm just going to click on generate. So print. Okay, this is the final result that I got after this demo. So you see here, it's a screenshot of the PDF document, right? So you see the title, you see the QR code exactly like I wanted it to be. And you see the map and the map, it's the extent that I selected
in the application during the previous video. But you can see that the map is much more detailed. There are much more data because the DPI is high and there is a legion as well. So this is all a very, these are all features that are part of Descartes, right? InkMap was only responsible
for producing the image that you see. And here, there are some examples that you can try there from the demo app, the demo page of InkMap. I'm going to give you the link afterwards, but I'm just going to skip on this because it's going to be too long otherwise. These are volcano area in France.
This is the surface of Mars, right? Pretty cool, the landing area of Mars 2020. And this is historical pictures of a town in Southwest France and WMTS service. Okay, so where to get it? You can find the source at camp2camp.inkmap on GitHub.
It's open source, of course. It's a CCLC license. There is a demo page, which you find the URL here and there's NPM package, which you can use right away. It's at camp2camp.inkmap. Okay, I'm done. Thank you so much for following these presentations. I hope you had a good time. I wish you have a very, very good Phosphorgy.
Have fun, see you later.