Commit Graph

882 Commits (master)

Author SHA1 Message Date
Jochen Topf 0c7b201b76 Make attributes of OSM objects always available to Lua
I did some benchmarking and it turns out there is real no measurable
difference between putting the data in there and not doing it. So
we'll just always do it. This means that it doesn't depend on the
-x/--extra-attributes command line option any more.

Note that the attributes will still be nil when coming from the
middle in update mode if -x/--extra-attributes was not used on import.
2024-08-19 09:23:16 +02:00
Jochen Topf 7b6ed0d2bc Use anonymous namespace instead of static in test code
This is recommended in C++ Core Guidelines SF.22
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rs-unnamed2
2024-08-15 22:24:35 +02:00
Jochen Topf 193ac44a98 Improved parsing of --bbox command line option
Without use of scanf.
2024-08-15 14:06:25 +02:00
Sarah Hoffmann 882e065fdc
Merge pull request #2224 from joto/area-assembler
Refactor area assembler
2024-08-15 10:40:53 +02:00
Jochen Topf 83072b075f Re-use temp buffer for area creation
Saves memory allocations.
2024-08-14 13:42:29 +02:00
Jochen Topf d6256a0c89 Make --flat-nodes also work in non-slim mode
This is useful if memory is tight.

Flat node file is not deleted automatically. Use --drop to delete it.
This is the same behaviour as in slim mode.
2024-08-13 17:30:24 +02:00
Sarah Hoffmann f8c78ae3d5
Merge pull request #2222 from joto/geom-get-bbox
Add get_bbox() function to geometries in Lua
2024-08-13 17:10:08 +02:00
Jochen Topf ac8bc1d8af Add get_bbox() function to geometries in Lua
Add new get_bbox() function for geometries in Lua. Like the get_bbox()
function on OSM objects it returns the bounding box as four numbers in a
Lua array (table). Having this function on geometries allows for more
flexibility, you can call it on a centroid or a projected geometry for
instance.

It is faster to call get_bbox() on the OSM object, because it removes
the step of building the geometry first, so for those cases where this
is good enough the old use is fine and is still supported.

See #2219
2024-08-13 13:48:59 +02:00
Jochen Topf 3537f17fdb Add after_nodes/ways/relations() callback functions in Lua 2024-08-12 15:40:56 +02:00
Sarah Hoffmann b13126a9db make sure diffs are recent enough when initialising replication 2024-07-12 11:49:18 +02:00
Sarah Hoffmann a5f0872756 bdd: run basic lua tests against empty files
This way osm2pgsql can be run without failure but the test will be
quick.
2024-07-11 11:34:38 +02:00
Sarah Hoffmann 319dff8d2b remove HAVE_LUA config option from BDD tests
Lua is now mandatory.
2024-07-11 11:31:25 +02:00
Jochen Topf 0ce67d1fe7 Refactor how COPY is handled, use variant instead of virtual class
COPYs are handled in extra threads through a worker queue. Using
std::variant instead of virtual classes simplifies the code, because we
don't need the indirection through a unique_ptr any more.
2024-07-09 11:21:46 +02:00
Jochen Topf 728a92dd60 Make properties available in Lua in osm2pgsql.properties 2024-07-07 21:57:18 +02:00
Jochen Topf e7ed8d0ae9 Allow empty config file in flex output
No flex config file, or one that doesn't define any tables is usually
not very useful. But it can be used in slim mode to have the middle
tables only. Or it can be used to do some other processing or instead
if the null output for testing.

