Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Support
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
otb
otb
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
  • Issues 207
    • Issues 207
    • List
    • Boards
    • Labels
    • Milestones
  • Merge Requests 8
    • Merge Requests 8
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Packages
    • Packages
    • Container Registry
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Main Repositories
  • otbotb
  • Issues
  • #1916

Closed
Open
Opened Jun 07, 2019 by Cédric Traizet@ctraizet
  • Report abuse
  • New issue
Report abuse New issue

type assertion in OGRFieldWrapper GetValue()

The GetValue<T>() method of otbOGRFieldWrapper returns the value of the field by calling the ogr method associated with type T, for example, if T=int, it will call ogr::GetFieldAsInteger.

There is an assertion that compares the type of the field object from wchich the method is called to the required type (l454 of otbOGRFieldWrapper.hxx):

assert(m_Definition.GetType() == Kind::value && "OGR field type mismatches the type of requested field value");

This means that, if otb is compiled with assertion, GetValue<int>() can only be called on integer fields, GetValue<string>() can only be called on string fields and so on.

The GetValue<T>() method of otbOGRFieldWrapper returns the value of the field by calling the ogr method associated with type T, for example, if T=int, it will call ogr::GetFieldAsInteger.

There is an assertion that compares the type of the field object from wchich the method is called to the required type (l454 of otbOGRFieldWrapper.hxx): I don't think this is the expected behavior of such a function, as ogr's GetFieldAsXXX can do conversions, for example calling atoi to convert string to int if GetFieldAsInt is called on a string field.

This method is used for example in the classification vector applications to fetch the fields and values of the input vector data. The input field can be a string (possible fields are defined in the DoExecute of the applications), but the assertion will fail as the class field is an integer.

There are a few tests failing because of this issue if the otb is compiled in debug mode (which does not happen or CI nor Dashboard if I'm correct). If we want to keep this assertion, we should replace GetValue by GetFieldAsXXX in classification applications.

Edited Jun 11, 2019 by Cédric Traizet
Assignee
Assign to
7.0.0
Milestone
7.0.0
Assign milestone
Time tracking
None
Due date
None
4
Labels
CNES backlog Doing bug ~03pt
Assign labels
  • View project labels
Reference: orfeotoolbox/otb#1916