[gdal-dev] NewDataset and SetBand error

2013-11-07 Thread Seung Ae Lim
Dear,

I make a console application with VS2010 linking gdal_i.lib.
The steps are :
1. Create New Dataset and Band in main.cpp
class XXDataset : public GDALPamDataset
{
public:
XXDataset() {};
~XXDataset() {};

static GDALDataset* Open(GDALOpenInfo*);
};

class XXRasterBand : public GDALPamRasterBand
{
public:
XXRasterBand( GDALDataset*, int, GDALDataType );
~XXRasterBand() {};
};



GDALDataset* XXDataset::Open(GDALOpenInfo* pOpenInfo)
{
XXDataset* poDS = new XXDataset();
poDS- nRasterXSize = 100;
poDS- nRasterYSize = 200;
poDS- eAccess = GA_Update;
poDS- nBands = 3;

int iBand = 0;
for(iBand = 1; iBand  = 3; iBand++ )
{
XXRasterBand* band = new XXRasterBand( poDS, iBand, GDT_Byte);
poDS- SetBand( iBand, band );
}

return poDS;
}

XXRasterBand::XXRasterBand( GDALDataset *poDS, int nBand, GDALDataType eType)
{
this- poDS = poDS;
this- nBand = nBand;
this- eDataType = eType;
nRasterXSize = 100;
nRasterYSize = 200;
nBlockXSize = nRasterXSize;
nBlockYSize = nRasterYSize;
}

2. Add the code in main function
void main()
{


GDALDataset* pDSTemp = XXDataset::Open(NULL);
if (pDSTemp) GDALClose(pDSTemp);
}



I compile and try to debug this app.
But in poDS-SetBand line of XXDataset::Open, the app is broken when the 
first band is ready to set.
In XXDataset::Open, all value of parameters is right.
But When stepping into the SetBand function, the values may be corrupted.
papobands of GDALDataset is not null and it make an error.

Please let me know the reason or some tips.

Thanks.

___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] geotiff projection not showing up

2013-11-07 Thread Frank Warmerdam
Norman,

My apologies.  The GCP projection is actually supposed to be passed as the
third value in the SetGCPs call - where you have passed the string
Richmond.  Instead pass the whole WKT strings for the coordinate system.

Best regards,
Frank


On Wed, Nov 6, 2013 at 4:00 PM, Norman Goldstein norm...@telus.net wrote:

  Frank,

 I am using GDAL
 Version : 1.9.2

 so maybe that is why I do not see the method SetGCPProjection().

 I think you have convinced me, though, to calculate the 6 coefficients
 directly,
 and then call SetGeoTransform().  Will let you guys know how this works out
 for me.

 Thank you,
 Norm



 On 11/06/2013 01:51 PM, Frank Warmerdam wrote:

 Norman,

  I believe you want to call SetGCPProjection() instead of SetProjection()
 when using GCPs instead of an affine transform.

  Best regards,
 Frank



 On Wed, Nov 6, 2013 at 1:23 PM, Norman Goldstein norm...@telus.netwrote:

 I have created a geotiff file using the GTiff driver, and have
 successfully set options for it to be a strips file with no compression.
  Also, successfully called the functions

 dataset-SetMetadataItem( AREA_OR_POINT,
 Point,
  nullptr ) )

 and

 dataset-SetGCPs( 3,
gcps,
Richmond )

 Here is the listgeo dump:

 # listgeo dump ##
 Geotiff_Information:
Version: 1
Key_Revision: 1.0
Tagged_Information:
   ModelTiepointTag (6,3):
  0249  0
  000
  399  249  0
  1000 00
  000
  02000 0
   End_Of_Tags.
Keyed_Information:
   GTRasterTypeGeoKey (Short,1): RasterPixelIsPoint
   End_Of_Keys.
