[gdal-dev] Re: C GDAL beginner

deadpickle deadpickle at gmail.com
Wed Mar 3 00:01:41 EST 2010


Thanks for the reply. I was wonder what the deal is with the other
warnings:

#include "ogr_api.h"
#include "ogr_srs_api.h"

int main()
{
	//~ variable declaration
	const char *format = "ESRI Shapefile", *name = "testc.shp", *source,
*target;
	const char *sprj = "+proj=lcc +lat_1=33.000000 +lat_2=45.000000
+lat_0=39.000000 +lon_0=-96.000000 +x_0=0.0 +y_0=0.0 +datum=NAD83";
	const char *tprj = "WGS84";
	OGRSFDriverH driver;
	OGRDataSourceH ds;
	OGRCoordinateTransformationH ctrans;

	//~ get driver and create ds
	driver = OGRGetDriverByName(format);
	ds = OGR_Dr_CreateDataSource(driver, "testc.shp", NULL);

	//~ create spatrefs and trans
	OSRNewSpatialReference(source);
	OSRNewSpatialReference(target);
	OSRSetFromUserInput(source, sprj);
	OSRSetFromUserInput(target, tprj);
	ctrans = OCTNewCoordinateTransformation(target, source);

}

dal_test_convert.c: In function ‘main’:
gdal_test_convert.c:22: warning: passing argument 1 of â
€˜OSRSetFromUserInput’ discards qualifiers from pointer target type
gdal_test_convert.c:23: warning: passing argument 1 of â
€˜OSRSetFromUserInput’ discards qualifiers from pointer target type
gdal_test_convert.c:24: warning: passing argument 1 of â
€˜OCTNewCoordinateTransformation’ discards qualifiers from pointer
target type
gdal_test_convert.c:24: warning: passing argument 2 of â
€˜OCTNewCoordinateTransformation’ discards qualifiers from pointer
target type

On Mar 2, 10:48 pm, brian <r... at winkey.org> wrote:
> deadpickle,
>
> The types in the OGR C api pretty much end in H.
>
> OGRCoordinateTransformation ctrans;
> should read
> OGRCoordinateTransformationH ctrans;
>
> The function your looking for is OCTNewCoordinateTransformation().
>
> Brian
>
>
>
> On Tue, 2010-03-02 at 19:22 -0800, deadpickle wrote:
> > I'm trying to write a simple C program that creates and populates a
> > shapefile (have one done in python). I'm very new to C and GDAL both
> > and could use some help. I'm trying to apply coordinatetransformation
> > to my points but first I have to create the coordinatetransformation.
> > In python I can do this simply by:
> > coordtrans = osr.CoordinateTransformation(target, source)
> > but in C I cant seem to find the right call for this. Any ideas?
>
> > #include "ogr_api.h"
> > #include "ogr_srs_api.h"
>
> > int main()
> > {
> >    //~ variable declaration
> >    const char *format = "ESRI Shapefile", *name = "testc.shp", *source,
> > *target;
> >    const char *sprj = "+proj=lcc +lat_1=33.000000 +lat_2=45.000000
> > +lat_0=39.000000 +lon_0=-96.000000 +x_0=0.0 +y_0=0.0 +datum=NAD83";
> >    const char *tprj = "WGS84";
> >    OGRSFDriverH driver;
> >    OGRDataSourceH ds;
> >    OGRCoordinateTransformation ctrans;
>
> >    //~ get driver and create ds
> >    OGRRegisterAll();
> >    driver = OGRGetDriverByName(format);
> >    ds = OGR_Dr_CreateDataSource(driver, "testc.shp", NULL);
>
> >    //~ create spatrefs and trans
> >    OSRNewSpatialReference(source);
> >    OSRNewSpatialReference(target);
> >    OSRSetFromUserInput(source, sprj);
> >    OSRSetFromUserInput(target, tprj);
> >    ctrans = OGRCreateCoordinateTransformation(target, source);
> > }
>
> > [thor at updraft ~/Programs]$ gcc -o gdal_test_convert
> > gdal_test_convert.c
> > gdal_test_convert.c: In function main :
> > gdal_test_convert.c:12: error: OGRCoordinateTransformation
> > undeclared (first use in this function)
> > gdal_test_convert.c:12: error: (Each undeclared identifier is reported
> > only once
> > gdal_test_convert.c:12: error: for each function it appears in.)
> > gdal_test_convert.c:12: error: expected ; before ctrans
> > gdal_test_convert.c:22: warning: passing argument 1 of
> > OSRSetFromUserInput discards qualifiers from pointer target type
> > gdal_test_convert.c:23: warning: passing argument 1 of
> > OSRSetFromUserInput discards qualifiers from pointer target type
> > gdal_test_convert.c:24: error: ctrans undeclared (first use in
> > this function)
>
> > _______________________________________________
> > gdal-dev mailing list
> > gdal-... at lists.osgeo.org
> >http://lists.osgeo.org/mailman/listinfo/gdal-dev
>
> _______________________________________________
> gdal-dev mailing list
> gdal-... at lists.osgeo.orghttp://lists.osgeo.org/mailman/listinfo/gdal-dev


More information about the gdal-dev mailing list