This change allows an empty config file, but a warning is printed that
no output tables are defined. You still have to specify a config file,
it can be an empty one, but it has to be there. This is so that if the
user forgets naming a config file on the command line they get an error
and not only a warning that might be missed.
2024-06-16 11:17:27 +02:00
Sarah Hoffmann 40ef1a6dfc
Merge pull request #2202 from joto/cleanup-misc
Various small cleanups
2024-06-16 11:13:18 +02:00
Jochen Topf 05f4ff91bf Remove superfluous c_str(), decode_hex() parameter is a string_view 2024-06-15 19:55:25 +02:00
Jochen Topf 8c5e1e22dc Lua is now required
We are moving to the flex output which always needs Lua. Making Lua
optional isn't useful any more and just makes code more complicated.
This commit makes Lua non-optional.
2024-06-15 19:54:33 +02:00
Jochen Topf 490ad6a7d6 Avoid warnings for integer conversions from MSVC 2024-06-13 09:29:17 +02:00
Jochen Topf 1c4ce753b6 New nodes and ways can't have existing parents
New nodes or ways (ie with version=1) can't have parent ways or
relations. So we don't have to add them to the list of "changed nodes"
or "changed ways" to trigger re-processing of changed parents. This will
save us a whole lot of effort looking for parents that are never there.

Note that we are checking for version != 1. In the (unlikely) case that
there are no versions in the input file (making version == 0),
everything will work as before.
2024-05-13 22:01:50 +02:00
Jochen Topf d4a7b377ea Refactor osmdata_t code
Remove has_pending() which checks two things we can easily check each by
itself and sometimes only need one or the other.

