MerginMaps / work-packages

Mergin Maps Work Packages: manage field surveys for multiple teams
MIT License
7 stars 4 forks source link

Use createRebasedChangesetEx from geodiff #6

Closed wonder-sk closed 2 years ago

wonder-sk commented 3 years ago

The algorithm would get a bit simpler if we used GEODIFF_createRebasedChangesetEx() call from geodiff, however pygeodiff currently does not include it...

wonder-sk commented 3 years ago

pygeodiff 1.0 includes the call:

geodiff.create_rebased_changeset_ex(driver, driver_info, base, base2modified, base2their, rebased, conflict_file)
wonder-sk commented 3 years ago

hopefully something like this (unchecked):

geodiff.create_rebased_changeset_ex(
    driver,        --- "sqlite" / "postgres"
    driver_info,   ---  ""      /  "host=localhost dbname=mydb username=...."
    base,          --- base database (.gpkg)
    base2our,      --- .diff file: changes from "base" to "our"  .gpkg 
    base2their,    --- .diff file: changes from "base" to "their"  .gpkg
    our_rebased,   --- output .diff created by rebase
    conflict_file) --- output .json created by rebase

BEFORE:

          [ base ]

base2our /      \  base2their

  [ our ]    [ their ]

AFTER:

  [ base ]
      |   base2their
  [ their ]
      |   our_rebased
  [ their+our ]

---------

geodiff.rebase()  == createRebasedChangeset + applyChangeset

-----------

base: [ master_gpkg_base ]
our: [ tmp_master_with_wp ]
their: [ master_gpkg_output ]

base2our: wp_changeset_base_input
base2their:  geodiff.create_changeset(wp_gpkg_base, master_gpkg_output, base2their)

----------
hopefully this:

geodiff.create_changeset(wp_gpkg_base, master_gpkg_output, base2their)

geodiff.create_rebased_changeset_ex(
    "sqlite",
    "",
    master_gpkg_base,
    wp_changeset_base_input,
    base2their,
    wp_rebased,
    wp_conflict_file)

geodiff.apply_changeset(master_gpkg_output, wp_rebased)