瀏覽代碼

libproj: support user-defined PROJ pipelines

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@72597 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 7 年之前
父節點
當前提交
c0d0557788
共有 1 個文件被更改,包括 11 次插入7 次删除
  1. 11 7
      lib/proj/do_proj.c

+ 11 - 7
lib/proj/do_proj.c

@@ -68,6 +68,8 @@ static double METERS_in = 1.0, METERS_out = 1.0;
  *         converts from ll to a given SRS, not from a given SRS to ll
  *         thus PROJ 5+ itself uses an inverse transformation in the
  *         first step of the pipeline for proj_create_crs_to_crs()
+ *   if info_trans->def is not NULL, this pipeline definition will be 
+ *   used to create a transformation object 
  * PROJ 4:
  *   info_in->pj must not be null
  *   if info_out->pj is null, create info_out as ll equivalent
@@ -87,13 +89,15 @@ int GPJ_init_transform(const struct pj_info *info_in,
 	G_fatal_error(_("Input coordinate system is NULL"));
 
 #ifdef HAVE_PROJ_H
-    if (info_out->pj != NULL && info_out->def != NULL)
-	G_asprintf(&(info_trans->def), "+proj=pipeline +step +inv %s +step %s",
-		   info_in->def, info_out->def);
-    else
-	/* assume info_out to be ll equivalent of info_in */
-	G_asprintf(&(info_trans->def), "+proj=pipeline +step +inv %s",
-		   info_in->def);
+    if (!info_trans->def) {
+	if (info_out->pj != NULL && info_out->def != NULL)
+	    G_asprintf(&(info_trans->def), "+proj=pipeline +step +inv %s +step %s",
+		       info_in->def, info_out->def);
+	else
+	    /* assume info_out to be ll equivalent of info_in */
+	    G_asprintf(&(info_trans->def), "+proj=pipeline +step +inv %s",
+		       info_in->def);
+    }
 
     info_trans->pj = proj_create(PJ_DEFAULT_CTX, info_trans->def);
     if (info_trans->pj == NULL) {