Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6685093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:01:04+00:00 2026-05-26T05:01:04+00:00

I am trying to analyze a geotiff file, very simple, just trying to get

  • 0

I am trying to analyze a geotiff file, very simple, just trying to get all the tag information. I know there are libs available such as libtiff and libgeotiff. What I want to do is simple: read out all the tags.

The tag structure is:

struct ifd_entry
{
_int16 tag_id;
_int16 field_type;
_int16 field_count;
_int16 field_offset;
};

the field type is an int16, which stands for int8, int16, int32, float, double and other formats. The field_count indicates the number of data in the type. Field_offset indicates the field data location in the file starting from the file beginning.

What I want to do is to retrieve the tag and the field data it points to. I would like to write in a neat c++ way, but I do not know how to do that. It seems I cannot avoid using the switch statement to deal with each type separately:

class ifd
{
   ifd_entry hd;
   char *pfield;
public:   
   ifd(ifd_entry hd0,char *p); //allocate and copy the field data
   void print(); //print the ifd_entry and its field, have to use switch to cast to the correct type;
};

It might be trivial, but I wonder what would be the neat way in C++ to deal with such problems. Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:01:05+00:00Added an answer on May 26, 2026 at 5:01 am

    If the number of types is fixed and short, I would use Boost.Variant. Having a variant over the possible types, then the visitor pattern can be applied to for instance print the fields. The internal implementation may not be too different from what you are currently doing, but I find it more idiomatic.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get LinqPad use my dbml model so I could analyze a
I'm trying to analyze core dump, but i get following result. If i make
I'm trying to analyze a deadlock in SQL Server 2008 profiler. I know how
Using Python I am trying to analyze a tab delimited file. I open the
is there an open source tainting tool? I am trying to analyze a Java
I am trying to analyze a movie file by splitting it up into camera
I have this mysql query that I am trying to analyze. It is very
I am trying to analyze a JVM crash that is occuring inconsistently. I get
I'm trying to analyze an enormous text file (1.6GB), whose data lines look like
Lets suppose I am trying to analyze an algorithm and all I can do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.