Changeset 1205
- Timestamp:
- 07/03/09 09:29:50 (14 months ago)
- Location:
- trunk
- Files:
-
- 3 modified
-
include/mapnik/global.hpp (modified) (3 diffs)
-
plugins/input/shape/shapefile.hpp (modified) (2 diffs)
-
src/wkb.cpp (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/mapnik/global.hpp
r805 r1205 26 26 #define GLOBAL_HPP 27 27 28 // boost 28 29 #include <boost/cstdint.hpp> 29 30 #include <boost/detail/endian.hpp> 31 // stl 32 #include <cstring> 30 33 31 34 namespace mapnik … … 35 38 (((boost::uint16_t) ((boost::uint8_t) (A)[0])) << 8)) 36 39 37 #define int4net(A) (int32_t) (((boost::uint32_t) ((boost::uint8_t) (A)[3]))| \40 #define int4net(A) (int32_t) (((boost::uint32_t) ((boost::uint8_t) (A)[3])) | \ 38 41 (((boost::uint32_t) ((boost::uint8_t) (A)[2])) << 8) | \ 39 42 (((boost::uint32_t) ((boost::uint8_t) (A)[1])) << 16) | \ … … 58 61 ((byte*) &def_temp)[3]=(M)[0]; \ 59 62 (V)=def_temp; } while(0) 63 64 65 // read int NDR (little endian) 66 inline int& read_int_ndr(const char* data, int & val) 67 { 68 #ifndef BOOST_BIG_ENDIAN 69 memcpy(&val,data,4); 70 #else 71 val = (data[3]&0xff) | 72 ((data[2]&0xff)<<8) | 73 ((data[1]&0xff)<<16) | 74 ((data[0]&0xff)<<24); 75 #endif 76 return val; 77 } 78 79 // read double NDR (little endian) 80 inline double& read_double_ndr(const char* data, double & val) 81 { 82 #ifndef BOOST_BIG_ENDIAN 83 std::memcpy(&val,&data[0],8); 84 #else 85 boost::int64_t bits = ((boost::int64_t)data[0] & 0xff) | 86 ((boost::int64_t)data[1] & 0xff) << 8 | 87 ((boost::int64_t)data[2] & 0xff) << 16 | 88 ((boost::int64_t)data[3] & 0xff) << 24 | 89 ((boost::int64_t)data[4] & 0xff) << 32 | 90 ((boost::int64_t)data[5] & 0xff) << 40 | 91 ((boost::int64_t)data[6] & 0xff) << 48 | 92 ((boost::int64_t)data[7] & 0xff) << 56 ; 93 std::memcpy(&val,&bits,8); 94 #endif 95 return val; 96 } 97 98 // read int XDR (big endian) 99 inline int& read_int_xdr(const char* data, int & val) 100 { 101 #ifndef BOOST_BIG_ENDIAN 102 val = (data[3]&0xff) | ((data[2]&0xff)<<8) | ((data[1]&0xff)<<16) | ((data[0]&0xff)<<24); 103 #else 104 memcpy(&val,data,4); 105 #endif 106 return val; 107 } 108 109 // read double XDR (big endian) 110 inline double& read_double_xdr(const char* data, double & val) 111 { 112 #ifndef BOOST_BIG_ENDIAN 113 boost::int64_t bits = ((boost::int64_t)data[0] & 0xff) | 114 ((boost::int64_t)data[1] & 0xff) << 8 | 115 ((boost::int64_t)data[2] & 0xff) << 16 | 116 ((boost::int64_t)data[3] & 0xff) << 24 | 117 ((boost::int64_t)data[4] & 0xff) << 32 | 118 ((boost::int64_t)data[5] & 0xff) << 40 | 119 ((boost::int64_t)data[6] & 0xff) << 48 | 120 ((boost::int64_t)data[7] & 0xff) << 56 ; 121 std::memcpy(&val,&bits,8); 122 #else 123 std::memcpy(&val,&data[0],8); 124 #endif 125 return val; 126 } 60 127 } 61 128 -
trunk/plugins/input/shape/shapefile.hpp
r1171 r1205 26 26 #define SHAPEFILE_HPP 27 27 28 #include <mapnik/global.hpp> 28 29 #include <mapnik/envelope.hpp> 29 30 // boost 30 31 #include <boost/utility.hpp> 31 #include <boost/ detail/endian.hpp>32 #include <boost/cstdint.hpp> 32 33 #include <boost/iostreams/stream.hpp> 34 33 35 #include <boost/iostreams/device/file.hpp> 34 36 #include <boost/iostreams/device/mapped_file.hpp> 37 //#include <boost/iostreams/device/file_descriptor.hpp> 35 38 36 39 #include <cstring> 37 40 38 41 using mapnik::Envelope; 42 using mapnik::read_int_ndr; 43 using mapnik::read_int_xdr; 44 using mapnik::read_double_ndr; 45 using mapnik::read_double_xdr; 39 46 40 47 struct shape_record 41 48 { 42 const char* data; 43 size_t size; 44 mutable size_t pos; 45 explicit shape_record(size_t size) 46 : size(size), 47 pos(0) {} 49 const char* data; 50 size_t size; 51 mutable size_t pos; 52 explicit shape_record(size_t size) 53 : //data(static_cast<char*>(::operator new(sizeof(char)*size))), 54 size(size), 55 pos(0) {} 48 56 49 void set_data(const char * data_) 50 { 51 data = data_; 52 } 57 void set_data(const char * data_) 58 { 59 data = data_; 60 } 61 62 void skip(unsigned n) 63 { 64 pos+=n; 65 } 53 66 54 void skip(unsigned n) 55 { 56 pos+=n; 57 } 67 int read_ndr_integer() 68 { 69 int val; 70 read_int_ndr(&data[pos],val); 71 pos+=4; 72 return val; 73 } 58 74 59 int read_ndr_integer() 60 { 61 int val=(data[pos] & 0xff) | 62 (data[pos+1] & 0xff) << 8 | 63 (data[pos+2] & 0xff) << 16 | 64 (data[pos+3] & 0xff) << 24; 65 pos+=4; 66 return val; 67 } 75 int read_xdr_integer() 76 { 77 int val; 78 read_int_xdr(&data[pos],val); 79 pos+=4; 80 return val; 81 } 68 82 69 int read_xdr_integer() 70 { 71 int val=(data[pos] & 0xff) << 24 | 72 (data[pos+1] & 0xff) << 16 | 73 (data[pos+2] & 0xff) << 8 | 74 (data[pos+3] & 0xff); 75 pos+=4; 76 return val; 77 } 78 79 double read_double() 80 { 81 double val; 82 #ifndef BOOST_BIG_ENDIAN 83 std::memcpy(&val,&data[pos],8); 84 #else 85 long long bits = ((long long)data[pos] & 0xff) | 86 ((long long)data[pos+1] & 0xff) << 8 | 87 ((long long)data[pos+2] & 0xff) << 16 | 88 ((long long)data[pos+3] & 0xff) << 24 | 89 ((long long)data[pos+4] & 0xff) << 32 | 90 ((long long)data[pos+5] & 0xff) << 40 | 91 ((long long)data[pos+6] & 0xff) << 48 | 92 ((long long)data[pos+7] & 0xff) << 56 ; 93 std::memcpy(&val,&bits,8); 94 #endif 95 pos+=8; 96 return val; 97 } 98 long remains() 99 { 100 return (size-pos); 101 } 102 ~shape_record() {} 83 double read_double() 84 { 85 double val; 86 read_double_ndr(&data[pos],val); 87 pos+=8; 88 return val; 89 } 90 long remains() 91 { 92 return (size-pos); 93 } 94 95 ~shape_record() 96 { 97 //::operator delete(data); 98 } 103 99 104 100 }; … … 108 104 class shape_file : boost::noncopyable 109 105 { 110 stream<mapped_file_source> file_; 111 public: 112 shape_file(); 113 shape_file(const std::string& file_name); 114 ~shape_file(); 115 bool is_open(); 116 void close(); 106 stream<mapped_file_source> file_; 107 //stream<file_source> file_; 108 public: 109 shape_file(); 110 shape_file(std::string const& file_name); 111 ~shape_file(); 112 bool is_open(); 113 void close(); 117 114 118 inline void read_record(shape_record& rec) 119 { 120 rec.set_data(file_->data() + file_.tellg()); 121 file_.seekg(rec.size,std::ios::cur); 122 } 115 inline void read_record(shape_record& rec) 116 { 117 rec.set_data(file_->data() + file_.tellg()); 118 file_.seekg(rec.size,std::ios::cur); 119 } 120 121 inline int read_xdr_integer() 122 { 123 char b[4]; 124 file_.read(b, 4); 125 int val; 126 read_int_xdr(b,val); 127 return val; 128 } 123 129 124 inline int read_xdr_integer() 125 { 126 char b[4]; 127 file_.read(b, 4); 128 return (b[3] & 0xffu) | ((b[2] & 0xffu) << 8) | 129 ((b[1] & 0xffu) << 16) | ((b[0] & 0xffu) << 24); 130 } 130 inline int read_ndr_integer() 131 { 132 char b[4]; 133 file_.read(b,4); 134 int val; 135 read_int_ndr(b,val); 136 return val; 137 } 131 138 132 inline int read_ndr_integer() 133 { 134 char b[4]; 135 file_.read(b,4); 136 return (b[0]&0xffu) | ((b[1]&0xffu) << 8) | 137 ((b[2]&0xffu) << 16) | ((b[3]&0xffu) << 24); 138 } 139 inline double read_double() 140 { 141 double val; 142 #ifndef WORDS_BIGENDIAN 143 file_.read(reinterpret_cast<char*>(&val),8); 144 #else 145 char b[8]; 146 file_.read(b,8); 147 read_double_ndr(b,val); 148 #endif 149 return val; 150 } 151 152 inline void read_envelope(Envelope<double>& envelope) 153 { 154 #ifndef WORDS_BIGENDIAN 155 file_.read(reinterpret_cast<char*>(&envelope),sizeof(envelope)); 156 #else 157 char data[4*8]; 158 file_.read(data,4*8); 159 double minx,miny,maxx,maxy; 160 read_double_ndr(data,minx); 161 read_double_ndr(data,miny); 162 read_double_ndr(data,maxx); 163 read_double_ndr(data,maxy); 164 envelope.init(minx,miny,maxx,maxy); 165 #endif 166 } 139 167 140 inline double read_double() 141 { 142 double val; 143 #ifndef WORDS_BIGENDIAN 144 file_.read(reinterpret_cast<char*>(&val),8); 145 #else 146 char b[8]; 147 file_.read(b,8); 148 long long bits = ((long long)b[0] & 0xff) | 149 ((long long)b[1] & 0xff) << 8 | 150 ((long long)b[2] & 0xff) << 16 | 151 ((long long)b[3] & 0xff) << 24 | 152 ((long long)b[4] & 0xff) << 32 | 153 ((long long)b[5] & 0xff) << 40 | 154 ((long long)b[6] & 0xff) << 48 | 155 ((long long)b[7] & 0xff) << 56 ; 156 memcpy(&val,&bits,8); 157 #endif 158 return val; 159 } 168 inline void skip(std::streampos bytes) 169 { 170 file_.seekg(bytes,std::ios::cur); 171 } 160 172 161 inline void read_envelope(Envelope<double>& envelope) 162 { 163 #ifndef WORDS_BIGENDIAN 164 file_.read(reinterpret_cast<char*>(&envelope),sizeof(envelope)); 165 #else 166 double minx=read_double(); 167 double miny=read_double(); 168 double maxx=read_double(); 169 double maxy=read_double(); 170 envelope.init(minx,miny,maxx,maxy); 171 #endif 172 } 173 inline void rewind() 174 { 175 seek(100); 176 } 173 177 174 inline void skip(std::streampos bytes)175 {176 file_.seekg(bytes,std::ios::cur);177 }178 inline void seek(std::streampos pos) 179 { 180 file_.seekg(pos,std::ios::beg); 181 } 178 182 179 inline void rewind()180 {181 seek(100);182 }183 inline std::streampos pos() 184 { 185 return file_.tellg(); 186 } 183 187 184 inline void seek(std::streampos pos) 185 { 186 file_.seekg(pos,std::ios::beg); 187 } 188 189 inline std::streampos pos() 190 { 191 return file_.tellg(); 192 } 193 194 inline bool is_eof() 195 { 196 return file_.eof(); 197 } 188 inline bool is_eof() 189 { 190 return file_.eof(); 191 } 198 192 }; 199 193 -
trunk/src/wkb.cpp
r1188 r1205 23 23 //$Id: wkb.cpp 19 2005-03-22 13:53:27Z pavlenko $ 24 24 25 #include <mapnik/global.hpp> 25 26 #include <mapnik/wkb.hpp> 26 27 #include <mapnik/geom_util.hpp> 27 28 #include <mapnik/feature.hpp> 29 28 30 // boost 29 #include <boost/ cstdint.hpp>31 #include <boost/utility.hpp> 30 32 #include <boost/detail/endian.hpp> 31 33 32 34 namespace mapnik 33 35 { 34 struct wkb_reader35 {36 private:37 enum wkbByteOrder {36 struct wkb_reader : boost::noncopyable 37 { 38 private: 39 enum wkbByteOrder { 38 40 wkbXDR=0, 39 41 wkbNDR=1 40 };41 const char* wkb_;42 unsigned size_;43 unsigned pos_;44 wkbByteOrder byteOrder_;45 bool needSwap_;46 wkbFormat format_;47 48 public:49 50 enum wkbGeometryType {42 }; 43 const char* wkb_; 44 unsigned size_; 45 unsigned pos_; 46 wkbByteOrder byteOrder_; 47 bool needSwap_; 48 wkbFormat format_; 49 50 public: 51 52 enum wkbGeometryType { 51 53 wkbPoint=1, 52 54 wkbLineString=2, … … 56 58 wkbMultiPolygon=6, 57 59 wkbGeometryCollection=7 58 };59 60 wkb_reader(const char* wkb,unsigned size,wkbFormat format)60 }; 61 62 wkb_reader(const char* wkb,unsigned size,wkbFormat format) 61 63 : wkb_(wkb), 62 64 size_(size), 63 65 pos_(0), 64 66 format_(format) 65 {67 { 66 68 switch (format_) 67 69 { 68 case wkbSpatiaLite:69 byteOrder_ = (wkbByteOrder) wkb_[1];70 pos_ = 39;71 break;72 73 case wkbGeneric:74 default:75 byteOrder_ = (wkbByteOrder) wkb_[0];76 pos_ = 1;77 break;70 case wkbSpatiaLite: 71 byteOrder_ = (wkbByteOrder) wkb_[1]; 72 pos_ = 39; 73 break; 74 75 case wkbGeneric: 76 default: 77 byteOrder_ = (wkbByteOrder) wkb_[0]; 78 pos_ = 1; 79 break; 78 80 } 79 81 … … 83 85 needSwap_=byteOrder_?wkbNDR:wkbXDR; 84 86 #endif 85 }86 87 ~wkb_reader() {}88 89 void read_multi(Feature & feature)90 {87 } 88 89 ~wkb_reader() {} 90 91 void read_multi(Feature & feature) 92 { 91 93 int type=read_integer(); 92 94 switch (type) 93 95 { 94 case wkbPoint:95 read_point(feature);96 break;97 case wkbLineString:98 read_linestring(feature);99 break;100 case wkbPolygon:101 read_polygon(feature);102 break;103 case wkbMultiPoint:104 read_multipoint(feature);105 break;106 case wkbMultiLineString:107 read_multilinestring(feature);108 break;109 case wkbMultiPolygon:110 read_multipolygon(feature);111 break;112 case wkbGeometryCollection:113 break;114 default:115 break;116 } 117 }118 119 void read(Feature & feature)120 {96 case wkbPoint: 97 read_point(feature); 98 break; 99 case wkbLineString: 100 read_linestring(feature); 101 break; 102 case wkbPolygon: 103 read_polygon(feature); 104 break; 105 case wkbMultiPoint: 106 read_multipoint(feature); 107 break; 108 case wkbMultiLineString: 109 read_multilinestring(feature); 110 break; 111 case wkbMultiPolygon: 112 read_multipolygon(feature); 113 break; 114 case wkbGeometryCollection: 115 break; 116 default: 117 break; 118 } 119 } 120 121 void read(Feature & feature) 122 { 121 123 int type=read_integer(); 122 124 switch (type) 123 125 { 124 case wkbPoint:125 read_point(feature);126 break;127 case wkbLineString:128 read_linestring(feature);129 break;130 case wkbPolygon:131 read_polygon(feature);132 break;133 case wkbMultiPoint:134 read_multipoint_2(feature);135 break;136 case wkbMultiLineString:137 read_multilinestring_2(feature);138 break;139 case wkbMultiPolygon:140 read_multipolygon_2(feature);141 break;142 case wkbGeometryCollection:143 break;144 default:145 break;146 } 147 }126 case wkbPoint: 127 read_point(feature); 128 break; 129 case wkbLineString: 130 read_linestring(feature); 131 break; 132 case wkbPolygon: 133 read_polygon(feature); 134 break; 135 case wkbMultiPoint: 136 read_multipoint_2(feature); 137 break; 138 case wkbMultiLineString: 139 read_multilinestring_2(feature); 140 break; 141 case wkbMultiPolygon: 142 read_multipolygon_2(feature); 143 break; 144 case wkbGeometryCollection: 145 break; 146 default: 147 break; 148 } 149 } 148 150 149 private: 150 wkb_reader(const wkb_reader&); 151 wkb_reader& operator=(const wkb_reader&); 152 153 int read_integer() 154 { 151 private: 152 153 int read_integer() 154 { 155 155 int n; 156 157 if (!needSwap_) 158 { 159 memcpy(&n,wkb_+pos_,4); 156 if (needSwap_) 157 { 158 read_int_xdr(wkb_+pos_,n); 160 159 } 161 160 else 162 161 { 163 const char* b=wkb_+pos_; 164 n = (b[3]&0xff) | ((b[2]&0xff)<<8) | ((b[1]&0xff)<<16) | ((b[0]&0xff)<<24); 162 read_int_ndr(wkb_+pos_,n); 165 163 } 166 164 pos_+=4; 167 165 168 166 return n; 169 }170 171 double read_double()172 {167 } 168 169 double read_double() 170 { 173 171 double d; 174 175 if (!needSwap_) 176 { 177 memcpy(&d,wkb_+pos_,8); 172 if (needSwap_) 173 { 174 read_double_xdr(wkb_ + pos_, d); 178 175 } 179 176 else 180 177 { 181 const char* b= wkb_+pos_; 182 boost::int64_t n = ((boost::int64_t)b[7]&0xff) | 183 (((boost::int64_t)b[6]&0xff)<<8) | 184 (((boost::int64_t)b[5]&0xff)<<16) | 185 (((boost::int64_t)b[4]&0xff)<<24) | 186 (((boost::int64_t)b[3]&0xff)<<32) | 187 (((boost::int64_t)b[2]&0xff)<<40) | 188 (((boost::int64_t)b[1]&0xff)<<48) | 189 (((boost::int64_t)b[0]&0xff)<<56); 190 memcpy(&d,&n,8); 178 read_double_ndr(wkb_ + pos_, d); 191 179 } 192 180 pos_+=8; 193 181 194 182 return d; 195 }196 197 void read_coords(CoordinateArray& ar)198 {183 } 184 185 void read_coords(CoordinateArray& ar) 186 { 199 187 int size=sizeof(coord<double,2>)*ar.size(); 200 188 if (!needSwap_) 201 189 { 202 std::memcpy(&ar[0],wkb_+pos_,size);203 190 std::memcpy(&ar[0],wkb_+pos_,size); 191 pos_+=size; 204 192 } 205 193 else 206 194 { 207 for (unsigned i=0;i<ar.size();++i) 208 { 209 ar[i].x=read_double(); 210 ar[i].y=read_double(); 211 } 212 } 213 pos_+=size; 214 } 215 216 void read_point(Feature & feature) 217 { 195 for (unsigned i=0;i<ar.size();++i) 196 { 197 read_double_ndr(wkb_ + pos_,ar[i].x); 198 read_double_ndr(wkb_ + pos_ + 8,ar[i].y); 199 pos_ += 16; 200 } 201 } 202 203 } 204 205 void read_point(Feature & feature) 206 { 218 207 geometry2d * pt = new point<vertex2d>; 219 208 double x = read_double(); … … 221 210 pt->move_to(x,y); 222 211 feature.add_geometry(pt); 223 }224 225 void read_multipoint(Feature & feature)226 {212 } 213 214 void read_multipoint(Feature & feature) 215 { 227 216 int num_points = read_integer(); 228 217 for (int i=0;i<num_points;++i) 229 218 { 230 pos_+=5;231 read_point(feature);232 } 233 }234 235 void read_multipoint_2(Feature & feature)236 {219 pos_+=5; 220 read_point(feature); 221 } 222 } 223 224 void read_multipoint_2(Feature & feature) 225 { 237 226 geometry2d * pt = new point<vertex2d>; 238 227 int num_points = read_integer(); 239 228 for (int i=0;i<num_points;++i) 240 229 { 241 pos_+=5;242 double x = read_double();243 double y = read_double();244 pt->move_to(x,y);230 pos_+=5; 231 double x = read_double(); 232 double y = read_double(); 233 pt->move_to(x,y); 245 234 } 246 235 feature.add_geometry(pt); 247 }248 249 void read_linestring(Feature & feature)250 {236 } 237 238 void read_linestring(Feature & feature) 239 { 251 240 geometry2d * line = new line_string<vertex2d>; 252 241 int num_points=read_integer(); … … 257 246 for (int i=1;i<num_points;++i) 258 247 { 259 line->line_to(ar[i].x,ar[i].y);248 line->line_to(ar[i].x,ar[i].y); 260 249 } 261 250 feature.add_geometry(line); 262 }263 264 void read_multilinestring(Feature & feature)265 {251 } 252 253 void read_multilinestring(Feature & feature) 254 { 266 255 int num_lines=read_integer(); 267 256 for (int i=0;i<num_lines;++i) 268 257 { 269 pos_+=5;270 read_linestring(feature);271 } 272 }273 274 void read_multilinestring_2(Feature & feature)275 {258 pos_+=5; 259 read_linestring(feature); 260 } 261 } 262 263 void read_multilinestring_2(Feature & feature) 264 { 276 265 geometry2d * line = new line_string<vertex2d>; 277 266 int num_lines=read_integer(); … … 279 268 for (int i=0;i<num_lines;++i) 280 269 { 281 pos_+=5;282 int num_points=read_integer();283 capacity+=num_points;284 CoordinateArray ar(num_points);285 read_coords(ar);286 line->set_capacity(capacity);287 line->move_to(ar[0].x,ar[0].y);288 for (int i=1;i<num_points;++i)289 {290 line->line_to(ar[i].x,ar[i].y);291 }270 pos_+=5; 271 int num_points=read_integer(); 272 capacity+=num_points; 273 CoordinateArray ar(num_points); 274 read_coords(ar); 275 line->set_capacity(capacity); 276 line->move_to(ar[0].x,ar[0].y); 277 for (int i=1;i<num_points;++i) 278 { 279 line->line_to(ar[i].x,ar[i].y); 280 } 292 281 } 293 282 feature.add_geometry(line); 294 }295 296 void read_polygon(Feature & feature)297 {283 } 284 285 void read_polygon(Feature & feature) 286 { 298 287 geometry2d * poly = new polygon<vertex2d>; 299 288 int num_rings=read_integer(); … … 301 290 for (int i=0;i<num_rings;++i) 302 291 { 303 int num_points=read_integer();304 capacity+=num_points;305 CoordinateArray ar(num_points);306 read_coords(ar);307 poly->set_capacity(capacity);308 poly->move_to(ar[0].x,ar[0].y);309 for (int j=1;j<num_points;++j)310 {311 poly->line_to(ar[j].x,ar[j].y);312 }292 int num_points=read_integer(); 293 capacity+=num_points; 294 CoordinateArray ar(num_points); 295 read_coords(ar); 296 poly->set_capacity(capacity); 297 poly->move_to(ar[0].x,ar[0].y); 298 for (int j=1;j<num_points;++j) 299 { 300 poly->line_to(ar[j].x,ar[j].y); 301 } 313 302 } 314 303 feature.add_geometry(poly); 315 }316 317 void read_multipolygon(Feature & feature)318 {304 } 305 306 void read_multipolygon(Feature & feature) 307 { 319 308 int num_polys=read_integer(); 320 309 for (int i=0;i<num_polys;++i) 321 310 { 322 pos_+=5;323 read_polygon(feature);324 } 325 }326 327 void read_multipolygon_2(Feature & feature)328 {311 pos_+=5; 312 read_polygon(feature); 313 } 314 } 315 316 void read_multipolygon_2(Feature & feature) 317 { 329 318 geometry2d * poly = new polygon<vertex2d>; 330 319 int num_polys=read_integer(); … … 332 321 for (int i=0;i<num_polys;++i) 333 322 { 334 pos_+=5;335 int num_rings=read_integer();336 for (int i=0;i<num_rings;++i)337 {338 int num_points=read_integer();339 capacity += num_points;340 CoordinateArray ar(num_points);341 read_coords(ar);342 poly->set_capacity(capacity);343 poly->move_to(ar[0].x,ar[0].y);323 pos_+=5; 324 int num_rings=read_integer(); 325 for (int i=0;i<num_rings;++i) 326 { 327 int num_points=read_integer(); 328 capacity += num_points; 329 CoordinateArray ar(num_points); 330 read_coords(ar); 331 poly->set_capacity(capacity); 332 poly->move_to(ar[0].x,ar[0].y); 344 333 345 for (int j=1;j<num_points;++j)346 {347 poly->line_to(ar[j].x,ar[j].y);348 }349 poly->line_to(ar[0].x,ar[0].y);350 }334 for (int j=1;j<num_points;++j) 335 { 336 poly->line_to(ar[j].x,ar[j].y); 337 } 338 poly->line_to(ar[0].x,ar[0].y); 339 } 351 340 } 352 341 feature.add_geometry(poly); 353 }354 };355 356 void geometry_utils::from_wkb (Feature & feature,342 } 343 }; 344 345 void geometry_utils::from_wkb (Feature & feature, 357 346 const char* wkb, 358 347 unsigned size, 359 348 bool multiple_geometries, 360 349 wkbFormat format) 361 {362 wkb_reader reader(wkb,size,format);363 if (multiple_geometries)364 return reader.read_multi(feature);365 else366 return reader.read(feature);367 }350 { 351 wkb_reader reader(wkb,size,format); 352 if (multiple_geometries) 353 return reader.read_multi(feature); 354 else 355 return reader.read(feature); 356 } 368 357 }
