[Proj] Welcome to the "Proj" mailing list

jamesmikedupont at googlemail.com jamesmikedupont at googlemail.com
Mon Jan 4 06:44:56 EST 2010


here is my patch so far.

I can understand the desire to keep things simple. I would have never
even bothered to compile this at all if I did not have problems. My
problem was the usage of radians that is dependant on the combination
of projections. This is something that could be hidden by the
templates and done automatically. It is done in cs2cs but not in the
api.

My idea about the templates is very simple, to be able to create a
single function

newcood= f<fromproj,toproj>(coord)

it would not need any initialization of the projections, but the
projections would be selected via templates. That would allow for a
very fast usage.

mike


On Mon, Jan 4, 2010 at 12:38 PM, Jan Hartmann <j.l.h.hartmann at uva.nl> wrote:
> I would prefer to keep the code of the library itself as standard-C like as
> possible. It is scientific programming, could be done just as well in
> Fortran (preferably not, of course :-)). On the other hand, what someone
> does on top of this library (e.g. building user interfaces in Fortran),
> should be doable in any other language.
>
> Jan
>
> On 4-1-2010 12:27, jamesmikedupont at googlemail.com wrote:
>>
>> Yes,
>> Of course. My plan was to test this and submit it to the main branch.
>> In fact, I would not have published this at all, but was having
>> problems and wanted help. Now I have resolved the issues and this
>> branch is not needed any more.
>>
>> This is just a working snapshot.
>> Ideally there more work to do with c++ and proj.
>> Like to move the configuration of the projections to templates..
>>
>>
>> mike
>>
>> On Mon, Jan 4, 2010 at 12:20 PM, Jan Hartmann<j.l.h.hartmann at uva.nl>
>>  wrote:
>>
>>>
>>> If it is just a patch to make the source code c++ compliant, IMHO it
>>> belongs
>>> in the main branch. Useful for indepentdent C++ projects that would like
>>> to
>>> link in the PROJ4 library.
>>>
>>> Jan
>>>
>>> On 4-1-2010 12:10, jamesmikedupont at googlemail.com wrote:
>>>
>>>>
>>>> It does not do anything more at the moment.
>>>>
>>>> This is just compiling with c++, you can apply the patch if you like.
>>>>
>>>> mike
>>>>
>>>>
>>>> On Mon, Jan 4, 2010 at 12:09 PM, Jan Hartmann<j.l.h.hartmann at uva.nl>
>>>>  wrote:
>>>>
>>>>
>>>>>
>>>>> On 4-1-2010 8:47, jamesmikedupont at googlemail.com wrote:
>>>>>
>>>>>
>>>>>>
>>>>>> In addition, I have started a c++ branch of proj4, and have resolved
>>>>>> some compile problems.
>>>>>> Feel free to check it out
>>>>>> http://github.com/h4ck3rm1k3/ProjC--/
>>>>>>
>>>>>> mike
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> Just curious, what does this branch do that the main tree doesn' t?
>>>>>
>>>>> Jan
>>>>>
>>>>>
>>>>>
>>>
>>>
>
-------------- next part --------------
Index: src/pj_transform.c
===================================================================
--- src/pj_transform.c	(revision 2650)
+++ src/pj_transform.c	(working copy)
@@ -142,6 +142,8 @@
         {
             XY         projected_loc;
             LP	       geodetic_loc;
+	    projected_loc.u = 0.0;
+            projected_loc.v = 0.0;
 
             projected_loc.u = x[point_offset*i];
             projected_loc.v = y[point_offset*i];
Index: src/pj_ell_set.c
===================================================================
--- src/pj_ell_set.c	(revision 2650)
+++ src/pj_ell_set.c	(working copy)
@@ -74,7 +74,15 @@
 			pj_param(pl, "tR_lat_g").i) { /* or geom. mean at latitude */
 			double tmp;
 
-			tmp = sin(pj_param(pl, i ? "rR_lat_a" : "rR_lat_g").f);
+
+			char temp[10];
+			strcpy(temp,i ? "rR_lat_a" : "rR_lat_g");
+			tmp = sin(
+				  pj_param(pl, 
+					   temp
+					   ).f
+				  );
+
 			if (fabs(tmp) > HALFPI) {
 				pj_errno = -11;
 				goto bomb;
Index: src/dmstor.c
===================================================================
--- src/dmstor.c	(revision 2650)
+++ src/dmstor.c	(working copy)
@@ -65,7 +65,11 @@
 		++s;
 	}
 		/* postfix sign */
-	if (*s && (p = strchr(sym, *s))) {
+	char temp[sizeof(sym)+1];
+	strcpy(temp,sym);
+	if (*s && (p = 
+		   strchr(temp, *s)
+		   )) {
 		sign = (p - sym) >= 4 ? '-' : '+';
 		++s;
 	}
Index: src/projects.h
===================================================================
--- src/projects.h	(revision 2650)
+++ src/projects.h	(working copy)
@@ -136,7 +136,17 @@
 
 #define USE_PROJUV 
 
-typedef struct { double u, v; } projUV;
+  typedef 
+  struct TprojUV
+  {     
+  TprojUV() :
+    u(0.0),v(0.0) {}
+
+  TprojUV(double u, double v) :
+    u(u),v(v) {}
+    double u, v; 
+
+} projUV;
 typedef struct { double r, i; }	COMPLEX;
 
 #ifndef PJ_LIB__
Index: src/pj_open_lib.c
===================================================================
--- src/pj_open_lib.c	(revision 2650)
+++ src/pj_open_lib.c	(working copy)
@@ -83,10 +83,14 @@
 
     if( count > 0 )
     {
-        search_path = pj_malloc(sizeof *search_path * count);
+      search_path = (char **)pj_malloc(
+				sizeof (
+					search_path)
+				* count
+				);
         for (i = 0; i < count; i++)
         {
-            search_path[i] = pj_malloc(strlen(path[i]) + 1);
+	  search_path[i] = (char *)pj_malloc(strlen(path[i]) + 1);
             strcpy(search_path[i], path[i]);
         }
     }
Index: src/nad2nad.c
===================================================================
--- src/nad2nad.c	(revision 2650)
+++ src/nad2nad.c	(working copy)
@@ -72,7 +72,7 @@
 			io->nprojc = 2; /* no other options allowed */
 			io->projc[0] = "proj=utm";
 			sprintf(tmp, "zone=%d", io->zone);
-			io->projc[1] = io->t83 ? "ellps=GRS80" : "ellps=clrk66";
+			strcpy(io->projc[1], io->t83 ? "ellps=GRS80" : "ellps=clrk66");
 		} else /* SPCS zone */
 			sprintf(tmp, "init=nad%s:%d", io->t83 ? "83" : "27", io->zone);
 		io->projc[io->nprojc++] = tmp;
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision 2650)
+++ src/Makefile.am	(working copy)
@@ -1,7 +1,10 @@
+CC= g++
+
 bin_PROGRAMS =	proj nad2nad nad2bin geod cs2cs
 
 INCLUDES =	-DPROJ_LIB=\"$(pkgdatadir)\" \
-		-DMUTEX_ at MUTEX_SETTING@ @JNI_INCLUDE@
+		-DMUTEX_ at MUTEX_SETTING@ 
+#@JNI_INCLUDE@
 
 include_HEADERS = projects.h nad_list.h proj_api.h org_proj4_Projections.h
 
