258 Commits

Author SHA1 Message Date
systemed 21a71cdead Fix compiler warning 2026-02-10 14:59:43 +00:00
systemed 497aa7d8af Boost 1.89+ fix 2026-02-10 14:51:34 +00:00
John Carmack d19d080271 Fix Lua 5.4 compatibility in kaguya.hpp
Some Lua 5.4 builds (e.g., vcpkg) removed LUA_GCSETPAUSE and
LUA_GCSETSTEPMUL constants, replacing them with LUA_GCPPAUSE and
LUA_GCPSTEPMUL. Add conditional defines to handle both cases.
2026-02-09 19:09:04 +00:00
AlanIWBFT bf4f3f35ad Fix build with Boost 1.89
* `boost::range::sort` conflicts with `boost::sort`. Implementations are moved into a dedicated .cpp file.
* `boost::system` is a header only library now and the stub is removed
2026-01-13 22:11:17 +08:00
etienneJr 68847d367d Add new function to allow ID modification (#866)
* add new function to allow ID modification

* document modifyId
2026-01-11 15:54:26 +00:00
Richard Fairhurst ea8d2151a9 Allow combine_lines_below on each layer (#850)
Co-authored-by: Etilène Jourdier <etienne.jourdier@gmail.com>
2025-09-30 14:45:19 +01:00
etienneJr 80f53f3cbd create function to get OSM type (#834) 2025-09-29 22:18:43 +01:00
Richard Fairhurst 830f85c3e1 Add AttributeInteger for writing int values (#827) 2025-09-29 12:22:55 +01:00
Echoz 5c8d73b4f0 feat: write attribution in pmtiles metadata (#818) 2025-09-29 12:21:18 +01:00
Richard Fairhurst 0ebc1d7168 Simple key/value store (#817) 2025-04-17 10:59:33 +01:00
Richard Fairhurst 8d372c02ea IsMultiPolygon Lua method (#810) 2025-04-14 21:21:53 +01:00
Richard Fairhurst 13b841d58f Visvalingam-Whyatt simplification (#772) 2024-10-19 11:34:29 +01:00
Richard Fairhurst 22ecab790d Add per-layer ability to disable multipoints (#771) 2024-10-13 22:47:30 +01:00
John Bayly 6ecacf4646 Add optional --quiet flag to tilemaker (#754) 2024-10-13 21:37:08 +01:00
John Bayly a9681849dd Add AllKeys and AllTags Lua functions (#755)
See systemed/tilemaker#748
2024-10-13 21:35:18 +01:00
Colin Dellow fe8399e522 use libdeflate rather than zlib (#769) 2024-10-13 18:03:44 +01:00
Colin Dellow 88b8b6f6b3 be less chatty when run non-interactively (#767) 2024-10-13 15:41:32 +01:00
Colin Dellow 76ef3e8232 don't require any Lua functions (#770) 2024-10-13 15:40:54 +01:00
Colin Dellow e42aaa7516 faster Intersects queries (#765) 2024-10-03 09:06:39 +01:00
Colin Dellow 7f03430456 Fix #750: allow no more than 512 attribute names (#760)
This fixes two issues:

- use an unsigned type, so we can use the whole 9 bits and have 512
  keys, not 256
- fix the bounds check in AttributeKeyStore to reflex the lower
  threshold that was introduced in #618

Hat tip @oobayly for reporting this.
2024-09-21 14:10:28 +01:00
Colin Dellow 6509f0cf50 Boost 186 (#759) 2024-09-20 17:20:48 +01:00
Richard Fairhurst eab08d189a Fix indexing nodes when basezoom>14 (#728) 2024-06-09 12:52:38 +01:00
Richard Fairhurst 1c0638fc45 Fix reading bools from shapefiles (#715) 2024-05-08 17:55:37 +01:00
Colin Dellow ad86ab4a01 remove FAT_TILE_INDEX (#700) 2024-04-01 17:24:47 +01:00
Richard Fairhurst a393cef6f6 Faster polygon combining (#681) 2024-02-17 11:07:14 +00:00
Richard Fairhurst d8fbd52661 Merge pull request #668 from cldellow/geojson-write-points-and-linestrings
GeoJSON writer: support points and linestrings
2024-02-10 21:03:54 +00:00
Colin Dellow 6951cd7346 windows build: uint -> uint8_t 2024-02-06 21:02:59 -05:00
Colin Dellow 93f618574f AttributePair: use uint, not char
Since we only allocate 4 bits and `char` is signed, the usable space
was -8..7. Larger values (like, say, 12) overflow, and get interpreted
as a negative value, which means they don't act as a filter, since all
zoom values are natural numbers.

The tests didn't actually test that a zoom value could be roundtripped.
I updated them, and verified they failed before the code change, and
passed after the code change.

I've also allocated an extra bit so that we support minzooms up to z31,
vs just up to z15, since I think (?) some people generate up to z16
2024-02-06 20:54:20 -05:00
Colin Dellow 537b9b1fe4 GeoJSON writer: support points and linestrings 2024-02-04 01:03:31 -05:00
Colin Dellow 5b96711a09 --shard-stores and --compact aren't compatible
CompactNodeStore doesn't know how to compute if it contains a node,
which is a prerequisite for sharding.

The two settings don't make much sense together: sharding will create N
CompactNodeStores, which each will take as much memory as a single one,
since each will likely have a large node ID.

This differs from BinarySearchNodeStore and SortedNodeStore, where each of
the N store instances will take roughly 1/N memory.

Instead:

- fail faster and more clearly by throwing if CompactNodeStore.contains is
  called
- don't enable sharding if --compact is passed
2024-01-26 20:15:34 -05:00
Colin Dellow d3de0fb4b1 warn when --compact used on non-renumbered PBF
A future commit will make it safe to do so, but it's still
memory-inefficient to use --compact on a non-renumbered PBF
2024-01-26 19:56:51 -05:00
Colin Dellow ac37ce3faf parallelize geojsonl reading
For a ~300MB geojson file of mine, this decreases wall clock time from
2.5s to 1s.
2024-01-21 12:46:46 -05:00
Colin Dellow 5b8f009a1e support GeoJSON lines format
Described at https://stevage.github.io/ndgeojson/; each feature is given
its own line, rather than being wrapped in a FeatureCollection.
2024-01-20 11:05:00 -05:00
Colin Dellow dedbfe7db2 Centroid(...) should return nil on error
Previously, calling Centroid(...) on an invalid geometry (such as
https://www.openstreetmap.org/relation/9769005, which I think gets
simplified to having 0 rings) would throw, killing the lua process.

Instead, return nil.
2024-01-18 18:55:10 -05:00
systemed 4230c3db2d Simplify runtime options
This changes the default to lazy geometries for both in-memory and on-disk.
--fast selects materialized geometries when running in memory, and unsharded
stores when running on disk.
2024-01-14 23:20:13 +00:00
Colin Dellow 7c8abef5e2 V3 post relation scan (#642) 2024-01-14 17:34:41 +00:00
Colin Dellow 5511d7680a fixup LayerAsCentroid(...)
Eep, two fixes here as well:

- I had rejigged how the skipping of LayerAsCentroid's algorithm
  argument worked; this rejigging ultimately broke it entirely, as `i`
  would never get incremented.

- If `way_keys` is provided, we are no longer guaranteed that we'll have
  stored the `label` node of the  relation
2024-01-12 00:04:02 -05:00
Colin Dellow b77340c870 remove PossiblyKnownTagValue
When I replaced #604 with #626, I botched extracting this part of the
code. I had the trait, which taught kaguya how to serialize
`PossiblyKnownTagValue`, but I missed updating the parameter type
of `Attribute` to actually use it, so it was a no-op.

This PR restores the behaviour of avoiding string copies, but now that
we have protozero's data_view class, we can use that rather than
our own weirdo struct.
2024-01-11 23:29:50 -05:00
systemed 9080cdb10e Merge branch 'way_keys' into v3 2024-01-10 18:01:27 +00:00
systemed 4051605a49 Remove checks for obsolete Boost versions 2024-01-10 17:32:53 +00:00
systemed 73ac9ce1fe Remove Mapsplit support 2024-01-10 17:00:04 +00:00
systemed e768595c4b Merge branch 'lua_interop' into v3 2024-01-10 15:44:09 +00:00
Colin Dellow 3ff08a3bc3 Intersects: faster queries for negative case (#635) 2024-01-08 20:01:01 +00:00
Colin Dellow abb2e95f83 Merge remote-tracking branch 'origin/master' into lua-interop-3 2024-01-07 13:51:46 -05:00
Colin Dellow a600524c90 extend NextRelation/FindInRelation to nodes (#632) 2024-01-07 16:51:08 +00:00
Richard Fairhurst 65829e48cd GeoJSON as alternative to shapefiles (#630) 2024-01-01 23:08:08 +00:00
Colin Dellow 2bb131b5c4 run Docker build on PRs (#627) 2023-12-30 13:43:35 +00:00
Colin Dellow 3c1740ad4d generalize node_keys; add way_keys
This PR generalizes the idea of `node_keys`, adds `way_keys`, and fixes #402.

I'm not too sure if this is generally useful - it's useful for one of my
use cases, and I see someone asking about it in https://github.com/systemed/tilemaker/issues/190
and, elsewhere, in https://github.com/onthegomap/planetiler/issues/99

If you feel it complicates the maintainer story too much, please reject.

The goal is to reduce memory usage for users doing thematic extracts by
not indexing nodes that are only used by uninteresting ways.

For example, North America has ~1.8B nodes, needing 9.7GB of RAM for its node
store. By contrast, if your interest is only to build a railway map, you
require only ~8M nodes, needing 70MB of RAM. Or, to build a map of
national/provincial parks, 12M nodes and ~120MB of RAM.

Currently, a user can achieve this by pre-filtering their PBF using
osmium-tool. If you know exactly what you want, this is a good
long-term solution. But if you're me, flailing about in the OSM data
model, it's convenient to be able to tweak something in the Lua script
and observe the results without having to re-filter the PBF and update
your tilemaker command to use the new PBF.

Sample use cases:

```lua
-- Building a map without building polygons, ~ excludes ways whose
-- only tags are matched by the filter.
way_keys = {"~building"}
```

```lua
-- Building a railway map
way_keys = {"railway"}
```

```lua
-- Building a map of major roads
way_keys = {"highway=motorway", "highway=trunk", "highway=primary", "highway=secondary"}`
```

Nodes used in ways which are used in relations (as identified by
`relation_scan_function`) will always be indexed, regardless of
`node_keys` and `way_keys` settings that might exclude them.

A concrete example, given a Lua script like:

```lua
function way_function()
  if Find("railway") ~= "" then
    Layer("lines", false)
  end
end
```

it takes 13GB of RAM and 100 seconds to process North America.

If you add:

```lua
way_keys = {"railway"}
```

It takes 2GB of RAM and 47 seconds.

Notes:

1. This is based on `lua-interop-3`, as it interacts with files that are
   changed by that. I can rebase against master after lua-interop-3 is
   merged.

2. The names `node_keys` and `way_keys` are perhaps out of date, as they
   can now express conditions on the values of tags in addition to their
   keys. Leaving them as-is is nice, as it's not a breaking change.
   But if breaking changes are OK, maybe these should be
   `node_filters` and `way_filters` ?

3. Maybe the value for `node_keys` in the OMT profile should be
   expressed in terms of a negation, e.g. `node_keys = {"~created_by"}`?
   This would avoid issues like https://github.com/systemed/tilemaker/issues/337

4. This also adds a SIGUSR1 handler during OSM processing, which prints
   the ID of the object currently being processed. This is helpful for
   tracking down slow geometries.
2023-12-29 18:02:11 -05:00
Colin Dellow 6ba38b056d buffer objects when object index contended 2023-12-28 16:43:16 -05:00
Colin Dellow 515a0211e0 add thread-local cache for attributepairs 2023-12-28 16:43:16 -05:00