1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439
|
/* ===========================================================================
$Id: map.i 7249 2008-01-07 15:43:27Z tamas $
Project: MapServer
Purpose: SWIG interface file for mapscript mapObj extensions
Author: Steve Lime
Sean Gillies, sgillies@frii.com
===========================================================================
Copyright (c) 1996-2001 Regents of the University of Minnesota.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
===========================================================================
*/
%extend mapObj
{
mapObj(char *filename="")
{
if (filename && strlen(filename))
return msLoadMap(filename, NULL);
else { /* create an empty map, no layers etc... */
return msNewMapObj();
}
}
~mapObj()
{
msFreeMap(self);
}
#ifdef SWIGJAVA
%newobject cloneMap;
mapObj *cloneMap()
#else
%newobject clone;
mapObj *clone()
#endif
{
mapObj *dstMap;
dstMap = msNewMapObj();
if (msCopyMap(dstMap, self) != MS_SUCCESS) {
msFreeMap(dstMap);
dstMap = NULL;
}
return dstMap;
}
int insertLayer(layerObj *layer, int index=-1)
{
return msInsertLayer(self, layer, index);
}
%newobject removeLayer;
layerObj *removeLayer(int index)
{
layerObj *layer=msRemoveLayer(self, index);
MS_REFCNT_INCR(layer);
return layer;
}
int setExtent(double minx, double miny, double maxx, double maxy) {
return msMapSetExtent( self, minx, miny, maxx, maxy );
}
/* recent rotation work makes setSize the only reliable
method for changing the image size. direct access is deprecated. */
int setSize(int width, int height)
{
return msMapSetSize(self, width, height);
}
int setRotation( double rotation_angle )
{
return msMapSetRotation( self, rotation_angle );
}
%newobject getLayer;
layerObj *getLayer(int i) {
if(i >= 0 && i < self->numlayers) {
MS_REFCNT_INCR(self->layers[i]);
return (self->layers[i]); /* returns an EXISTING layer */
} else {
return NULL;
}
}
%newobject getLayerByName;
layerObj *getLayerByName(char *name) {
int i;
i = msGetLayerIndex(self, name);
if(i != -1) {
MS_REFCNT_INCR(self->layers[i]);
return (self->layers[i]); /* returns an EXISTING layer */
}
else
return NULL;
}
int getSymbolByName(char *name) {
return msGetSymbolIndex(&self->symbolset, name, MS_TRUE);
}
void prepareQuery() {
int status;
status = msCalculateScale(self->extent, self->units, self->width, self->height, self->resolution, &self->scaledenom);
if(status != MS_SUCCESS) self->scaledenom = -1;
}
%newobject prepareImage;
imageObj *prepareImage()
{
return msPrepareImage(self, MS_FALSE);
}
void setImageType( char * imagetype ) {
outputFormatObj *format;
format = msSelectOutputFormat( self, imagetype );
if( format == NULL )
msSetError(MS_MISCERR, "Unable to find IMAGETYPE '%s'.",
"setImageType()", imagetype );
else
{
msFree( self->imagetype );
self->imagetype = strdup(imagetype);
msApplyOutputFormat( &(self->outputformat), format, MS_NOOVERRIDE,
MS_NOOVERRIDE, MS_NOOVERRIDE );
}
}
void selectOutputFormat( char *imagetype )
{
outputFormatObj *format;
format = msSelectOutputFormat( self, imagetype );
if ( format == NULL )
msSetError(MS_MISCERR, "Unable to find IMAGETYPE '%s'.",
"setImageType()", imagetype );
else
{
msFree( self->imagetype );
self->imagetype = strdup(imagetype);
msApplyOutputFormat( &(self->outputformat), format, MS_NOOVERRIDE,
MS_NOOVERRIDE, MS_NOOVERRIDE );
}
}
void setOutputFormat( outputFormatObj *format ) {
msApplyOutputFormat( &(self->outputformat), format, MS_NOOVERRIDE,
MS_NOOVERRIDE, MS_NOOVERRIDE );
}
%newobject draw;
imageObj *draw() {
return msDrawMap(self, MS_FALSE);
}
%newobject drawQuery;
imageObj *drawQuery() {
return msDrawMap(self, MS_TRUE);
}
%newobject drawLegend;
imageObj *drawLegend() {
return msDrawLegend(self, MS_FALSE);
}
%newobject drawScalebar;
imageObj *drawScalebar() {
return msDrawScalebar(self);
}
%newobject drawReferenceMap;
imageObj *drawReferenceMap() {
return msDrawReferenceMap(self);
}
int embedScalebar(imageObj *image) {
return msEmbedScalebar(self, image->img.gd);
}
int embedLegend(imageObj *image) {
return msEmbedLegend(self, image->img.gd);
}
int drawLabelCache(imageObj *image) {
return msDrawLabelCache(image, self);
}
labelCacheMemberObj *getLabel(int i) {
return msGetLabelCacheMember(&(self->labelcache), i);
}
labelCacheMemberObj *nextLabel() {
static int i=0;
if(i<self->labelcache.numlabels)
return msGetLabelCacheMember(&(self->labelcache), i++);
else
return NULL;
}
int queryByPoint(pointObj *point, int mode, double buffer) {
return msQueryByPoint(self, -1, mode, *point, buffer);
}
int queryByRect(rectObj rect) {
return msQueryByRect(self, -1, rect);
}
int queryByFeatures(int slayer) {
return msQueryByFeatures(self, -1, slayer);
}
int queryByShape(shapeObj *shape) {
return msQueryByShape(self, -1, shape);
}
int setWKTProjection(char *wkt) {
return msOGCWKT2ProjectionObj(wkt, &(self->projection), self->debug);
}
%newobject getProjection;
char *getProjection() {
return msGetProjectionString(&(self->projection));
}
int setProjection(char *proj4) {
return msLoadProjectionString(&(self->projection), proj4);
}
int save(char *filename) {
return msSaveMap(self, filename);
}
int saveQuery(char *filename) {
return msSaveQuery(self, filename);
}
int loadQuery(char *filename)
{
return msLoadQuery(self, filename);
}
void freeQuery(int qlayer=-1)
{
msQueryFree(self, qlayer);
}
int saveQueryAsGML(char *filename, const char *ns="GOMF") {
return msGMLWriteQuery(self, filename, ns);
}
char *getMetaData(char *name) {
char *value = NULL;
if (!name) {
msSetError(MS_HASHERR, "NULL key", "getMetaData");
}
value = (char *) msLookupHashTable(&(self->web.metadata), name);
if (!value) {
msSetError(MS_HASHERR, "Key %s does not exist", "getMetaData", name);
return NULL;
}
return value;
}
int setMetaData(char *name, char *value) {
if (msInsertHashTable(&(self->web.metadata), name, value) == NULL)
return MS_FAILURE;
return MS_SUCCESS;
}
int removeMetaData(char *name) {
return(msRemoveHashTable(&(self->web.metadata), name));
}
char *getFirstMetaDataKey() {
return (char *) msFirstKeyFromHashTable(&(self->web.metadata));
}
char *getNextMetaDataKey(char *lastkey) {
return (char *) msNextKeyFromHashTable(&(self->web.metadata), lastkey);
}
int setSymbolSet(char *szFileName) {
msFreeSymbolSet(&self->symbolset);
msInitSymbolSet(&self->symbolset);
self->symbolset.filename = strdup(szFileName);
/* Symbolset shares same fontset as main mapfile */
self->symbolset.fontset = &(self->fontset);
return msLoadSymbolSet(&self->symbolset, self);
}
int getNumSymbols() {
return self->symbolset.numsymbols;
}
int setFontSet(char *filename) {
msFreeFontSet(&(self->fontset));
msInitFontSet(&(self->fontset));
self->fontset.filename = strdup(filename);
return msLoadFontSet(&(self->fontset), self);
}
/* I removed a method to get the fonset filename. Instead I updated mapserver.h
to allow SWIG access to the fonset, although the numfonts and filename
members are read-only. Use the setFontSet method to actually change the
fontset. To get the filename do $map->{fontset}->{filename}; -- SG */
int saveMapContext(char *szFileName) {
return msSaveMapContext(self, szFileName);
}
int loadMapContext(char *szFileName, int useUniqueNames=MS_FALSE) {
return msLoadMapContext(self, szFileName, useUniqueNames);
}
int moveLayerUp(int layerindex) {
return msMoveLayerUp(self, layerindex);
}
int moveLayerDown(int layerindex) {
return msMoveLayerDown(self, layerindex);
}
%newobject getLayersDrawingOrder;
intarray *getLayersDrawingOrder() {
int i;
intarray *order;
order = new_intarray(self->numlayers);
for (i=0; i<self->numlayers; i++)
#if (defined(SWIGPYTHON) || defined(SWIGRUBY) ) && SWIG_VERSION >= 0x010328 /* 1.3.28 */
intarray___setitem__(order, i, self->layerorder[i]);
#else
intarray_setitem(order, i, self->layerorder[i]);
#endif
return order;
}
int setLayersDrawingOrder(int *panIndexes) {
return msSetLayersdrawingOrder(self, panIndexes);
}
void setConfigOption(char *key, char *value) {
msSetConfigOption(self,key,value);
}
char *getConfigOption(char *key) {
return (char *) msGetConfigOption(self,key);
}
void applyConfigOptions() {
msApplyMapConfigOptions( self );
}
/* SLD */
int applySLD(char *sld) {
return msSLDApplySLD(self, sld, -1, NULL);
}
int applySLDURL(char *sld) {
return msSLDApplySLDURL(self, sld, -1, NULL);
}
%newobject generateSLD;
char *generateSLD() {
return (char *) msSLDGenerateSLD(self, -1);
}
%newobject processTemplate;
char *processTemplate(int bGenerateImages, char **names, char **values,
int numentries)
{
return msProcessTemplate(self, bGenerateImages, names, values,
numentries);
}
%newobject processLegendTemplate;
char *processLegendTemplate(char **names, char **values, int numentries) {
return msProcessLegendTemplate(self, names, values, numentries);
}
%newobject processQueryTemplate;
char *processQueryTemplate(char **names, char **values, int numentries) {
return msProcessQueryTemplate(self, 1, names, values, numentries);
}
outputFormatObj *getOutputFormatByName(char *name) {
return msSelectOutputFormat(self, name);
}
int appendOutputFormat(outputFormatObj *format) {
return msAppendOutputFormat(self, format);
}
int removeOutputFormat(char *name) {
return msRemoveOutputFormat(self, name);
}
int loadOWSParameters(cgiRequestObj *request, char *wmtver_string="1.1.1")
{
return msMapLoadOWSParameters(self, request, wmtver_string);
}
int OWSDispatch( cgiRequestObj *req )
{
return msOWSDispatch( self, req );
}
}
|