Here are answers to some questions frequently asked about CartoType.
What is CartoType?
A portable library providing maps and navigation on any platform. Please read this brief presentation.
Will CartoType run on any platform?
Yes, as long as, for that platform, there is a way of building C++ code using a compiler which supports C++14. For example, GCC 5 or later is fine.
Can I add my own data to the map?
Yes, you can add your own points, lines and polygons; in fact you can add any type of map object at run-time (except bitmap objects, which are used for terrain shading and similar things); objects can be added to any layer, or you can create new layers.You can add extra styles for these objects, either at run-time, or by adding them to your custom style sheet.
Why is a CTM1 file twice the size of a PBF file?
A CTM1 file is a file in CartoType's own map file format. A PBF file contains OpenStreetMap data encoded compactly using the protocol buffer system.
A CTM1 file is normally about twice the size of a PBF file. The actual main data (layer data) is roughly the same size as the PBF file, but there are several other tables necessary to make things work, or speed things up. The main ones are
- the low-resolution layer data: when you zoom right out you don't want to incur the cost of loading detailed polygons like (say) the entire eastern coastline of the USA. The lower resolution copies remove any features which would be less than a pixel in size when drawn. Turn this off using /lowreslayers=no as a makemap argument, at the cost of slower drawing.
- the full-text index; turn it off using /textindex=no, at the cost of poor or slow address searching.
- the route network; turn it off using /route=no, at the cost of slow first route creation; CartoType has to build the route table at run-time if it's not in the CTM1 file.
Here's an example of how things break down, using a map of the eastern part of the US state of Virginia. I obtained the data using the ctm1_info tool, which you can download: http://www.cartotype.com/assets/downloads/ctm1_info.exe.
east_virginia.pbf = 253Mb
east_virginia.ctm1 = 424Mb
extract from ctm1_info report:
table 0: global information (166 bytes, 0.00Mb)
table 1: layer data (266637835 bytes, 254.29Mb)
table 4: projection table (99 bytes, 0.00Mb)
table 5: table of compressed strings (776336 bytes, 0.74Mb)
table 6: low-resolution layer data (41879150 bytes, 39.94Mb)
table 8: index used for text searching (57499012 bytes, 54.84Mb)
table 10: routing network (A*) (56946763 bytes, 54.31Mb)
table 12: extra information for the routing network (A*) (9493 bytes, 0.01Mb)
Can I use CartoType with Qt?
The Windows and Linux SDKs come with pre-built CartoType libraries compatible with Qt. You can download them here.
How do I find all the roads in a certain postcode?
... or all the restaurants in a certain city, or any complete list of map objects bounded by an irregular area.
First note that FindAddress is not the way to do it. The FindAddress function is not a general database query. It is designed to return a single specific result, and extra results are thrown away during the matching process, to save time. You need the general Find function.
Here's an example using the C# SDK. The task is to find all the streets in the postal code area 94559 in Germany.
CartoType.MapObjectList postcode_list = new CartoType.MapObjectList();
CartoType.MapObjectList road_list = new CartoType.MapObjectList();
CartoType.FindParam find_param = new CartoType.FindParam();
find_param.m_text = "94559";
find_param.m_layers = "postcode";
find_param.m_condition = "@=2";
if (postcode_list.Count > 0)
CartoType.Geometry postcode_bounds = new CartoType.Geometry(postcode_list);
find_param.m_text = "";
find_param.m_layers = "road/";
find_param.m_condition = "";
find_param.m_clip = postcode_bounds;
It yields 333 roads (using a map of Germany prepared in 2107).
The code above first searches for a polygon postcode object. A condition is used to limit the search: it's "@=2", where @ is a built-in variable meaning the geometry type: 0=point, 1=line, 2=polygon, 3=texture. The resulting postcode polygon is then used to create a Geometry object which is used as a clip region for the search for roads.
How can I use CartoType with an ASP .NET app created by Microsoft Visual Studio?
If you create an ASP .NET app with Microsoft Visual Studio, and add a reference to the CartoType .NET library (the file CartoTypeWrapper.dll) you get the error "Could not load file or assembly 'CartoTypeWrapper' or one of its dependencies. An attempt was made to load a program with an incorrect format." Here's how to fix it:
1. In Visual Studio, add a new Release x64 configuration to your ASP .NET project and use that configuration.
2. In Visual Studio, in Tools->Options->Web Projects in VS2017, check the box 'Use the 64 bit version of IIS Express for web sites and projects'.
3. Copy the x64 release versions of libEGL.dll and libEGLESv2.dll to your Windows folder (usually C:\Windows). For some reason the IISExpress program which runs your app doesn't look in the local app directory for DLLs. You could probably alternatively add the location of these DLLs to your PATH environmental variable, but I haven't tried that.