| 258 | | mPList.mBounds[0] = Shape::freadLittleDouble(fp); |
| 259 | | mPList.mBounds[1] = Shape::freadLittleDouble(fp); |
| 260 | | mPList.mBounds[2] = Shape::freadLittleDouble(fp); |
| 261 | | mPList.mBounds[3] = Shape::freadLittleDouble(fp); |
| 262 | | rctx.readSize += 32; |
| 263 | | rctx.readRecordContentSize += 32; |
| 264 | | |
| 265 | | mPList.mNParts = Shape::freadLittle32(fp); |
| 266 | | mPList.mNPoints = Shape::freadLittle32(fp); |
| 267 | | rctx.readSize += 8; |
| 268 | | rctx.readRecordContentSize += 8; |
| 269 | | |
| 270 | | mPList.allocBuffers(); |
| 271 | | |
| 272 | | ESInt32 i; |
| 273 | | |
| 274 | | for (i = 0;i < mPList.mNParts;i++) |
| 275 | | { |
| 276 | | mPList.mPartIndexes[i] = Shape::freadLittle32(fp); |
| 277 | | rctx.readSize += 4; |
| 278 | | rctx.readRecordContentSize += 4; |
| 279 | | } |
| 280 | | |
| 281 | | for (i = 0;i < mPList.mNPoints;i++) |
| 282 | | { |
| 283 | | mPList.mPoints[i].x = Shape::freadLittleDouble(fp); |
| 284 | | mPList.mPoints[i].y = Shape::freadLittleDouble(fp); |
| 285 | | rctx.readSize += 16; |
| 286 | | rctx.readRecordContentSize += 16; |
| 287 | | } |
| 288 | | |
| 289 | | if (mOption & SHPRECORD_WITH_Z) |
| 290 | | { |
| 291 | | // Z |
| 292 | | mPList.mZRange[0] = Shape::freadLittleDouble(fp); |
| 293 | | mPList.mZRange[1] = Shape::freadLittleDouble(fp); |
| 294 | | rctx.readSize += 16; |
| 295 | | rctx.readRecordContentSize += 16; |
| 296 | | |
| 297 | | for (i = 0;i < mPList.mNPoints;i++) |
| 298 | | { |
| 299 | | mPList.mPoints[i].z = Shape::freadLittleDouble(fp); |
| 300 | | rctx.readSize += 8; |
| 301 | | rctx.readRecordContentSize += 8; |
| 302 | | } |
| 303 | | |
| 304 | | // Measure |
| 305 | | mPList.mMRange[0] = Shape::freadLittleDouble(fp); |
| 306 | | mPList.mMRange[1] = Shape::freadLittleDouble(fp); |
| 307 | | rctx.readSize += 16; |
| 308 | | rctx.readRecordContentSize += 16; |
| 309 | | |
| 310 | | for (i = 0;i < mPList.mNPoints;i++) |
| 311 | | { |
| 312 | | mPList.mPoints[i].m = Shape::freadLittleDouble(fp); |
| 313 | | rctx.readSize += 8; |
| 314 | | rctx.readRecordContentSize += 8; |
| 315 | | } |
| 316 | | } |
| | 271 | mPList.readFromMainFile(fp, rctx, mOption); |
| | 272 | |
| 343 | | if (index < 0 || index >= mPList.mNParts) |
| 344 | | return Qnil; |
| 345 | | |
| 346 | | int len = (index == (mPList.mNParts-1)) ? mPList.mNPoints : mPList.mPartIndexes[index+1]; |
| 347 | | len -= mPList.mPartIndexes[index]; |
| 348 | | |
| 349 | | int start = mPList.mPartIndexes[index]; |
| 350 | | |
| 351 | | VALUE arr = rb_ary_new2(len); |
| 352 | | for (int i = 0;i < len;i++) |
| 353 | | { |
| 354 | | ESPointEx& p = mPList.mPoints[start+i]; |
| 355 | | ShpPoint* shp = new ShpPoint(p.x, p.y, p.z, p.m); |
| 356 | | rb_ary_push(arr, shp->toRubyObject()); |
| 357 | | } |
| 358 | | |
| 359 | | return arr; |
| | 299 | return mPList.getPartAsRubyObj(index); |
| | 319 | } |
| | 320 | |
| | 321 | // Polyline |
| | 322 | |
| | 323 | ShpPolyline::ShpPolyline(int option) |
| | 324 | { |
| | 325 | mOption = option; |
| | 326 | } |
| | 327 | |
| | 328 | ShpPolyline::~ShpPolyline() |
| | 329 | { |
| | 330 | } |
| | 331 | |
| | 332 | es_error_t ShpPolyline::readFromMainFile(FILE* fp, ShpReadContext& rctx) |
| | 333 | { |
| | 334 | es_error_t rv = ESHP_OK; |
| | 335 | |
| | 336 | mType = Shape::freadLittle32(fp); |
| | 337 | rctx.readSize += 4; |
| | 338 | rctx.readRecordContentSize += 4; |
| | 339 | |
| | 340 | mPList.readFromMainFile(fp, rctx, mOption); |
| | 341 | |
| | 342 | return rv; |
| | 343 | } |
| | 344 | |
| | 345 | VALUE ShpPolyline::getPartAt(int index) |
| | 346 | { |
| | 347 | return mPList.getPartAsRubyObj(index); |
| | 348 | } |
| | 349 | |
| | 350 | int ShpPolyline::getPartsLength() |
| | 351 | { |
| | 352 | return mPList.mNParts; |
| | 353 | } |
| | 354 | |
| | 355 | ShpRecordObject* ShpPolyline::clone() |
| | 356 | { |
| | 357 | ShpPolyline* copy = new ShpPolyline(mOption); |
| | 358 | copy->mType = mType; |
| | 359 | copy->mPList.copyFrom(mPList); |
| | 360 | |
| | 361 | return copy; |
| | 362 | } |
| | 363 | |
| | 364 | VALUE ShpPolyline::toRubyObject() |
| | 365 | { |
| | 366 | VALUE klass = getRubyESRIShapePolylineClass(); |
| | 367 | VALUE instance = rb_class_new_instance(0, NULL, klass); |
| | 368 | |
| | 369 | RPolylineData* indata; |
| | 370 | Data_Get_Struct(instance, RPolylineData, indata); |
| | 371 | |
| | 372 | indata->pThis = this; |
| | 373 | |
| | 374 | return instance; |