| 1 |
/****************************************************************************** |
| 2 |
* |
| 3 |
* Project: |
| 4 |
* Purpose: Generate sample .VCT files |
| 5 |
* Author: Even Rouault, <even dot rouault at spatialys.com> |
| 6 |
* |
| 7 |
****************************************************************************** |
| 8 |
* Copyright (c) 2011, Even Rouault <even dot rouault at spatialys.com> |
| 9 |
* |
| 10 |
* SPDX-License-Identifier: MIT |
| 11 |
****************************************************************************/ |
| 12 |
|
| 13 |
#include <stdio.h> |
| 14 |
|
| 15 |
int main(int argc, char *argv[]) |
| 16 |
{ |
| 17 |
char c; |
| 18 |
int i; |
| 19 |
int nfeatures; |
| 20 |
int nodes; |
| 21 |
int nparts; |
| 22 |
FILE *f; |
| 23 |
double id, x, y; |
| 24 |
double minx, maxx, miny, maxy; |
| 25 |
|
| 26 |
f = fopen("points.vct", "wb"); |
| 27 |
c = 0x01; |
| 28 |
fwrite(&c, 1, 1, f); |
| 29 |
nfeatures = 2; |
| 30 |
fwrite(&nfeatures, 1, sizeof(int), f); |
| 31 |
for (i = 5; i < 0x105; i++) |
| 32 |
{ |
| 33 |
c = 0; |
| 34 |
fwrite(&c, 1, 1, f); |
| 35 |
} |
| 36 |
|
| 37 |
id = 1; |
| 38 |
x = 400000; |
| 39 |
y = 5000000; |
| 40 |
fwrite(&id, 1, sizeof(double), f); |
| 41 |
fwrite(&x, 1, sizeof(double), f); |
| 42 |
fwrite(&y, 1, sizeof(double), f); |
| 43 |
|
| 44 |
id = 2; |
| 45 |
x = 600000; |
| 46 |
y = 4000000; |
| 47 |
fwrite(&id, 1, sizeof(double), f); |
| 48 |
fwrite(&x, 1, sizeof(double), f); |
| 49 |
fwrite(&y, 1, sizeof(double), f); |
| 50 |
|
| 51 |
fclose(f); |
| 52 |
|
| 53 |
f = fopen("lines.vct", "wb"); |
| 54 |
c = 0x02; |
| 55 |
fwrite(&c, 1, 1, f); |
| 56 |
nfeatures = 2; |
| 57 |
fwrite(&nfeatures, 1, sizeof(int), f); |
| 58 |
for (i = 5; i < 0x105; i++) |
| 59 |
{ |
| 60 |
c = 0; |
| 61 |
fwrite(&c, 1, 1, f); |
| 62 |
} |
| 63 |
|
| 64 |
id = 10; |
| 65 |
minx = 400000; |
| 66 |
miny = 4500000; |
| 67 |
maxx = 600000; |
| 68 |
maxy = 5000000; |
| 69 |
fwrite(&id, 1, sizeof(double), f); |
| 70 |
fwrite(&minx, 1, sizeof(double), f); |
| 71 |
fwrite(&miny, 1, sizeof(double), f); |
| 72 |
fwrite(&maxx, 1, sizeof(double), f); |
| 73 |
fwrite(&maxy, 1, sizeof(double), f); |
| 74 |
nodes = 2; |
| 75 |
fwrite(&nodes, 1, sizeof(int), f); |
| 76 |
x = 400000; |
| 77 |
y = 5000000; |
| 78 |
fwrite(&x, 1, sizeof(double), f); |
| 79 |
fwrite(&y, 1, sizeof(double), f); |
| 80 |
x = 600000; |
| 81 |
y = 4500000; |
| 82 |
fwrite(&x, 1, sizeof(double), f); |
| 83 |
fwrite(&y, 1, sizeof(double), f); |
| 84 |
|
| 85 |
id = 20; |
| 86 |
minx = 400000; |
| 87 |
miny = 4000000; |
| 88 |
maxx = 600000; |
| 89 |
maxy = 4500000; |
| 90 |
fwrite(&id, 1, sizeof(double), f); |
| 91 |
fwrite(&minx, 1, sizeof(double), f); |
| 92 |
fwrite(&miny, 1, sizeof(double), f); |
| 93 |
fwrite(&maxx, 1, sizeof(double), f); |
| 94 |
fwrite(&maxy, 1, sizeof(double), f); |
| 95 |
nodes = 2; |
| 96 |
fwrite(&nodes, 1, sizeof(int), f); |
| 97 |
x = 450000; |
| 98 |
y = 4000000; |
| 99 |
fwrite(&x, 1, sizeof(double), f); |
| 100 |
fwrite(&y, 1, sizeof(double), f); |
| 101 |
x = 550000; |
| 102 |
y = 4500000; |
| 103 |
fwrite(&x, 1, sizeof(double), f); |
| 104 |
fwrite(&y, 1, sizeof(double), f); |
| 105 |
|
| 106 |
fclose(f); |
| 107 |
|
| 108 |
f = fopen("polygons.vct", "wb"); |
| 109 |
c = 0x03; |
| 110 |
fwrite(&c, 1, 1, f); |
| 111 |
nfeatures = 2; |
| 112 |
fwrite(&nfeatures, 1, sizeof(int), f); |
| 113 |
for (i = 5; i < 0x105; i++) |
| 114 |
{ |
| 115 |
c = 0; |
| 116 |
fwrite(&c, 1, 1, f); |
| 117 |
} |
| 118 |
|
| 119 |
id = 1; |
| 120 |
minx = 400000; |
| 121 |
miny = 4000000; |
| 122 |
maxx = 600000; |
| 123 |
maxy = 5000000; |
| 124 |
fwrite(&id, 1, sizeof(double), f); |
| 125 |
fwrite(&minx, 1, sizeof(double), f); |
| 126 |
fwrite(&miny, 1, sizeof(double), f); |
| 127 |
fwrite(&maxx, 1, sizeof(double), f); |
| 128 |
fwrite(&maxy, 1, sizeof(double), f); |
| 129 |
nparts = 2; |
| 130 |
fwrite(&nparts, 1, sizeof(int), f); |
| 131 |
nodes = 10; |
| 132 |
fwrite(&nodes, 1, sizeof(int), f); |
| 133 |
|
| 134 |
nodes = 5; |
| 135 |
fwrite(&nodes, 1, sizeof(int), f); |
| 136 |
|
| 137 |
nodes = 5; |
| 138 |
fwrite(&nodes, 1, sizeof(int), f); |
| 139 |
|
| 140 |
x = 400000; |
| 141 |
y = 4000000; |
| 142 |
fwrite(&x, 1, sizeof(double), f); |
| 143 |
fwrite(&y, 1, sizeof(double), f); |
| 144 |
x = 400000; |
| 145 |
y = 5000000; |
| 146 |
fwrite(&x, 1, sizeof(double), f); |
| 147 |
fwrite(&y, 1, sizeof(double), f); |
| 148 |
x = 600000; |
| 149 |
y = 5000000; |
| 150 |
fwrite(&x, 1, sizeof(double), f); |
| 151 |
fwrite(&y, 1, sizeof(double), f); |
| 152 |
x = 600000; |
| 153 |
y = 4000000; |
| 154 |
fwrite(&x, 1, sizeof(double), f); |
| 155 |
fwrite(&y, 1, sizeof(double), f); |
| 156 |
x = 400000; |
| 157 |
y = 4000000; |
| 158 |
fwrite(&x, 1, sizeof(double), f); |
| 159 |
fwrite(&y, 1, sizeof(double), f); |
| 160 |
|
| 161 |
x = 450000; |
| 162 |
y = 4250000; |
| 163 |
fwrite(&x, 1, sizeof(double), f); |
| 164 |
fwrite(&y, 1, sizeof(double), f); |
| 165 |
x = 450000; |
| 166 |
y = 4750000; |
| 167 |
fwrite(&x, 1, sizeof(double), f); |
| 168 |
fwrite(&y, 1, sizeof(double), f); |
| 169 |
x = 550000; |
| 170 |
y = 4750000; |
| 171 |
fwrite(&x, 1, sizeof(double), f); |
| 172 |
fwrite(&y, 1, sizeof(double), f); |
| 173 |
x = 550000; |
| 174 |
y = 4250000; |
| 175 |
fwrite(&x, 1, sizeof(double), f); |
| 176 |
fwrite(&y, 1, sizeof(double), f); |
| 177 |
x = 450000; |
| 178 |
y = 4250000; |
| 179 |
fwrite(&x, 1, sizeof(double), f); |
| 180 |
fwrite(&y, 1, sizeof(double), f); |
| 181 |
|
| 182 |
id = 2; |
| 183 |
minx = 400000; |
| 184 |
miny = 4000000; |
| 185 |
maxx = 600000; |
| 186 |
maxy = 5000000; |
| 187 |
fwrite(&id, 1, sizeof(double), f); |
| 188 |
fwrite(&minx, 1, sizeof(double), f); |
| 189 |
fwrite(&miny, 1, sizeof(double), f); |
| 190 |
fwrite(&maxx, 1, sizeof(double), f); |
| 191 |
fwrite(&maxy, 1, sizeof(double), f); |
| 192 |
nparts = 1; |
| 193 |
fwrite(&nparts, 1, sizeof(int), f); |
| 194 |
nodes = 5; |
| 195 |
fwrite(&nodes, 1, sizeof(int), f); |
| 196 |
|
| 197 |
nodes = 5; |
| 198 |
fwrite(&nodes, 1, sizeof(int), f); |
| 199 |
|
| 200 |
x = 400000; |
| 201 |
y = 4000000; |
| 202 |
fwrite(&x, 1, sizeof(double), f); |
| 203 |
fwrite(&y, 1, sizeof(double), f); |
| 204 |
x = 400000; |
| 205 |
y = 5000000; |
| 206 |
fwrite(&x, 1, sizeof(double), f); |
| 207 |
fwrite(&y, 1, sizeof(double), f); |
| 208 |
x = 600000; |
| 209 |
y = 5000000; |
| 210 |
fwrite(&x, 1, sizeof(double), f); |
| 211 |
fwrite(&y, 1, sizeof(double), f); |
| 212 |
x = 600000; |
| 213 |
y = 4000000; |
| 214 |
fwrite(&x, 1, sizeof(double), f); |
| 215 |
fwrite(&y, 1, sizeof(double), f); |
| 216 |
x = 400000; |
| 217 |
y = 4000000; |
| 218 |
fwrite(&x, 1, sizeof(double), f); |
| 219 |
fwrite(&y, 1, sizeof(double), f); |
| 220 |
|
| 221 |
fclose(f); |
| 222 |
|
| 223 |
return 0; |
| 224 |
} |