@@ -60,9 +63,11 @@
 	nad_cvt.c nad_init.c nad_intr.c emess.c emess.h \
 	pj_apply_gridshift.c pj_datums.c pj_datum_set.c pj_transform.c \
 	geocent.c geocent.h pj_utils.c pj_gridinfo.c pj_gridlist.c \
-	jniproj.c pj_mutex.c pj_initcache.c
+	pj_mutex.c pj_initcache.c
 
+#jniproj.c 
 
+
 install-exec-local:
 	rm -f $(DESTDIR)$(bindir)/invproj$(EXEEXT)
 	(cd $(DESTDIR)$(bindir); ln -s proj$(EXEEXT) invproj$(EXEEXT))
Index: src/bch2bps.c
===================================================================
--- src/bch2bps.c	(revision 2650)
+++ src/bch2bps.c	(working copy)
@@ -2,7 +2,11 @@
 #include <projects.h>
 /* basic support procedures */
 	static void /* clear vector to zero */
-clear(projUV *p, int n) { static const projUV c = {0., 0.}; while (n--) *p++ = c; }
+clear(projUV *p, int n) { 
+	  static const projUV c (0., 0.); 
+	  while (n--) 
+	    *p++ = c; 
+	}
 	static void /* clear matrix rows to zero */
 bclear(projUV **p, int n, int m) { while (n--) clear(*p++, m); }
 	static void /* move vector */
Index: Makefile.am
===================================================================
--- Makefile.am	(revision 2650)
+++ Makefile.am	(working copy)
@@ -1,4 +1,5 @@
-SUBDIRS	=	src man nad jniwrap
+SUBDIRS	=	src man nad 
+#jniwrap
 
 EXTRA_DIST = makefile.vc nmake.opt
 


More information about the Proj mailing list