Spatial Reference Systems Transformations with Boost.Geometry
This is a modal window.
The media could not be loaded, either because the server or network failed or because the format is not supported.
Formal Metadata
Title |
| |
Title of Series | ||
Number of Parts | 295 | |
Author | ||
Contributors | ||
License | CC Attribution 3.0 Germany: You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor. | |
Identifiers | 10.5446/43482 (DOI) | |
Publisher | ||
Release Date | ||
Language | ||
Production Place | Bucharest |
Content Metadata
Subject Area | ||
Genre | ||
Abstract |
| |
Keywords |
FOSS4G Bucharest 2019102 / 295
15
20
28
32
37
38
39
40
41
42
43
44
46
48
52
54
57
69
72
75
83
85
87
88
101
103
105
106
108
111
114
119
122
123
126
129
130
131
132
137
139
140
141
142
143
144
147
148
149
155
157
159
163
166
170
171
179
189
191
192
193
194
195
196
197
202
207
212
213
214
215
216
231
235
251
252
263
287
00:00
Wave packetLibrary (computing)Computational geometryGeometryLecture/Conference
00:22
SoftwareGeometrySystem programmingTransformation (genetics)OracleAlgorithmPrice indexMereologyConditional probabilityMeta elementComputer programmingElectronic mailing listWebsiteRepository (publishing)Source codeLibrary (computing)Core dumpSoftware developerPredicate (grammar)Relational databaseOperations researchUniqueness quantificationAreaData bufferModel theorySpacetimeState diagramRevision controlState of matterEmailVertical directionOperator (mathematics)Parameter (computer programming)Exception handlingError messageThread (computing)Vector spaceError correction modelDefault (computer science)Modal logicMultiplicationLine (geometry)Point (geometry)Addressing modeMaß <Mathematik>NeuroinformatikLibrary (computing)Auditory maskingMereologyAlgorithmPairwise comparisonPoint (geometry)BenchmarkData conversionNetwork topologyState of matterRing (mathematics)Form (programming)Object (grammar)Different (Kate Ryan album)Projective planeIntegrated development environmentDefault (computer science)Coordinate systemString (computer science)CodeFile formatArmSource codeOrder (biology)Parameter (computer programming)Product (business)Arithmetic meanEqualiser (mathematics)Multiplication signRight angleAreaMessage passingSubject indexingInterface (computing)Sound effectSelf-organizationLetterpress printingTransformation (genetics)Computer programmingComputer configurationPhysical systemUltraviolet photoelectron spectroscopyParsingRevision controlAdditionEmailElectronic mailing listSoftware developerException handlingData storage deviceWordCodeDistanceMathematicsPrimitive (album)Computer fileINTEGRALInterior (topology)Degree (graph theory)Cartesian productType theoryFunctional (mathematics)Shared memoryConformal mapExpressionGeometryFlow separationLine (geometry)Authorization1 (number)Thread (computing)Variable (mathematics)Electronic visual displayVector spaceRun time (program lifecycle phase)NumberData typeFehlererkennungComputer animation
09:41
SpacetimeMaß <Mathematik>Fluid staticsGeometryData storage deviceLattice (order)State diagramBenchmarkThread (computing)Extension (kinesiology)Visual systemOracleThread (computing)Different (Kate Ryan album)Product (business)Transformation (genetics)Run time (program lifecycle phase)Virtual machineMultiplication signLibrary (computing)SynchronizationExtension (kinesiology)Structural loadDirectory serviceParameter (computer programming)CompilerVisualization (computer graphics)Variable (mathematics)System callData storage deviceHeat transferMessage passingCodeProgrammer (hardware)Social classConstructor (object-oriented programming)Projective planeString (computer science)Streaming mediaCASE <Informatik>Instance (computer science)Cartesian coordinate systemObject (grammar)Pairwise comparisonMultiplicationCodeGame controllerSemiconductor memoryBenchmarkOrder (biology)Degree (graph theory)BuildingTwitterParsingObservational studyOnline helpArithmetic meanFigurate numberDatabaseInsertion lossDemosceneMiniDiscWebsiteNumberRight angleFile formatNetwork topologyType theoryComputer animation
18:46
WebsiteTwitterOnline helpLine (geometry)1 (number)CodeGreatest elementState diagramThread (computing)Lecture/Conference
19:35
GeometryRevision controlElectronic mailing listEquations of motionProjective planeComputer programmingServer (computing)Point (geometry)Software developerLevel (video gaming)Series (mathematics)State observerRight angleLatent heatView (database)Element (mathematics)ECosInstance (computer science)Physical systemFocus (optics)Fitness functionFunctional (mathematics)Event horizonComputer animationLecture/Conference
Transcript: English(auto-generated)
00:09
Ok, so let's start another talk. I'm Adam and I work at MySQL and together we are
00:21
developing Boost's geometry, a library for geometrical computing used by MySQL to do GIS stuff. So we are part of Boost's ecosystem, so we adapt their principles
00:44
like header only, we're a header only library, we tend to focus on performance, we use modern C++, we tend to do things in compile time, instant of run time and so on. And Boost's
01:09
geometry allows us to vector data and perform algorithms on this vector data. It also contains
01:20
spatial index to speed things up and now projections. Yeah, I started. It was a public demand. So the current version is 1.71, documentation mailing list and GitHub displayed. We have
01:46
a vibrant development team, any contributions are welcome. We are participating in Google's number of codes, so if you want to contribute, please. Here are some algorithms, examples
02:10
of algorithms implemented in Boost geometry. If you know OGC standard, then you know the algorithms. And here is Hello World, calculating the distance between my home
02:25
city and Bucharest. And this distance is calculated in geographic coordinate system in WGS84 by default. So we like to be as expressive as possible. So first here, or
02:56
maybe I'll use the cursor. So here we are creating a point which is 2D in geographic
03:06
coordinate system and coordinates are in degrees. And the data type is double because you can, in Boost geometry you can use whatever coordinate type you like. And then
03:21
two points are created and function is called. And I'll be comparing with Proj4 which is state of the art. I used 5.2 for the comparison and benchmarks and the current version is
03:45
6.1.1 which changes things severely. So what are the differences? Work on projections in both geometry was started by Barand Girls which is the original author. They call this
04:07
based on Proj4. So it basically works more or less like Proj4 but it was severely redesigned in order to make it more, let's say C++ friendly. And I'm not talking about the
04:23
interfaces but the internals. So cons are that there are less transformation than in the more recent Proj. It's 2D only, there is no pipelines. There are of course no
04:43
Proj 6 features. On the other hand, it's more, let's say C++ friendly or Boost friendly that it's header only. There are no additional requirements. There are no environments, variables used under the hood. It's faster. I'll show it later. And our handling
05:13
is done differently. It's based on exceptions. So we don't store this global error codes
05:22
which makes the library thread safe, let's say. During the talk I'll be using this data. So here are the vectors I'm using. There will be three examples. One with Poland
05:48
and Romania and one with New Jersey. New Jersey I'm using because it's one of the last non-depurgated EPSG codes using NAD grids. So here is Poland and Romania in EPSG 4326 which is the native
06:15
data of this file I've shown. And I'll be transforming into conformant project using
06:23
conformant production to EPSG 3034. So first this is how you do it in Proj 4. This
06:46
of coordinates. And the coordinates are interleaved XY in the vector. This is as far as I understand you do it in Proj 5 where you'd pass PJ coordinates which are up to two to four dimensional
07:13
coordinates. And Boost geometry, the most basic interface in Boost geometry is not
07:21
very different. Oh, first note about the expressiveness. In Boost geometry it's possible to express various ODC primitives in the code like points, line string and multi-line strings. So here we have geographic ones and Cartesian ones. So the point type defines the coordinate
07:46
systems at compile time. So here is the difference. Right? Geographic in degrees and Cartesian. And all of the derived types share this coordinate system. So here is how you perform
08:06
the transformation in Boost geometry which is more or less like Proj 4. First you have you define your geographic multi-line string, create transformation object, passing source
08:25
and destination transformation parameters and you're performing forward transformation. And that's it. But since we're in C++ environment maybe you don't want to create strings because
08:48
you probably have parameters already in your code. But this will be another example. So in this example I'm using different projection. That one was conformant. This
09:03
will be equal area. So here it looks similar, right? Two Proj 4 strings. And another possibility is to pass parameters directly from C++. Which is similar. And the interface was based
09:28
on both program options. Names of parameters are the same. So it's similar to Proj 4. But it allows you to omit string parsing and string formation and string parsing on
09:47
the side of library which is faster. And if you know what transformation we'll be using at compile time. So for instance you're writing a very specific application doing
10:01
very specific thing and only that and you want to be as fast as possible then you'll probably want to do it at compile time. And it's also possible. Also with transformation object. So basically here you're creating two types. And only filling the runtime values
10:31
that are needed. But if you don't care about that you can simply pass APS-G codes.
10:44
And that will create transformation for you. The upper one is that the APS-G code is passed in the runtime and the below one is passed at compile time. Now the third
11:01
example. As I said here, I wanted to show you how to use NAD grids. It's different than in Proj which loads grids automatically under the hood from directories
11:20
specified in variable. In both geometry, if you do something like this, the grids won't be used at all. Even if they're defined in the parameters. So this will, this
11:40
call will be the fastest. The transfer should be the fastest. The grids won't be, they won't pass. If you want to pass grids you have to do it by yourself. And we want
12:03
to be, want to give the programmer the flexibility to store the grids whatever he likes, whenever he likes. Load them however he likes. So we provide this additional class which is grid storage which takes stream policy and grids
12:26
definition. So if stream policy defines how to load the grids because maybe you don't want to load them from disk. Maybe you want to load them from somewhere else. Maybe you want to define the path somehow. So this allows
12:47
you to do it. And the second parameter tells the library how to synchronize the grids in case you wanted to do transformation in multiple threads. So
13:02
there is the same. And with this object you also have the control where the grids are actually stored, how they are stored in memory and where they are removed from memory. So where they are destroyed. So in order to
13:26
use grids you have to put this grid storage somewhere and then initialize grids for your specific production and pass the grids manually. So this
13:43
example shows how to perform production in one thread. If you want to use several threads, the only difference is that you're passing shared grids. And shared grids are using boost threads for synchronization. So here is
14:11
an example how to perform the transformation in two threads and wait for both threads to end. But if you don't want to rely on boost threads, you
14:28
don't want to have this dependency and have a compiler supporting C++ 14, then you can use standard threads and standard synchronization. So you
14:44
have to include a different header, pass a different type and you're free to go. The code looks exactly the same. And here are some benchmarks.
15:05
I'm showing the time of construction of projection and below is the transformation itself. So this benchmark is for the first example. As you can see, the construction is a lot faster with when you don't have to
15:30
parse strings. And because it's possible to, because it's a library and because it was severely redesigned, it allows the compiler to perform
15:45
transformation faster. Because the compiler is able to optimize and this makes things a lot faster. It's the same story with another projection.
16:04
As I'm not entirely sure what happens here, I also tried approach six, but the comparison would be unreliable because it does things entirely differently, searches the definition in the database, so it takes a lot,
16:29
a lot longer to create. And the time of execution is still slightly slower than approach four. So I just omitted approach six here. Yes, and it's
16:55
basically the same for all cases. With NAD grids, I think the difference is
17:03
even more, it's more or less two times faster. And how it behaves in multiple threads, so some charts, these are times of the same work
17:21
divided into multiple threads, how they are scaling with threads, with boost synchronization or STD, standard synchronization is red. So there's no difference actually between boost thread and STD. And different
17:49
machine and different compiler. Now with approach five, also clang. So
18:04
yes, that will be it. And we also have this extension which you can use with Visual Studio to visualize your variables at debug time when you're debugging in Visual Studio. Okay, thank you. Yes, if there are any
18:36
questions. What kind of threads are you using for approach four and
18:57
approach five benchmarks? Standard ones. So it's C++ 11 STD thread.
19:21
Sorry, is the code available on GitHub? Yes, of course. Bottom line. So yeah, you can test it. Do you have any interest from any of the C
19:51
projects to use this library? Or have you tried to get other people using it? Let's say, especially map server, but the other programs
20:01
relying on C and C++? No, we didn't try to reach anyone. I don't know well enough about map server to suggest if it would be a good fit or
20:23
not. My understanding is that map server lives in a specific ecosystem which already have everything it needs. Maybe because from other
20:45
libraries point of view, like approach four for instance, the I guess it depends on what aspects of development you would like to
21:01
put focus on. If you tend to perform, if you tend to care about performance more or maybe about modern C++ or about features or accuracy, then you would pick one or the other.
21:34
I'd just like to thank Adam and wish you a pleasant lunchtime. So see you in the afternoon. Thank you all for coming.