Turn get_pending_way_ids() and get_pending_relation_ids() into simple
getters, they are only needed for testing outside the class.
2024-05-10 10:00:37 +02:00
Jochen Topf 89f4b0baaa Remove osmdata_t::start() function, do its job in constructor 2024-05-10 10:00:37 +02:00
Jochen Topf eb8ac61679 Move dependency manager code into osmdata
Now that we always use dependency management, we don't need the
dependency manager to be a virtual class any more. In fact it isn't
really doing that much, so we can roll it into the code in osmdata_t.
2024-05-10 10:00:37 +02:00
Jochen Topf 515dfb25e9 Remove support for legacy middle database format 2024-04-11 12:03:00 +02:00
Jochen Topf 60afdaf533 Remove superfluous @ in test file 2024-04-11 09:57:34 +02:00
Jochen Topf f07eb240ac Make a variable const (because we can) 2024-04-11 09:57:34 +02:00
Jochen Topf b699cde8ad Remove long deprecated add_row() Lua command
This also removes the special "area" column type which was only used
with the add_row() function.
2024-04-08 22:00:15 +02:00
Jochen Topf 6214c39835 Report missing nodes in the input (in debug mode)
A maximum of 100 missing nodes (with the ways they are missing from) are
reported.
2024-04-07 22:21:25 +02:00
Sarah Hoffmann 39bdb8952f
Merge pull request #2160 from joto/replace-add-row-with-insert
Replace add_row() with insert() in tests
2024-04-06 21:43:26 +02:00
Jochen Topf 7acb80c8cd Replace add_row() by insert() in BDD tests
As preparation for the removal of the add_row() function.
2024-04-04 10:34:04 +02:00
Jochen Topf 6c949b0919 Remove gazetteer output and --with-forward-dependencies option 2024-04-03 21:36:40 +02:00
Jochen Topf 9dfa61eee1 Replace add_row() by insert() in tests
As preparation for the removal of the add_row() function.
2024-04-03 21:22:42 +02:00
Sarah Hoffmann 646653265b
Merge pull request #2153 from joto/replace-boost-filesystem-by-std-filesystem
Use std::filesystem instead of boost::filesystem
2024-04-02 16:13:59 +02:00
Jochen Topf 3bd217dd37 Use std::filesystem instead of boost::filesystem
This changes the minimum GCC version supported from 7 to 8, because
std::filesystem is only in glibc 8.
2024-04-02 11:05:34 +02:00
Jochen Topf 65a9317baa Make osmid_t a real class 2024-03-31 18:12:25 +02:00
Jochen Topf 3e5daee106 Move idlist_t into its own header file 2024-03-31 18:12:25 +02:00
Jochen Topf 76ba82c7e0 Fix off-by-one error in expire code generating out of bounds tiles
See #2142
2024-03-06 18:53:08 +01:00
Jochen Topf 3a460cda86 Switch middle database default format to "new" 2024-02-09 11:36:37 +01:00
Jochen Topf ac6008bdf7 Give flex tables a number and use it for prepared statements
This way prepared statements are different and we can have several of
them in the same connection. We'll use that in the future.
2024-02-04 10:25:30 +01:00
Jochen Topf 9cbc221868 Use different application names for db connection to show context
Adds a "context" parameter to database connection setup describing what
this connection is for. This is something like "middle.query" or
"out.pgsql". It will be added to the application name, so querying
pg_stat_activity will show it like "osm2pgsql.middle.query/C2" etc.
2024-02-02 14:54:46 +01:00
Jochen Topf abd6554636 Rename conninfo to connection_params everywhere
This is really part of the previous commit but was factored out to keep
that one reasonably legible.
2024-02-01 10:39:19 +01:00
Jochen Topf 46ef18e7d0 Store db connection parameters in a their own class
The connection parameters (such as dbname, user, host, ...) are stored
in their original format and not concatenated into a conninfo string any
more. We are now using a different database connection function from
libpq that takes them in this form. This allows us to get rid of the
code that transforms those parameters into the conninfo string that
takes various forms of connection parameters into account, especially
around the URI form of the connection parameters. The libpq has this
code anyway, see also the last parameter "expand_dbname" of the
PQconnectdbParams() function
(https://www.postgresql.org/docs/current/libpq-connect.html).

This also allow us to have slightly different database connection
parameters for different database connection. This is used here to add
the connection id into the fallback_application_name parameter. This
connection id also reported when using --log-sql. This way you can
correlate the ids from the log with the information shown in
pg_stat_activity.

This commit looks large, because it changes the type std::string to
connection_parameters_t in many places. I have kept the parameter name
"conninfo" in an effort to keep the commit small, the next commit will
change that also.
2024-02-01 10:37:35 +01:00
Sarah Hoffmann 6375e05087
Merge pull request #2120 from joto/add-test
Add test to make sure unset pg_result_t behaves sensibly
2024-01-27 10:28:13 +01:00
Jochen Topf ff91d49869 Update copyright date 2024-01-26 16:45:53 +01:00
Jochen Topf c5ea1d47da Add test to make sure unset pg_result_t behaves sensibly 2024-01-11 14:57:24 +01:00
Jochen Topf 482719e541 Use CLI11 command line parser library
This switches parsing of command line arguments from getopt to the CLI11
library.

Its adds CLI11 as a new dependency. With this commit CLI11 is vendored
in in the contrib directory, because it is not available in Ubuntu 20.04
and Debian before Bookworm. It is available in Ubuntu 22.04 und Debian
Bookworm and it is available in Homebrew and as vcpkg. So a bit down the
line we can switch to the versions available from the OS distribution.

For Windows we don't need the getopt version from alex85k any more and
this commit also removes that code from the Github action setup.

This commit is quite large, because we have to change everything at the
same time. Changes are for osm2pgsql and osm2pgsql-gen which now share
part of the option parsing code (database and logging options), in the
new src/command-line-app.[ch]pp files.

The code tries to keep the functionality the same as much as possible.
So no extra checks on command line options or so, these can come later.

There are some unavoidable changes:
* Some error messages have changed
* Help output is now generated by the CLI11 library so it looks very
  different. There is no verbose help version any more. All command
  line options are shown with --help, but some with a bit less detail
  than before. But all the detail is in the man page anyway.
* CLI11 can not parse an empty option parameter, so something like
  "--foo=" does not work, it tries to use the next option as value
  for the option. This is not very relevant in the real world, but
  there might be some corner cases where this changes behaviour.

See #142
2023-12-22 10:10:44 +01:00
Jochen Topf aa4507fad7 Remove need for output_backend_set boolean 2023-12-19 09:29:15 +01:00
Sarah Hoffmann bbff9f30d0
Merge pull request #2097 from joto/modernize-use-string-view
Refactor: Modernize get_count and require_has_table
2023-10-30 08:38:55 +01:00
Jochen Topf 368fbccaa9 Refactor: Modernize get_count and require_has_table
Use string_view parameters
2023-10-17 09:53:42 +02:00
Jochen Topf 90ac2c1475 Refactor: Modernize code, use nested namespace definition 2023-10-17 09:50:32 +02:00