End_Of_Geotiff.


 Corner Coordinates:
  ... unable to transform points between pixel/line and PCS space
 #

 I also set the reference system using the following code:

 /// c++ code 
   OGRSpatialReference oSRS;
   oSRS.SetProjCS( NoWhere );
   oSRS.SetWellKnownGeogCS( WGS84 );
   oSRS.SetEquirectangular( 0.0,// Centre lat
0.0,// Centre lon
0.0,   // False Easting
0.0 ); // False Northing

   char* wkt = nullptr;

   if( OGRERR_NONE != oSRS.exportToPrettyWkt( wkt ) )
   {
  error...
   }

   if( CE_Failure == dataset-SetProjection( wkt ) )
   {
error...
   }
 ///

 So, why is listgeo not able to transform points between pixel/line and
 PCS space?

 I am happy to upload a full working example if needed.

 Thank you.












 ___
 gdal-dev mailing list
 gdal-dev@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/gdal-dev




  --

 ---+--
 I set the clouds in motion - turn up   | Frank Warmerdam,
 warmer...@pobox.com
 light and sound - activate the windows | http://pobox.com/~warmerdam
 and watch the world go round - Rush| Geospatial Software Developer



 ___
 gdal-dev mailing list
 gdal-dev@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/gdal-dev




-- 
---+--
I set the clouds in motion - turn up   | Frank Warmerdam,
warmer...@pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush| Geospatial Software Developer
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

[gdal-dev] Writing GPX Files with multiple Extensions

2013-11-07 Thread Pouliot, Christopher (MNIT)
Hello All,

I am currently using GDAL 1.9 and I'm writing out GPX files for uploading onto 
Garmin units.  Garmin has many different GPX extensions (gpxx, gpxtpx, gpxtrx, 
etc) for defining extra attributes for their GPS data.  I am wondering how I 
would specify these multiple extensions in my code?  Currently, I am defining a 
single extension as shown below:

ds = drv.CreateDataSource(outputFilePath, new string[] { 
GPX_USE_EXTENSIONS=YES,GPX_EXTENSIONS_NS=gpxx,GPX_EXTENSIONS_NS_URL=http://www.garmin.com/xmlschemas/GpxExtensions/v3});}

How would I go about setting more namespaces (gpxtpx, gpxtrx, ...)?  And then 
how would I specify that an attribute belongs in a particular extension?

Thanks,

Chris

Chris Pouliot  |  GIS Application Developer
MN.IT Services @ Department of Natural Resources
(651) 259-5491 (w)  |  christopher.poul...@state.mn.us
[cid:image002.jpg@01CEDB9E.F20C9670]http://www.mn.gov/oet  Information 
Technology for Minnesota Government   |   mn.gov/oethttp://www.mn.gov/oet

inline: image002.jpg___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] gdal_translate produces tif with different colors as original

2013-11-07 Thread Andre Joost

Am 06.11.2013 21:32, schrieb Jukka Rahkonen:


You're advised to preprocess your rasters with other
tools, such as pct2rgb.py or gdal_translate -expand RGB to operate
gdalbuildvrt on RGB rasters instead.



I proposed that, but have a look at the color palette of the VRT:

http://gis.stackexchange.com/questions/76662/gdal-translate-produces-tif-with-different-colors-as-original

Is it a fault of the source or the driver?

Greetings,
André Joost

___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] Difference: EPSG 3004 - EPSG 102092

2013-11-07 Thread Andre Joost
Am 07.11.2013 16:39, schrieb 
b.j.kob...@utwente.nl:

As an added note: be aware that 102092 is NOT an actual EPSG code. EPSG
codes with no's  32768 are not in the official EPSG database, and are in
actual fact therefore not EPSG codes really.



It is actually a definition by ESRI:
http://spatialreference.org/ref/esri/102092/

and we all know that they keep datum shifts always seperately from 
projection definitions.


I don't understand why QGIS 2.0 (and GDAL 1.10.0) simply calls them EPSG.
QGIS 1.8.0 Lisboa did not know those codes, and they named French 
definitions IGNF:...


