| 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 |
#include "mapserver.h" |
|---|
| 32 |
|
|---|
| 33 |
#ifdef USE_GDAL |
|---|
| 34 |
# include "gdal.h" |
|---|
| 35 |
# include "cpl_conv.h" |
|---|
| 36 |
#endif |
|---|
| 37 |
|
|---|
| 38 |
MS_CVSID("$Id$") |
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
int msMoveStyleUp(classObj *class, int nStyleIndex) |
|---|
| 44 |
{ |
|---|
| 45 |
styleObj *psTmpStyle = NULL; |
|---|
| 46 |
if (class && nStyleIndex < class->numstyles && nStyleIndex >0) |
|---|
| 47 |
{ |
|---|
| 48 |
psTmpStyle = (styleObj *)malloc(sizeof(styleObj)); |
|---|
| 49 |
initStyle(psTmpStyle); |
|---|
| 50 |
|
|---|
| 51 |
msCopyStyle(psTmpStyle, class->styles[nStyleIndex]); |
|---|
| 52 |
|
|---|
| 53 |
msCopyStyle(class->styles[nStyleIndex], |
|---|
| 54 |
class->styles[nStyleIndex-1]); |
|---|
| 55 |
|
|---|
| 56 |
msCopyStyle(class->styles[nStyleIndex-1], psTmpStyle); |
|---|
| 57 |
|
|---|
| 58 |
return(MS_SUCCESS); |
|---|
| 59 |
} |
|---|
| 60 |
msSetError(MS_CHILDERR, "Invalid index: %d", "msMoveStyleUp()", |
|---|
| 61 |
nStyleIndex); |
|---|
| 62 |
return (MS_FAILURE); |
|---|
| 63 |
} |
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
|
|---|
| 69 |
int msMoveStyleDown(classObj *class, int nStyleIndex) |
|---|
| 70 |
{ |
|---|
| 71 |
styleObj *psTmpStyle = NULL; |
|---|
| 72 |
|
|---|
| 73 |
if (class && nStyleIndex < class->numstyles-1 && nStyleIndex >=0) |
|---|
| 74 |
{ |
|---|
| 75 |
psTmpStyle = (styleObj *)malloc(sizeof(styleObj)); |
|---|
| 76 |
initStyle(psTmpStyle); |
|---|
| 77 |
|
|---|
| 78 |
msCopyStyle(psTmpStyle, class->styles[nStyleIndex]); |
|---|
| 79 |
|
|---|
| 80 |
msCopyStyle(class->styles[nStyleIndex], |
|---|
| 81 |
class->styles[nStyleIndex+1]); |
|---|
| 82 |
|
|---|
| 83 |
msCopyStyle(class->styles[nStyleIndex+1], psTmpStyle); |
|---|
| 84 |
|
|---|
| 85 |
return(MS_SUCCESS); |
|---|
| 86 |
} |
|---|
| 87 |
msSetError(MS_CHILDERR, "Invalid index: %d", "msMoveStyleDown()", |
|---|
| 88 |
nStyleIndex); |
|---|
| 89 |
return (MS_FAILURE); |
|---|
| 90 |
} |
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
int msInsertStyle(classObj *class, styleObj *style, int nStyleIndex) { |
|---|
| 98 |
int i; |
|---|
| 99 |
|
|---|
| 100 |
if (!style) |
|---|
| 101 |
{ |
|---|
| 102 |
msSetError(MS_CHILDERR, "Can't insert a NULL Style", "msInsertStyle()"); |
|---|
| 103 |
return -1; |
|---|
| 104 |
} |
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
if (msGrowClassStyles(class) == NULL) { |
|---|
| 108 |
return -1; |
|---|
| 109 |
} |
|---|
| 110 |
|
|---|
| 111 |
else if (nStyleIndex >= class->numstyles) { |
|---|
| 112 |
msSetError(MS_CHILDERR, "Cannot insert style beyond index %d", "insertStyle()", class->numstyles-1); |
|---|
| 113 |
return -1; |
|---|
| 114 |
} |
|---|
| 115 |
else if (nStyleIndex < 0) { |
|---|
| 116 |
class->styles[class->numstyles]=style; |
|---|
| 117 |
MS_REFCNT_INCR(style); |
|---|
| 118 |
class->numstyles++; |
|---|
| 119 |
return class->numstyles-1; |
|---|
| 120 |
} |
|---|
| 121 |
else if (nStyleIndex >= 0 && nStyleIndex < class->numstyles) { |
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 |
for (i=class->numstyles-1; i>=nStyleIndex; i--) { |
|---|
| 125 |
class->styles[i+1] = class->styles[i]; |
|---|
| 126 |
} |
|---|
| 127 |
class->styles[nStyleIndex]=style; |
|---|
| 128 |
MS_REFCNT_INCR(style); |
|---|
| 129 |
class->numstyles++; |
|---|
| 130 |
return nStyleIndex; |
|---|
| 131 |
} |
|---|
| 132 |
else { |
|---|
| 133 |
msSetError(MS_CHILDERR, "Invalid nStyleIndex", "insertStyle()"); |
|---|
| 134 |
return -1; |
|---|
| 135 |
} |
|---|
| 136 |
} |
|---|
| 137 |
|
|---|
| 138 |
styleObj *msRemoveStyle(classObj *class, int nStyleIndex) { |
|---|
| 139 |
int i; |
|---|
| 140 |
styleObj *style; |
|---|
| 141 |
if (class->numstyles == 1) { |
|---|
| 142 |
msSetError(MS_CHILDERR, "Cannot remove a class's sole style", "removeStyle()"); |
|---|
| 143 |
return NULL; |
|---|
| 144 |
} |
|---|
| 145 |
else if (nStyleIndex < 0 || nStyleIndex >= class->numstyles) { |
|---|
| 146 |
msSetError(MS_CHILDERR, "Cannot remove style, invalid nStyleIndex %d", "removeStyle()", nStyleIndex); |
|---|
| 147 |
return NULL; |
|---|
| 148 |
} |
|---|
| 149 |
else { |
|---|
| 150 |
style=class->styles[nStyleIndex]; |
|---|
| 151 |
for (i=nStyleIndex; i<class->numstyles-1; i++) { |
|---|
| 152 |
class->styles[i]=class->styles[i+1]; |
|---|
| 153 |
} |
|---|
| 154 |
class->styles[class->numstyles-1]=NULL; |
|---|
| 155 |
class->numstyles--; |
|---|
| 156 |
MS_REFCNT_DECR(style); |
|---|
| 157 |
return style; |
|---|
| 158 |
} |
|---|
| 159 |
} |
|---|
| 160 |
|
|---|
| 161 |
|
|---|
| 162 |
|
|---|
| 163 |
|
|---|
| 164 |
|
|---|
| 165 |
int msDeleteStyle(classObj *class, int nStyleIndex) |
|---|
| 166 |
{ |
|---|
| 167 |
int i = 0; |
|---|
| 168 |
if (class && nStyleIndex < class->numstyles && nStyleIndex >=0) |
|---|
| 169 |
{ |
|---|
| 170 |
if (freeStyle(class->styles[nStyleIndex]) == MS_SUCCESS) |
|---|
| 171 |
msFree(class->styles[nStyleIndex]); |
|---|
| 172 |
for (i=nStyleIndex; i< class->numstyles-1; i++) |
|---|
| 173 |
{ |
|---|
| 174 |
class->styles[i] = class->styles[i+1]; |
|---|
| 175 |
} |
|---|
| 176 |
class->styles[class->numstyles-1] = NULL; |
|---|
| 177 |
class->numstyles--; |
|---|
| 178 |
return(MS_SUCCESS); |
|---|
| 179 |
} |
|---|
| 180 |
msSetError(MS_CHILDERR, "Invalid index: %d", "msDeleteStyle()", |
|---|
| 181 |
nStyleIndex); |
|---|
| 182 |
return (MS_FAILURE); |
|---|
| 183 |
} |
|---|