OpenOrienteering / mapper

OpenOrienteering Mapper is a software for creating maps for the orienteering sport.
https://www.openorienteering.org/apps/mapper/
GNU General Public License v3.0
400 stars 106 forks source link

Point object angle/rotation is lost during DXF import #2133

Open MaBreaker opened 1 year ago

MaBreaker commented 1 year ago

Steps to reproduce

  1. Generate DXF file with rotated POINT objects (slope lines, springs, cave, bouldery field etc.)
  2. Import DXF into new map
  3. Point objects are not rotated as should, but pointing north

Actual behaviour

Point object rotation angle is defined in DXF file (like below POINT code 50 angle -167.00), but are lost in Import

POINT
8
101.1_slope_line
10
12345.00
20
67890.50
50
-167.00
0

Expected behaviour

Point object rotation angle should be set accordingly (when defined) during file import.

Proposal

I believe DXF file is imported through OGR and POINTs with importPointGeometry function. If so and if original DXF angle is stored into OGR symbol details (which I do not know) the same way as with Text objects, then it could work something like..

Object* OgrFileImport::importPointGeometry(OGRFeatureH feature, OGRGeometryH geometry)
{
  ...
  if (symbol->getType() == Symbol::Point)
  {
    auto object = new PointObject(symbol);
    object->setPosition(toMapCoord(OGR_G_GetX(geometry, 0), OGR_G_GetY(geometry, 0)));

    // get rotation angle from symbol details
    const auto& description = symbol->getDescription();
    auto split = description.indexOf(QLatin1Char(' '));
    auto angle = QStringRef(&description, 3, split-3).toDouble(&ok);
    if (ok)
    {
      object->setRotation(qDegreesToRadians(angle));
    }

    return object;
  }
  ...

Configuration

Mapper Version: 0.9.5 Operating System: All

dl3sdo commented 1 year ago

@MaBreaker: could you attach a small DXF test file to this issue?

dl3sdo commented 1 year ago

@MaBreaker: your proposed solution does not work that way. For text objects the angle (and anchor) is 'transported' within the 'description' property of the text symbol (see getSymbolForLabel()). For point objects no angle is retrieved and no description is set.

I doubt that this way of transporting object specific data should be applied to other objects types.

MaBreaker commented 1 year ago

@MaBreaker: your proposed solution does not work that way. For text objects the angle (and anchor) is 'transported' within the 'description' property of the text symbol (see getSymbolForLabel()). For point objects no angle is retrieved and no description is set.

I doubt that this way of transporting object specific data should be applied to other objects types.

Hi, that might be true, as mentioned I do not know exactly how GDAL OGR works and what information is provided through their tools and I do not have working QT compiler for OOM to see or test it in debug mode.

Texts are having angle for sure also when imported through OGR library.

However all point objects (beside texts) can have angle as well, if not then OGR library does not work correctly and are missing this important feature.

Attached one simple DXF having small depression in it with two slope lines, which both should be pointing to the centre of the depression, but as import angle feature is missing those booth are now falsely pointing north.

OOM does not import rotation angles corretcly image

OCAD works fine with rotation angle image

Example files attached slope.zip