I would like to see those ESRI definitions marked ESRI:... to flag the 
difference.


** added mailing lists for proj.4 and gdal as it comes probably from there

Greetings,
André Joost

___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev


Re: [gdal-dev] NewDataset and SetBand error

2013-11-07 Thread Frank Warmerdam
Seung,

If the fields, like papoBands in the dataset seem ok before stepping into
SetBand(), and corrupt once you are inside I would suspect that GDAL and
your application have been built with different gdal_priv.h include files
*or* with different structure alighnments flags for Visual Studio.  Did you
build GDAL from source using the same configuration you are building your
application with?

Best regards,
Frank



On Thu, Nov 7, 2013 at 1:03 AM, Seung Ae Lim sa...@pixoneer.co.kr wrote:

   Dear,



  I make a console application with VS2010 linking gdal_i.lib.

  The steps are :

 * 1. Create New Dataset and Band in main.cpp*
 class XXDataset : public GDALPamDataset
 {
 public:
  XXDataset() {};
  ~XXDataset() {};

  static GDALDataset* Open(GDALOpenInfo*);
 };

 class XXRasterBand : public GDALPamRasterBand
 {
 public:
  XXRasterBand( GDALDataset*, int, GDALDataType );
  ~XXRasterBand() {};
 };


 GDALDataset* XXDataset::Open(GDALOpenInfo* pOpenInfo)
 {
  XXDataset* poDS = new XXDataset();
  poDS- nRasterXSize = 100;
  poDS- nRasterYSize = 200;
  poDS- eAccess = GA_Update;
  poDS- nBands = 3;

  int iBand = 0;
  for(iBand = 1; iBand  = 3; iBand++ )
  {
  XXRasterBand* band = new XXRasterBand( poDS, iBand, GDT_Byte);
  poDS- SetBand( iBand, band );
  }

  return poDS;
 }

 XXRasterBand::XXRasterBand( GDALDataset *poDS, int nBand, GDALDataType
 eType)
 {
  this- poDS = poDS;
  this- nBand = nBand;
  this- eDataType = eType;
  nRasterXSize = 100;
  nRasterYSize = 200;
  nBlockXSize = nRasterXSize;
  nBlockYSize = nRasterYSize;
 }

 *2. Add the code in main function*
 void main()
 {


 GDALDataset* pDSTemp = XXDataset::Open(NULL);
  if (pDSTemp) GDALClose(pDSTemp);
 }


 I compile and try to debug this app.
 But in poDS-SetBand line of XXDataset::Open, the app is broken when
 the first band is ready to set.
 In XXDataset::Open, all value of parameters is right.
 But When stepping into the SetBand function, the values may be corrupted.
 papobands of GDALDataset is not null and it make an error.

 Please let me know the reason or some tips.

 Thanks.




 ___
 gdal-dev mailing list
 gdal-dev@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/gdal-dev




-- 
---+--
I set the clouds in motion - turn up   | Frank Warmerdam,
warmer...@pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush| Geospatial Software Developer
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

[gdal-dev] Could you approve my post

2013-11-07 Thread Victor R
Could you approve my post? 

http://osgeo-org.1560.x6.nabble.com/gdal-dev-C-ogr-wrap-dll-exception-with-ogr-OGRERR-NONE-td5044742.html#a5088006
 ___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] Could you approve my post

2013-11-07 Thread Mateusz Loskot
On 7 November 2013 17:12, Victor R va...@ukr.net wrote:

  Could you approve my post?


 http://osgeo-org.1560.x6.nabble.com/gdal-dev-C-ogr-wrap-dll-exception-with-ogr-OGRERR-NONE-td5044742.html#a5088006



Please, read this section
http://wiki.osgeo.org/wiki/Mailing_Lists#Nabble
and verify your Nabble account uses exactly the same e-mail address
as your gdal-dev subscribtion.
You may want to ask Nabble folks for help if you need further clarifications
on how to use Nabble with mailing lists.

Best regards,
-- 
Mateusz  Loskot, http://mateusz.loskot.net
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] Writing GPX Files with multiple Extensions

2013-11-07 Thread Even Rouault
Le jeudi 07 novembre 2013 16:51:35, Pouliot, Christopher (MNIT) a écrit :
 Hello All,
 
 I am currently using GDAL 1.9 and I'm writing out GPX files for uploading
 onto Garmin units.  Garmin has many different GPX extensions (gpxx,
 gpxtpx, gpxtrx, etc) for defining extra attributes for their GPS data.  I
 am wondering how I would specify these multiple extensions in my code? 
 Currently, I am defining a single extension as shown below:
 
 ds = drv.CreateDataSource(outputFilePath, new string[] {
 GPX_USE_EXTENSIONS=YES,GPX_EXTENSIONS_NS=gpxx,GPX_EXTENSIONS_NS_URL=h
 ttp://www.garmin.com/xmlschemas/GpxExtensions/v3});}
 
 How would I go about setting more namespaces (gpxtpx, gpxtrx, ...)?

This is not possible currently. Would require an enhancement in the driver, 
like acception a comma separated list of values for GPX_EXTENSIONS_NS and 
GPX_EXTENSIONS_NS_URL

 And
 then how would I specify that an attribute belongs in a particular
 extension?

It could detect it by the name of attribute. For example, gpxx_foo, 
gpxtpx_bar, gpxtrx_baz

 
 Thanks,
 
 Chris
 
 Chris Pouliot  |  GIS Application Developer
 MN.IT Services @ Department of Natural Resources
 (651) 259-5491 (w)  |  christopher.poul...@state.mn.us
 [cid:image002.jpg@01CEDB9E.F20C9670]http://www.mn.gov/oet  Information
 Technology for Minnesota Government   |  
 mn.gov/oethttp://www.mn.gov/oet

-- 
Geospatial professional services
http://even.rouault.free.fr/services.html
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] Writing GPX Files with multiple Extensions

2013-11-07 Thread Pouliot, Christopher (MNIT)
Even,

Thanks for the response!  I see that GPSBabel uses GDAL and writes out multiple 
extensions.  I'll check with them to see how they are doing it.

Chris

-Original Message-
From: Even Rouault [mailto:even.roua...@mines-paris.org] 
Sent: Thursday, November 07, 2013 1:22 PM
To: gdal-dev@lists.osgeo.org
Cc: Pouliot, Christopher (MNIT)
Subject: Re: [gdal-dev] Writing GPX Files with multiple Extensions

Le jeudi 07 novembre 2013 16:51:35, Pouliot, Christopher (MNIT) a écrit :
 Hello All,
 
 I am currently using GDAL 1.9 and I'm writing out GPX files for 
 uploading onto Garmin units.  Garmin has many different GPX extensions 
 (gpxx, gpxtpx, gpxtrx, etc) for defining extra attributes for their 
 GPS data.  I am wondering how I would specify these multiple extensions in my 
 code?
 Currently, I am defining a single extension as shown below:
 
 ds = drv.CreateDataSource(outputFilePath, new string[] { 
 GPX_USE_EXTENSIONS=YES,GPX_EXTENSIONS_NS=gpxx,GPX_EXTENSIONS_NS_U
 RL=h ttp://www.garmin.com/xmlschemas/GpxExtensions/v3});}
 
 How would I go about setting more namespaces (gpxtpx, gpxtrx, ...)?

This is not possible currently. Would require an enhancement in the driver, 
like acception a comma separated list of values for GPX_EXTENSIONS_NS and 
GPX_EXTENSIONS_NS_URL

 And
 then how would I specify that an attribute belongs in a particular 
 extension?

It could detect it by the name of attribute. For example, gpxx_foo, gpxtpx_bar, 
gpxtrx_baz

 
 Thanks,
 
 Chris
 
 Chris Pouliot  |  GIS Application Developer MN.IT Services @ 
 Department of Natural Resources
 (651) 259-5491 (w)  |  christopher.poul...@state.mn.us 
 [cid:image002.jpg@01CEDB9E.F20C9670]http://www.mn.gov/oet  Information
 Technology for Minnesota Government   |  
 mn.gov/oethttp://www.mn.gov/oet

--
Geospatial professional services
http://even.rouault.free.fr/services.html

___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] Writing GPX Files with multiple Extensions

2013-11-07 Thread Even Rouault
Le jeudi 07 novembre 2013 20:41:48, Pouliot, Christopher (MNIT) a écrit :
 Even,
 
 Thanks for the response!  I see that GPSBabel uses GDAL

Really ? OGR has a GPSBabel driver, but I didn't know that the reversed way 
existed.

 and writes out
 multiple extensions.  I'll check with them to see how they are doing it.

GPSBabel has its own GPX reader/writer. It wouldn't be difficult to extend the 
OGR GPX driver to implement what I mentionned below. Alternatively you could 
generate the GPX yourself. It is quite easy.

 
 Chris
 
 -Original Message-
 From: Even Rouault [mailto:even.roua...@mines-paris.org]
 Sent: Thursday, November 07, 2013 1:22 PM
 To: gdal-dev@lists.osgeo.org
 Cc: Pouliot, Christopher (MNIT)
 Subject: Re: [gdal-dev] Writing GPX Files with multiple Extensions
 
 Le jeudi 07 novembre 2013 16:51:35, Pouliot, Christopher (MNIT) a écrit :
  Hello All,
  
  I am currently using GDAL 1.9 and I'm writing out GPX files for
  uploading onto Garmin units.  Garmin has many different GPX extensions
  (gpxx, gpxtpx, gpxtrx, etc) for defining extra attributes for their
  GPS data.  I am wondering how I would specify these multiple extensions
  in my code? Currently, I am defining a single extension as shown below:
  
  ds = drv.CreateDataSource(outputFilePath, new string[] {
  GPX_USE_EXTENSIONS=YES,GPX_EXTENSIONS_NS=gpxx,GPX_EXTENSIONS_NS_U
  RL=h ttp://www.garmin.com/xmlschemas/GpxExtensions/v3});}
  
  How would I go about setting more namespaces (gpxtpx, gpxtrx, ...)?
 
 This is not possible currently. Would require an enhancement in the driver,
 like acception a comma separated list of values for GPX_EXTENSIONS_NS and
 GPX_EXTENSIONS_NS_URL
 
  And
  then how would I specify that an attribute belongs in a particular
  extension?
 
 It could detect it by the name of attribute. For example, gpxx_foo,
 gpxtpx_bar, gpxtrx_baz
 
  Thanks,
  
  Chris
  
  Chris Pouliot  |  GIS Application Developer MN.IT Services @
  Department of Natural Resources
  (651) 259-5491 (w)  |  christopher.poul...@state.mn.us
  [cid:image002.jpg@01CEDB9E.F20C9670]http://www.mn.gov/oet  Information
  Technology for Minnesota Government   |
  mn.gov/oethttp://www.mn.gov/oet
 
 --
 Geospatial professional services
 http://even.rouault.free.fr/services.html

-- 
Geospatial professional services
http://even.rouault.free.fr/services.html
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] Writing GPX Files with multiple Extensions

2013-11-07 Thread Pouliot, Christopher (MNIT)
Attached is a sample from downloading one Waypoint and a track using GPSBabel.  
I'll look into the GPSBabel driver.  I don't have much time to devote to this 
so hope to find a relatively quick solution.

Thanks again!

Chris


-Original Message-
From: Even Rouault [mailto:even.roua...@mines-paris.org] 
Sent: Thursday, November 07, 2013 1:47 PM
To: Pouliot, Christopher (MNIT)
Cc: gdal-dev@lists.osgeo.org
Subject: Re: [gdal-dev] Writing GPX Files with multiple Extensions

Le jeudi 07 novembre 2013 20:41:48, Pouliot, Christopher (MNIT) a écrit :
 Even,
 
 Thanks for the response!  I see that GPSBabel uses GDAL

Really ? OGR has a GPSBabel driver, but I didn't know that the reversed way 
existed.

 and writes out
 multiple extensions.  I'll check with them to see how they are doing it.

GPSBabel has its own GPX reader/writer. It wouldn't be difficult to extend the 
OGR GPX driver to implement what I mentionned below. Alternatively you could 
generate the GPX yourself. It is quite easy.

 
 Chris
 
 -Original Message-
 From: Even Rouault [mailto:even.roua...@mines-paris.org]
 Sent: Thursday, November 07, 2013 1:22 PM
 To: gdal-dev@lists.osgeo.org
 Cc: Pouliot, Christopher (MNIT)
 Subject: Re: [gdal-dev] Writing GPX Files with multiple Extensions
 
 Le jeudi 07 novembre 2013 16:51:35, Pouliot, Christopher (MNIT) a écrit :
  Hello All,
  
  I am currently using GDAL 1.9 and I'm writing out GPX files for 
  uploading onto Garmin units.  Garmin has many different GPX 
  extensions (gpxx, gpxtpx, gpxtrx, etc) for defining extra attributes 
  for their GPS data.  I am wondering how I would specify these 
  multiple extensions in my code? Currently, I am defining a single extension 
  as shown below:
  
  ds = drv.CreateDataSource(outputFilePath, new string[] { 
  GPX_USE_EXTENSIONS=YES,GPX_EXTENSIONS_NS=gpxx,GPX_EXTENSIONS_NS
  _U RL=h ttp://www.garmin.com/xmlschemas/GpxExtensions/v3});}
  
  How would I go about setting more namespaces (gpxtpx, gpxtrx, ...)?
 
 This is not possible currently. Would require an enhancement in the 
 driver, like acception a comma separated list of values for 
 GPX_EXTENSIONS_NS and GPX_EXTENSIONS_NS_URL
 
  And
  then how would I specify that an attribute belongs in a particular 
  extension?
 
 It could detect it by the name of attribute. For example, gpxx_foo, 
 gpxtpx_bar, gpxtrx_baz
 
  Thanks,
  
  Chris
  
  Chris Pouliot  |  GIS Application Developer MN.IT Services @ 
  Department of Natural Resources
  (651) 259-5491 (w)  |  christopher.poul...@state.mn.us 
  [cid:image002.jpg@01CEDB9E.F20C9670]http://www.mn.gov/oet  Information
  Technology for Minnesota Government   |
  mn.gov/oethttp://www.mn.gov/oet
 
 --
 Geospatial professional services
 http://even.rouault.free.fr/services.html

--
Geospatial professional services
http://even.rouault.free.fr/services.html



babel.gpx
Description: babel.gpx
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] NewDataset and SetBand error

2013-11-07 Thread Seung Ae Lim
I build GDAL library just opening makegdal10.sln.
My test program is just simple console application with VS2010 without any 
added configuration.
GDAL :f:\gdal-1.10.0\
Test program include config 
:f:\gdal-1.10.0\port\;f:\gdal-1.10.0\gcore;f:\gdal-1.10.0\ogr;f:\gdal-1.10.0\frmts;
Test program link path :f:\gdal-1.10.0\gdal_i.lib

In my thought, my program may use same sources with GDAL.

Is there any GDAL configuration for my program?

Thanks.
Seung Ae


- Original Message -
From:Frank Warmerdam [warmer...@pobox.com]
To:Seung Ae Lim [sa...@pixoneer.co.kr]
Cc:gdal dev [gdal-dev@lists.osgeo.org]
Sent:Fri , November 08, 2013 01:31 AM
Subject:Re: [gdal-dev] NewDataset and SetBand error




Seung,


If the fields, like papoBands in the dataset seem ok before stepping into 
SetBand(), and corrupt once you are inside I would suspect that GDAL and your 
application have been built with different gdal_priv.h include files *or* with 
different structure alighnments flags for Visual Studio. Did you build GDAL 
from source using the same configuration you are building your application with?


Best regards,
Frank






On Thu, Nov 7, 2013 at 1:03 AM, Seung Ae Lim  sa...@pixoneer.co.kr  wrote:



Dear,

I make a console application with VS2010 linking gdal_i.lib.
The steps are :
1. Create New Dataset and Band in main.cpp
class XXDataset : public GDALPamDataset
{
public:
XXDataset() {};
~XXDataset() {};

static GDALDataset* Open(GDALOpenInfo*);
};

class XXRasterBand : public GDALPamRasterBand
{
public:
XXRasterBand( GDALDataset*, int, GDALDataType );
~XXRasterBand() {};
};



GDALDataset* XXDataset::Open(GDALOpenInfo* pOpenInfo)
{
XXDataset* poDS = new XXDataset();
poDS-  nRasterXSize = 100;
poDS-  nRasterYSize = 200;
poDS-  eAccess = GA_Update;
poDS-  nBands = 3;

int iBand = 0;
for(iBand = 1; iBand   = 3; iBand++ )
{
XXRasterBand* band = new XXRasterBand( poDS, iBand, GDT_Byte);
poDS-  SetBand( iBand, band );
}

return poDS;
}

XXRasterBand::XXRasterBand( GDALDataset *poDS, int nBand, GDALDataType eType)
{
this-  poDS = poDS;
this-  nBand = nBand;
this-  eDataType = eType;
nRasterXSize = 100;
nRasterYSize = 200;
nBlockXSize = nRasterXSize;
nBlockYSize = nRasterYSize;
}

2. Add the code in main function
void main()
{


GDALDataset* pDSTemp = XXDataset::Open(NULL);
if (pDSTemp) GDALClose(pDSTemp);
}



I compile and try to debug this app.
But in poDS- SetBand line of XXDataset::Open, the app is broken when the 
first band is ready to set.
In XXDataset::Open, all value of parameters is right.
But When stepping into the SetBand function, the values may be corrupted.
papobands of GDALDataset is not null and it make an error.

Please let me know the reason or some tips.

Thanks.



  

___

gdal-dev mailing list

gdal-dev@lists.osgeo.org

http://lists.osgeo.org/mailman/listinfo/gdal-dev








-- 

---+--

I set the clouds in motion - turn up | Frank Warmerdam, warmer...@pobox.com

light and sound - activate the windows | http://pobox.com/~warmerdam

and watch the world go round - Rush  | Geospatial Software Developer

___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

[gdal-dev] [PATCH v2] Support Mercator_2SP in GeoTIFF

2013-11-07 Thread Trent Piepho
Mercator_[12]SP are both the same projection in GeoTIFF.  Lacking a
definition in the official specification, the intention appears to be that
for Mercator_2SP the latitude of true scale (lat_ts) should be specified in
ProjStdParallel1GeoKey and for Mercator_1SP the scale at origin (k) should
be specified in ProjScaleAtNatOriginGeoKey.  As proposed here,
http://permalink.gmane.org/gmane.comp.gis.geotiff/387

Current behavior when creating a GTiff with 2SP is to drop lat_ts and create
a default k value of 1.0, which will product an incorrect projection.  When
reading, 1SP is always used and lat_ts is ignored.  It is expected that
libgeotiff will provide a default k of 1.0 if none was specified in the
file.

This patches changes the behavior when writing to supply
ProjScaleAtNatOriginGeoKey for Mercator_1SP or ProjStdParallel1GeoKey for
Mercator_2SP.

When reading, 2SP is used if ProjStdParallel1GeoKey is present and 1SP is
used otherwise.  A warning is issued if both keys are present (and scale is
ignored).  It is expected that libgeotiff's normalization will continue to
provide a default scale of 1.0 if neither parameter is present.
---
v2
Split out libgeotiff part.  This patch does not need the libgeotiff
patch to be applied.  Will write correctly without libgeotiff patch. 
Reading will be unchanged unless libgeotiff is also patched.

 gdal/frmts/gtiff/gt_wkt_srs.cpp |   28 ++--
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/gdal/frmts/gtiff/gt_wkt_srs.cpp b/gdal/frmts/gtiff/gt_wkt_srs.cpp
index 5934df5..0afb101 100644
--- a/gdal/frmts/gtiff/gt_wkt_srs.cpp
+++ b/gdal/frmts/gtiff/gt_wkt_srs.cpp
@@ -737,9 +737,21 @@ char *GTIFGetOGISDefn( GTIF *hGTIF, GTIFDefn * psDefn )
 break;
 
   case CT_Mercator:
-oSRS.SetMercator( adfParm[0], adfParm[1],
-  adfParm[4],
-  adfParm[5], adfParm[6] );
+/* If a lat_ts was specified use 2SP, otherwise use 1SP */
+if (psDefn-ProjParmId[2] == ProjStdParallel1GeoKey)
+{
+if (psDefn-ProjParmId[4] == ProjScaleAtNatOriginGeoKey)
+CPLError( CE_Warning, CPLE_AppDefined,
+  Mercator projection should not define both 
StdParallel1 and ScaleAtNatOrigin.\n
+  Using StdParallel1 and ignoring 
ScaleAtNatOrigin.\n );
+oSRS.SetMercator2SP( adfParm[2],
+ adfParm[0], adfParm[1],
+ adfParm[5], adfParm[6]);
+}
+else
+oSRS.SetMercator( adfParm[0], adfParm[1],
+  adfParm[4],
+  adfParm[5], adfParm[6] );
   
 if (psDefn-Projection == 1024 || psDefn-Projection == 9841) // 
override hack for google mercator. 
 {
@@ -1510,14 +1522,18 @@ int GTIFSetFromOGISDefn( GTIF * psGTIF, const char 
*pszOGCWKT )
 GTIFKeySet(psGTIF, ProjNatOriginLongGeoKey, TYPE_DOUBLE, 1,
poSRS-GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 ) );
 
-GTIFKeySet(psGTIF, ProjScaleAtNatOriginGeoKey, TYPE_DOUBLE, 1,
-   poSRS-GetNormProjParm( SRS_PP_SCALE_FACTOR, 1.0 ) );
-
 GTIFKeySet(psGTIF, ProjFalseEastingGeoKey, TYPE_DOUBLE, 1,
poSRS-GetProjParm( SRS_PP_FALSE_EASTING, 0.0 ) );
 
 GTIFKeySet(psGTIF, ProjFalseNorthingGeoKey, TYPE_DOUBLE, 1,
poSRS-GetProjParm( SRS_PP_FALSE_NORTHING, 0.0 ) );
+
+if( EQUAL(pszProjection,SRS_PT_MERCATOR_2SP) )
+GTIFKeySet(psGTIF, ProjStdParallel1GeoKey, TYPE_DOUBLE, 1,
+   poSRS-GetNormProjParm( SRS_PP_STANDARD_PARALLEL_1, 0.0 
) );
+else
+GTIFKeySet(psGTIF, ProjScaleAtNatOriginGeoKey, TYPE_DOUBLE, 1,
+   poSRS-GetNormProjParm( SRS_PP_SCALE_FACTOR, 1.0 ) );
 }
 
 else if( EQUAL(pszProjection,SRS_PT_OBLIQUE_STEREOGRAPHIC) )
-- 
1.7.10.4

___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev