Skip to content

Commit

Permalink
Merge pull request #4607 from rouault/fix_4591
Browse files Browse the repository at this point in the history
HFA: enable to read GCPs from PAM .aux.xml (fixes #4591)
  • Loading branch information
rouault authored Oct 7, 2021
2 parents 780847d + 103cca9 commit 7d0eaba
Show file tree
Hide file tree
Showing 7 changed files with 1,072 additions and 1,100 deletions.
22 changes: 20 additions & 2 deletions autotest/gcore/hfa_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

import pytest

from osgeo import gdal
from osgeo import gdal, osr

import gdaltest

Expand Down Expand Up @@ -430,4 +430,22 @@ def test_hfa_create_compress_big_block():
assert got_data == src_ds.GetRasterBand(1).ReadRaster()



# GCPs go to PAM currently
def test_hfa_create_gcp():
filename = '/vsimem/test.img'
ds = gdal.GetDriverByName('HFA').Create(filename, 1, 1)
gcp1 = gdal.GCP()
gcp1.GCPPixel = 0
gcp1.GCPLine = 0
gcp1.GCPX = 440720.000
gcp1.GCPY = 3751320.000
sr = osr.SpatialReference()
sr.ImportFromEPSG(4326)
assert ds.SetGCPs((gcp1, ), sr.ExportToWkt()) == gdal.CE_None
ds = None
ds = gdal.Open(filename)
assert ds.GetGCPCount() == 1
assert ds.GetGCPSpatialRef() is not None
assert len(ds.GetGCPs()) == 1
ds = None
gdal.GetDriverByName('HFA').Delete(filename)
2 changes: 1 addition & 1 deletion gdal/frmts/hfa/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ clean:
$(O_OBJ): hfa.h hfa_p.h

hfatest: hfatest.$(OBJ_EXT) $(HFAOBJ:.o=.$(OBJ_EXT))
$(LD) hfatest.$(OBJ_EXT) $(HFAOBJ:.o=.$(OBJ_EXT)) ../../port/*.$(OBJ_EXT) ../../ogr/ogrsf_frmts/o/json_*.o ../../ogr/ogrsf_frmts/o/printbuf.o ../../ogr/ogrsf_frmts/o/arraylist.o ../../ogr/ogrsf_frmts/o/linkhash.o ../../ogr/ograpispy.o -L../.. -lgdal $(LIBS) -o hfatest
$(LD) hfatest.$(OBJ_EXT) $(HFAOBJ:.o=.$(OBJ_EXT)) ../../port/*.$(OBJ_EXT) ../../ogr/ogrsf_frmts/o/json_*.o ../../ogr/ogrsf_frmts/o/printbuf.o ../../ogr/ogrsf_frmts/o/arraylist.o ../../ogr/ogrsf_frmts/o/linkhash.o ../../ogr/ograpispy.o ../../ogr/ogr_proj_p.o -L../.. -lgdal $(LIBS) -o hfatest

install-obj: $(O_OBJ:.o=.$(OBJ_EXT))
8 changes: 6 additions & 2 deletions gdal/frmts/hfa/hfa_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

#include "cpl_error.h"
#include "cpl_vsi.h"
#include "ogr_spatialref.h"

#ifdef CPL_LSB
# define HFAStandard(n,p) {}
Expand Down Expand Up @@ -135,12 +136,15 @@ HFACreateLayer( HFAHandle psInfo, HFAEntry *poParent,
GIntBig nStackDataOffset,
int nStackCount, int nStackIndex );

char *
HFAPCSStructToWKT( const Eprj_Datum *psDatum,
std::unique_ptr<OGRSpatialReference>
HFAPCSStructToOSR( const Eprj_Datum *psDatum,
const Eprj_ProParameters *psPro,
const Eprj_MapInfo *psMapInfo,
HFAEntry *poMapInformation );

const char *const* HFAGetDatumMap();
const char *const* HFAGetUnitMap();

/************************************************************************/
/* HFABand */
/************************************************************************/
Expand Down
Loading

0 comments on commit 7d0eaba

Please sign in to comment.