Kaynağa Gözat

vlib: create ogr with spatial reference

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@44719 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 14 yıl önce
ebeveyn
işleme
93461a1e73
2 değiştirilmiş dosya ile 13 ekleme ve 6 silme
  1. 3 3
      include/Make/Grass.make
  2. 10 3
      lib/vector/Vlib/open_ogr.c

+ 3 - 3
include/Make/Grass.make

@@ -221,7 +221,7 @@ SITESDEPS        = $(VECTORLIB) $(DBMILIB) $(GISLIB) $(DATETIMELIB)
 STATSDEPS        = $(RASTERLIB) $(GISLIB) $(MATHLIB)	# NB: doesn't use libgis directly
 SYMBDEPS         = $(GISLIB) $(MATHLIB)
 TRANSDEPS        = $(MATHLIB)
-VECTORDEPS       = $(DBMILIB) $(GRAPHLIB) $(DIG2LIB) $(LINKMLIB) $(RTREELIB) $(GISLIB) $(GEOSLIBS) $(GDALLIBS) $(MATHLIB) $(BTREE2LIB)
+VECTORDEPS       = $(DBMILIB) $(GRAPHLIB) $(DIG2LIB) $(LINKMLIB) $(RTREELIB) $(GISLIB) $(GEOSLIBS) $(GDALLIBS) $(MATHLIB) $(BTREE2LIB) $(GPROJDEP)
 VEDITDEPS        = $(VECTORLIB) $(DBMILIB) $(GISLIB) $(MATHLIB)
 NETADEPS         = $(VECTORDEP) $(DBMIDEP) $(GISDEP)
 
@@ -278,8 +278,8 @@ endif
 
 DBMILIB     = $(DBMICLIENTLIB) $(DBMIBASELIB) $(DBMIEXTRALIB)
 GEOMLIB     = $(OPTRILIB) $(SOSLIB) $(LIALIB) $(BASICLIB)
-VECTLIB     = $(VECTORLIB) $(DIG2LIB) $(GRAPHLIB) $(RTREELIB) $(LINKMLIB) $(DBMILIB) $(BTREE2LIB)
+VECTLIB     = $(VECTORLIB) $(DIG2LIB) $(GRAPHLIB) $(RTREELIB) $(LINKMLIB) $(DBMILIB) $(BTREE2LIB) $(GPROJLIB)
 
 DBMIDEP     = $(DBMICLIENTDEP) $(DBMIBASEDEP)
 GEOMDEP     = $(OPTRIDEP) $(SOSDEP) $(LIADEP) $(BASICDEP)
-VECTDEP     = $(VECTORDEP) $(DIG2DEP) $(GRAPHDEP) $(RTREEDEP) $(LINKMDEP) $(DBMIDEP)
+VECTDEP     = $(VECTORDEP) $(DIG2DEP) $(GRAPHDEP) $(RTREEDEP) $(LINKMDEP) $(DBMIDEP) $(GPROJDEP)

+ 10 - 3
lib/vector/Vlib/open_ogr.c

@@ -21,8 +21,9 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
-#include <grass/vector.h>
 #include <grass/gis.h>
+#include <grass/vector.h>
+#include <grass/gprojects.h>
 #include <grass/glocale.h>
 
 #ifdef HAVE_OGR
@@ -217,6 +218,10 @@ int V1_open_new_ogr(struct Map_info *Map, const char *name, int with_z)
     OGRLayerH       Ogr_layer;
     OGRFeatureDefnH Ogr_featuredefn;
     
+    OGRSpatialReferenceH Ogr_spatial_ref;
+
+    struct Key_Value *projinfo, *projunits;
+    
     int            i, nlayers;
     char         **Ogr_layer_options;
      
@@ -264,10 +269,12 @@ int V1_open_new_ogr(struct Map_info *Map, const char *name, int with_z)
     }
     
     /* create new OGR layer */
-    /* TODO: spatial reference */
+    projinfo = G_get_projinfo();
+    projunits = G_get_projunits();
+    Ogr_spatial_ref = GPJ_grass_to_osr(projinfo, projunits);
     /* Ogr_layer_options = CSLSetNameValue(Ogr_layer_options, "OVERWRITE", "YES"); */
     Ogr_layer = OGR_DS_CreateLayer(Ogr_ds, Map->fInfo.ogr.layer_name,
-				   NULL, wkbPoint, Ogr_layer_options);
+				   Ogr_spatial_ref, wkbPoint, Ogr_layer_options);
     CSLDestroy(Ogr_layer_options);
     if (!Ogr_layer) {
 	G_warning(_("Unable to create OGR layer <%s> in '%s'"),