Skip to content

OD Matrix miscalculates time cost if network CRS does not use linear units of meters #36

@josephholler

Description

@josephholler

QNEAT3 does not correctly apply a unit conversion if the network layer uses a CRS with linear units other than meters for time-optimization. For example, one speed cost was calculated as 36 seconds in a network layer using meters, but once projected to a coordinate system using feet, the cost was calculated at 118 seconds -- incorrect by the same factor as the conversion from feet to meters.

It seems like the QGIS network builder is automatically converting linear units into meters using self.meter_to_unit_factor , so calling the speed strategy function with a speed conversion factor of unit_to_meter_factor * 1000.0 / 3600.0 is negating the unit conversion that has already been applied to distance. I'm making an educated guess here, since I can't find the code in the QGIS algorithms where the linear unit conversion happens, but clearly it happening for distance strategy and I assume that it must also be doing the same for speed strategy. In either cases, revising unit_to_meter_factor * 1000.0 / 3600.0 to 1000.0 / 3600.0 is fixing the bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions