Changeset 9261
- Timestamp:
- 08/10/11 15:54:48 (14 years ago)
- Location:
- issm/trunk/src/c/objects/KML
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/objects/KML/KML_Container.cpp
r9215 r9261 157 157 /*}}}*/ 158 158 159 /*FUNCTION KML_Container:: FindPolygons{{{1*/160 void KML_Container:: FindPolygons(DataSet* polygons){159 /*FUNCTION KML_Container::WriteExp {{{1*/ 160 void KML_Container::WriteExp(FILE* fid,char* nstr,int sgn,double cm,double sp){ 161 161 162 162 int i; … … 165 165 166 166 for (i=0; i<feature->Size(); i++) 167 ((KML_Object *)feature->GetObjectByOffset(i))-> FindPolygons(polygons);167 ((KML_Object *)feature->GetObjectByOffset(i))->WriteExp(fid,nstr,sgn,cm,sp); 168 168 169 169 return; … … 171 171 /*}}}*/ 172 172 173 /*FUNCTION KML_Container::FindLineStrings {{{1*/174 void KML_Container::FindLineStrings(DataSet* linestrings){175 176 int i;177 178 /* loop over the features for the container */179 180 for (i=0; i<feature->Size(); i++)181 ((KML_Object *)feature->GetObjectByOffset(i))->FindLineStrings(linestrings);182 183 return;184 }185 /*}}}*/186 -
issm/trunk/src/c/objects/KML/KML_Container.h
r9201 r9261 32 32 void Write(FILE* fid,char* indent); 33 33 void Read(FILE* fid,char* kstr); 34 void FindPolygons(DataSet* polygons); 35 void FindLineStrings(DataSet* linestrings); 34 void WriteExp(FILE* fid,char* nstr,int sgn,double cm,double sp); 36 35 int Id(){_error_("Not implemented yet.");}; 37 36 int MyRank(){_error_("Not implemented yet.");}; -
issm/trunk/src/c/objects/KML/KML_File.cpp
r9215 r9261 253 253 /*}}}*/ 254 254 255 /*FUNCTION KML_File:: FindPolygons{{{1*/256 void KML_File:: FindPolygons(DataSet* polygons){255 /*FUNCTION KML_File::WriteExp {{{1*/ 256 void KML_File::WriteExp(FILE* fid,char* nstr,int sgn,double cm,double sp){ 257 257 258 258 int i; … … 261 261 262 262 for (i=0; i<kmlobj->Size(); i++) 263 ((KML_Object *)kmlobj->GetObjectByOffset(i))->FindPolygons(polygons); 264 265 return; 266 } 267 /*}}}*/ 268 269 /*FUNCTION KML_File::FindLineStrings {{{1*/ 270 void KML_File::FindLineStrings(DataSet* linestrings){ 271 272 int i; 273 274 /* loop over the kml objects for the file */ 275 276 for (i=0; i<kmlobj->Size(); i++) 277 ((KML_Object *)kmlobj->GetObjectByOffset(i))->FindLineStrings(linestrings); 278 279 return; 280 } 281 /*}}}*/ 282 263 ((KML_Object *)kmlobj->GetObjectByOffset(i))->WriteExp(fid,nstr,sgn,cm,sp); 264 265 return; 266 } 267 /*}}}*/ 268 -
issm/trunk/src/c/objects/KML/KML_File.h
r9215 r9261 32 32 void Write(FILE* fid,char* indent); 33 33 void Read(FILE* fid,char* kstr); 34 void FindPolygons(DataSet* polygons); 35 void FindLineStrings(DataSet* linestrings); 34 void WriteExp(FILE* fid,char* nstr,int sgn,double cm,double sp); 36 35 int Id(){_error_("Not implemented yet.");}; 37 36 int MyRank(){_error_("Not implemented yet.");}; -
issm/trunk/src/c/objects/KML/KML_LineString.cpp
r9201 r9261 17 17 #include "../../Container/Container.h" 18 18 #include "../../include/include.h" 19 #include "../../modules/Ll2xyx/Ll2xyx.h" 19 20 /*}}}*/ 20 21 … … 170 171 /*}}}*/ 171 172 172 /*FUNCTION KML_LineString::FindLineStrings {{{1*/ 173 void KML_LineString::FindLineStrings(DataSet* linestrings){ 174 175 linestrings->AddObject((Object*)this); 176 177 return; 178 } 179 /*}}}*/ 180 173 /*FUNCTION KML_LineString::WriteExp {{{1*/ 174 void KML_LineString::WriteExp(FILE* fid,char* nstr,int sgn,double cm,double sp){ 175 176 int i; 177 double *lat,*lon,*x,*y; 178 char nstr2[81]; 179 180 /* extract latitude and longitude into vectors */ 181 182 lat=(double *) xmalloc(ncoord*sizeof(double)); 183 lon=(double *) xmalloc(ncoord*sizeof(double)); 184 for (i=0; i<ncoord; i++) { 185 lon[i]=coords[i][0]; 186 lat[i]=coords[i][1]; 187 } 188 189 /* convert latitude and longitude to x and y */ 190 191 x =(double *) xmalloc(ncoord*sizeof(double)); 192 y =(double *) xmalloc(ncoord*sizeof(double)); 193 Ll2xyx(x,y,lat,lon,ncoord,sgn,cm,sp); 194 195 /* write header */ 196 197 strcpy(nstr2,nstr); 198 for (i=0; i<strlen(nstr2); i++) 199 if ((nstr2[i] == ' ') || (nstr2[i] == '\t')) 200 nstr2[i]='_'; 201 fprintf(fid,"## Name:%s\n",nstr2); 202 fprintf(fid,"## Icon:0\n"); 203 fprintf(fid,"# Points Count Value\n"); 204 fprintf(fid,"%u %s\n",ncoord ,"1."); 205 fprintf(fid,"# X pos Y pos\n"); 206 207 /* write vertices */ 208 209 for (i=0; i<ncoord; i++) 210 fprintf(fid,"%lf\t%lf\n",x[i],y[i]); 211 212 /* write blank line */ 213 214 fprintf(fid,"\n"); 215 216 xfree((void**)&y); 217 xfree((void**)&x); 218 xfree((void**)&lon); 219 xfree((void**)&lat); 220 221 return; 222 } 223 /*}}}*/ 224 -
issm/trunk/src/c/objects/KML/KML_LineString.h
r9201 r9261 37 37 void Write(FILE* fid,char* indent); 38 38 void Read(FILE* fid,char* kstr); 39 void FindLineStrings(DataSet* linestrings);39 void WriteExp(FILE* fid,char* nstr,int sgn,double cm,double sp); 40 40 int Id(){_error_("Not implemented yet.");}; 41 41 int MyRank(){_error_("Not implemented yet.");}; -
issm/trunk/src/c/objects/KML/KML_LinearRing.cpp
r8461 r9261 17 17 #include "../../Container/Container.h" 18 18 #include "../../include/include.h" 19 #include "../../modules/Ll2xyx/Ll2xyx.h" 19 20 /*}}}*/ 20 21 … … 170 171 /*}}}*/ 171 172 173 /*FUNCTION KML_LinearRing::WriteExp {{{1*/ 174 void KML_LinearRing::WriteExp(FILE* fid,char* nstr,int sgn,double cm,double sp){ 175 176 int i; 177 double *lat,*lon,*x,*y; 178 char nstr2[81]; 179 180 /* extract latitude and longitude into vectors */ 181 182 lat=(double *) xmalloc(ncoord*sizeof(double)); 183 lon=(double *) xmalloc(ncoord*sizeof(double)); 184 for (i=0; i<ncoord; i++) { 185 lon[i]=coords[i][0]; 186 lat[i]=coords[i][1]; 187 } 188 189 /* convert latitude and longitude to x and y */ 190 191 x =(double *) xmalloc(ncoord*sizeof(double)); 192 y =(double *) xmalloc(ncoord*sizeof(double)); 193 Ll2xyx(x,y,lat,lon,ncoord,sgn,cm,sp); 194 195 /* write header */ 196 197 strcpy(nstr2,nstr); 198 for (i=0; i<strlen(nstr2); i++) 199 if ((nstr2[i] == ' ') || (nstr2[i] == '\t')) 200 nstr2[i]='_'; 201 fprintf(fid,"## Name:%s\n",nstr2); 202 fprintf(fid,"## Icon:0\n"); 203 fprintf(fid,"# Points Count Value\n"); 204 if ((lat[ncoord-1] != lat[0]) || (lon[ncoord-1] != lon[0])) 205 fprintf(fid,"%u %s\n",ncoord+1,"1."); 206 else 207 fprintf(fid,"%u %s\n",ncoord ,"1."); 208 fprintf(fid,"# X pos Y pos\n"); 209 210 /* write vertices, making sure ring is closed */ 211 212 for (i=0; i<ncoord; i++) 213 fprintf(fid,"%lf\t%lf\n",x[i],y[i]); 214 if ((lat[ncoord-1] != lat[0]) || (lon[ncoord-1] != lon[0])) 215 fprintf(fid,"%lf\t%lf\n",x[0],y[0]); 216 217 /* write blank line */ 218 219 fprintf(fid,"\n"); 220 221 xfree((void**)&y); 222 xfree((void**)&x); 223 xfree((void**)&lon); 224 xfree((void**)&lat); 225 226 return; 227 } 228 /*}}}*/ 229 -
issm/trunk/src/c/objects/KML/KML_LinearRing.h
r8293 r9261 37 37 void Write(FILE* fid,char* indent); 38 38 void Read(FILE* fid,char* kstr); 39 void WriteExp(FILE* fid,char* nstr,int sgn,double cm,double sp); 39 40 int Id(){_error_("Not implemented yet.");}; 40 41 int MyRank(){_error_("Not implemented yet.");}; -
issm/trunk/src/c/objects/KML/KML_MultiGeometry.cpp
r9215 r9261 181 181 /*}}}*/ 182 182 183 /*FUNCTION KML_MultiGeometry:: FindPolygons{{{1*/184 void KML_MultiGeometry:: FindPolygons(DataSet* polygons){183 /*FUNCTION KML_MultiGeometry::WriteExp {{{1*/ 184 void KML_MultiGeometry::WriteExp(FILE* fid,char* nstr,int sgn,double cm,double sp){ 185 185 186 186 int i; … … 189 189 190 190 for (i=0; i<geometry->Size(); i++) 191 ((KML_Object *)geometry->GetObjectByOffset(i))-> FindPolygons(polygons);191 ((KML_Object *)geometry->GetObjectByOffset(i))->WriteExp(fid,nstr,sgn,cm,sp); 192 192 193 193 return; … … 195 195 /*}}}*/ 196 196 197 /*FUNCTION KML_MultiGeometry::FindLineStrings {{{1*/198 void KML_MultiGeometry::FindLineStrings(DataSet* linestrings){199 200 int i;201 202 /* loop over the geometry elements for the multigeometry */203 204 for (i=0; i<geometry->Size(); i++)205 ((KML_Object *)geometry->GetObjectByOffset(i))->FindLineStrings(linestrings);206 207 return;208 }209 /*}}}*/210 -
issm/trunk/src/c/objects/KML/KML_MultiGeometry.h
r9201 r9261 33 33 void Write(FILE* fid,char* indent); 34 34 void Read(FILE* fid,char* kstr); 35 void FindPolygons(DataSet* polygons); 36 void FindLineStrings(DataSet* linestrings); 35 void WriteExp(FILE* fid,char* nstr,int sgn,double cm,double sp); 37 36 int Id(){_error_("Not implemented yet.");}; 38 37 int MyRank(){_error_("Not implemented yet.");}; -
issm/trunk/src/c/objects/KML/KML_Object.cpp
r9201 r9261 113 113 /*}}}*/ 114 114 115 /*FUNCTION KML_Object::WriteExp {{{1*/ 116 void KML_Object::WriteExp(FILE* fid,char* nstr,int sgn,double cm,double sp){ 117 118 ; 119 120 return; 121 } 122 /*}}}*/ 123 115 124 /*FUNCTION KML_Object::AddAttrib {{{1*/ 116 125 void KML_Object::AddAttrib(char* name,char* value){ … … 171 180 /*}}}*/ 172 181 173 /*FUNCTION KML_Object::FindPolygons {{{1*/174 void KML_Object::FindPolygons(DataSet* polygons){175 176 ;177 178 return;179 }180 /*}}}*/181 182 /*FUNCTION KML_Object::FindLineStrings {{{1*/183 void KML_Object::FindLineStrings(DataSet* linestrings){184 185 ;186 187 return;188 }189 /*}}}*/190 -
issm/trunk/src/c/objects/KML/KML_Object.h
r9201 r9261 41 41 virtual void Write(FILE* fid,char* indent)=0; 42 42 virtual void Read(FILE* fid,char* kstr)=0; 43 virtual void WriteExp(FILE* fid,char* nstr,int sgn,double cm,double sp); 43 44 virtual void AddAttrib(char* name,char* value); 44 45 virtual void FindAttrib(char** pvalue,char* name,char* deflt); 45 46 virtual void WriteAttrib(FILE* fid,char* indent); 46 virtual void FindPolygons(DataSet* polygons);47 virtual void FindLineStrings(DataSet* linestrings);48 47 49 48 }; -
issm/trunk/src/c/objects/KML/KML_Placemark.cpp
r9215 r9261 181 181 /*}}}*/ 182 182 183 /*FUNCTION KML_Placemark:: FindPolygons{{{1*/184 void KML_Placemark:: FindPolygons(DataSet* polygons){183 /*FUNCTION KML_Placemark::WriteExp {{{1*/ 184 void KML_Placemark::WriteExp(FILE* fid,char* nstr,int sgn,double cm,double sp){ 185 185 186 186 int i; 187 char nstr2[81]; 187 188 188 189 /* loop over the geometry elements for the placemark */ 189 190 190 for (i=0; i<geometry->Size(); i++) 191 ((KML_Object *)geometry->GetObjectByOffset(i))->FindPolygons(polygons); 192 193 return; 194 } 195 /*}}}*/ 196 197 /*FUNCTION KML_Placemark::FindLineStrings {{{1*/ 198 void KML_Placemark::FindLineStrings(DataSet* linestrings){ 199 200 int i; 201 202 /* loop over the geometry elements for the placemark */ 203 204 for (i=0; i<geometry->Size(); i++) 205 ((KML_Object *)geometry->GetObjectByOffset(i))->FindLineStrings(linestrings); 206 207 return; 208 } 209 /*}}}*/ 210 191 for (i=0; i<geometry->Size(); i++) { 192 if (strlen(nstr)) 193 sprintf(nstr2,"%s %s",nstr,name); 194 else 195 sprintf(nstr2,"%s",name); 196 197 ((KML_Object *)geometry->GetObjectByOffset(i))->WriteExp(fid,nstr2,sgn,cm,sp); 198 } 199 200 return; 201 } 202 /*}}}*/ 203 -
issm/trunk/src/c/objects/KML/KML_Placemark.h
r9201 r9261 33 33 void Write(FILE* fid,char* indent); 34 34 void Read(FILE* fid,char* kstr); 35 void FindPolygons(DataSet* polygons); 36 void FindLineStrings(DataSet* linestrings); 35 void WriteExp(FILE* fid,char* nstr,int sgn,double cm,double sp); 37 36 int Id(){_error_("Not implemented yet.");}; 38 37 int MyRank(){_error_("Not implemented yet.");}; -
issm/trunk/src/c/objects/KML/KML_Polygon.cpp
r9201 r9261 134 134 strcpy(indent4,indent); 135 135 strcat(indent4," "); 136 137 /* check outer boundary for the polygon */ 136 138 137 139 fprintf(filout,"%s <outerBoundaryIs>\n",indent); … … 254 256 /*}}}*/ 255 257 256 /*FUNCTION KML_Polygon::FindPolygons {{{1*/ 257 void KML_Polygon::FindPolygons(DataSet* polygons){ 258 259 polygons->AddObject((Object*)this); 260 261 return; 262 } 263 /*}}}*/ 264 258 /*FUNCTION KML_Polygon::WriteExp {{{1*/ 259 void KML_Polygon::WriteExp(FILE* fid,char* nstr,int sgn,double cm,double sp){ 260 261 int i; 262 char nstr2[81]; 263 264 /* check outer boundary for the polygon */ 265 266 if (outer->Size()) { 267 if (strlen(nstr)) 268 sprintf(nstr2,"%s (outer)",nstr); 269 else 270 sprintf(nstr2,"(outer)"); 271 272 ((KML_LinearRing *)outer->GetObjectByOffset(0))->WriteExp(fid,nstr2,sgn,cm,sp); 273 } 274 275 /* loop over any inner boundaries for the polygon */ 276 277 for (i=0; i<inner->Size(); i++) { 278 if (strlen(nstr)) 279 sprintf(nstr2,"%s (inner %d of %d)",nstr,i+1,inner->Size()); 280 else 281 sprintf(nstr2,"(inner %d of %d)",i+1,inner->Size()); 282 283 ((KML_LinearRing *)inner->GetObjectByOffset(i))->WriteExp(fid,nstr2,sgn,cm,sp); 284 } 285 286 return; 287 } 288 /*}}}*/ 289 -
issm/trunk/src/c/objects/KML/KML_Polygon.h
r9201 r9261 39 39 void Write(FILE* fid,char* indent); 40 40 void Read(FILE* fid,char* kstr); 41 void FindPolygons(DataSet* polygons);41 void WriteExp(FILE* fid,char* nstr,int sgn,double cm,double sp); 42 42 int Id(){_error_("Not implemented yet.");}; 43 43 int MyRank(){_error_("Not implemented yet.");};
Note:
See TracChangeset
for help on using the changeset viewer.