Index: trunk/zoo-project/zoo-kernel/service_internal_ms.c
===================================================================
--- trunk/zoo-project/zoo-kernel/service_internal_ms.c	(revision 434)
+++ trunk/zoo-project/zoo-kernel/service_internal_ms.c	(revision 451)
@@ -211,62 +211,62 @@
   map* msSrs=NULL;
   hSRS = OSRNewSpatialReference(NULL);
-  if( pszProjection!=NULL && strlen(pszProjection)>1 &&
-      OSRImportFromWkt( hSRS, &pszProjection ) == CE_None ){
-    char *proj4Str=NULL;
-    if(OSRGetAuthorityName(hSRS,NULL)!=NULL && 
-       OSRGetAuthorityCode(hSRS,NULL)!=NULL){
-      char tmpSrs[20];
-      sprintf(tmpSrs,"%s:%s",
-	      OSRGetAuthorityName(hSRS,NULL),OSRGetAuthorityCode(hSRS,NULL));
-      msLoadProjectionStringEPSG(&m->projection,tmpSrs);
-      msLoadProjectionStringEPSG(&myLayer->projection,tmpSrs);
-      
-      char tmpSrss[256];
-      sprintf(tmpSrss,"EPSG:4326 EPSG:900913 %s",tmpSrs);
-
-      msInsertHashTable(&(m->web.metadata), "ows_srs", tmpSrss);
-      msInsertHashTable(&(myLayer->metadata), "ows_srs", tmpSrss);
-
-#ifdef DEBUGMS
-      fprintf(stderr,"isGeo %b\n\n",OSRIsGeographic(hSRS)==TRUE);
-#endif
-      if(output!=NULL){
-	if(OSRIsGeographic(hSRS)==TRUE)
-	  addToMap(output->content,"crs_isGeographic","true");
-	else
-	  addToMap(output->content,"crs_isGeographic","false");
-	addToMap(output->content,"crs",tmpSrs);
-      }
-    }
-    else{
-      OSRExportToProj4(hSRS,&proj4Str);
-      if(proj4Str!=NULL){
-#ifdef DEBUGMS
-	fprintf(stderr,"PROJ (%s)\n",proj4Str);
-#endif
-	msLoadProjectionString(&(m->projection),proj4Str);
-	msLoadProjectionString(&(myLayer->projection),proj4Str);
-	if(output!=NULL){ 
+  if( pszProjection!=NULL && strlen(pszProjection)>1){
+    if(OSRImportFromWkt( hSRS, &pszProjection ) == CE_None ){
+      char *proj4Str=NULL;
+      if(OSRGetAuthorityName(hSRS,NULL)!=NULL && 
+	 OSRGetAuthorityCode(hSRS,NULL)!=NULL){
+	char tmpSrs[20];
+	sprintf(tmpSrs,"%s:%s",
+		OSRGetAuthorityName(hSRS,NULL),OSRGetAuthorityCode(hSRS,NULL));
+	msLoadProjectionStringEPSG(&m->projection,tmpSrs);
+	msLoadProjectionStringEPSG(&myLayer->projection,tmpSrs);
+	
+	char tmpSrss[256];
+	sprintf(tmpSrss,"EPSG:4326 EPSG:900913 %s",tmpSrs);
+	
+	msInsertHashTable(&(m->web.metadata), "ows_srs", tmpSrss);
+	msInsertHashTable(&(myLayer->metadata), "ows_srs", tmpSrss);
+	
+#ifdef DEBUGMS
+	fprintf(stderr,"isGeo %b\n\n",OSRIsGeographic(hSRS)==TRUE);
+#endif
+	if(output!=NULL){
 	  if(OSRIsGeographic(hSRS)==TRUE)
 	    addToMap(output->content,"crs_isGeographic","true");
 	  else
 	    addToMap(output->content,"crs_isGeographic","false");
+	  addToMap(output->content,"crs",tmpSrs);
 	}
       }
       else{
-	msLoadProjectionStringEPSG(&m->projection,"EPSG:4326");
-	msLoadProjectionStringEPSG(&myLayer->projection,"EPSG:4326");
+	OSRExportToProj4(hSRS,&proj4Str);
+	fprintf(stderr,"Debug WKT: %s \n",proj4Str);
+	if(proj4Str!=NULL){
+#ifdef DEBUGMS
+	  fprintf(stderr,"PROJ (%s)\n",proj4Str);
+#endif
+	  msLoadProjectionString(&(m->projection),proj4Str);
+	  msLoadProjectionString(&(myLayer->projection),proj4Str);
+	  if(output!=NULL){ 
+	    if(OSRIsGeographic(hSRS)==TRUE)
+	      addToMap(output->content,"crs_isGeographic","true");
+	    else
+	      addToMap(output->content,"crs_isGeographic","false");
+	  }
+	}
+	else{
+	  msLoadProjectionStringEPSG(&m->projection,"EPSG:4326");
+	  msLoadProjectionStringEPSG(&myLayer->projection,"EPSG:4326");
+	  if(output!=NULL){
+	    addToMap(output->content,"crs_isGeographic","true");
+	  }
+	}
 	if(output!=NULL){
-	  addToMap(output->content,"crs_isGeographic","true");
+	  addToMap(output->content,"crs","EPSG:4326");
+	  addToMap(output->content,"real_extent","true");
 	}
+	msInsertHashTable(&(m->web.metadata),"ows_srs", "EPSG:4326 EPSG:900913");
+	msInsertHashTable(&(myLayer->metadata),"ows_srs","EPSG:4326 EPSG:900913");
       }
-      if(output!=NULL){
-	addToMap(output->content,"crs","EPSG:4326");
-        addToMap(output->content,"real_extent","true");
-      }
-      msInsertHashTable(&(m->web.metadata),"ows_srs", "EPSG:4326 EPSG:900913");
-      msInsertHashTable(&(myLayer->metadata),"ows_srs","EPSG:4326 EPSG:900913");
-
-
     }
   }
@@ -684,5 +684,5 @@
   }
 #ifdef DEBUGMS
-    fprintf(stderr,"Accessing the DataSource %s %d\n",pszFilename,__LINE__);
+  fprintf(stderr,"Accessing the DataSource %s %d\n",pszFilename,__LINE__);
 #endif
 
@@ -696,4 +696,5 @@
     return -1;
   }
+  m->layers[m->numlayers]->index=m->numlayers;
 
   layerObj* myLayer=m->layers[m->numlayers];
@@ -714,4 +715,5 @@
   if(tmpMap!=NULL)
     abstract=tmpMap->value;
+
   msInsertHashTable(&(myLayer->metadata), "ows_label", title);
   msInsertHashTable(&(myLayer->metadata), "ows_title", title);
