Changeset 2076

Show
Ignore:
Timestamp:
11/28/07 01:28:58 (5 years ago)
Author:
gyuque
Message:

/lang/ruby/RubyESRIShape: added getter of shape type

Location:
lang/ruby/RubyESRIShape
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • lang/ruby/RubyESRIShape/RubyESRIShape.c

    r2062 r2076  
    8585                rb_raise(rb_eIOError, "shape types unmatched between files."); 
    8686 
     87        /* ESHP_NOINDEXFILE doesn't raise any errors */ 
     88 
    8789        return Qnil; 
    8890} 
     
    121123 
    122124        return self; 
     125} 
     126 
     127static VALUE rb_shape_type(VALUE self) 
     128{ 
     129        RShapeData* indata; 
     130    Data_Get_Struct(self, RShapeData, indata); 
     131 
     132        return INT2NUM( c_Shape_getType(indata->pThis) ); 
    123133} 
    124134 
     
    367377        rb_define_method(rb_cShape, "length", rb_shape_length, 0); 
    368378        rb_define_method(rb_cShape, "each",   rb_shape_each  , 0); 
     379        rb_define_method(rb_cShape, "type",   rb_shape_type  , 0); 
    369380 
    370381        // class 
  • lang/ruby/RubyESRIShape/Shape.cpp

    r2062 r2076  
    2727{ 
    2828        return (ESRIShapeType)mSHPFHeader.shapetype; 
     29} 
     30 
     31int Shape::getTypeAsInt() const 
     32{ 
     33        return mSHPFHeader.shapetype; 
    2934} 
    3035 
     
    4449                _tcscpy(actualName + orgLen, ".shx"); 
    4550                rv = readIndexFile(actualName); 
    46  
    47                 //_tcscpy(actualName + orgLen, ".dbf"); 
    4851        } 
    4952 
     
    423426{return ((Shape*)pThis)->getLength();} 
    424427 
     428int c_Shape_getType(void* pThis) 
     429{return ((Shape*)pThis)->getTypeAsInt();} 
     430 
    425431void c_Shape_markRubyGC(void* pThis) 
    426432{((Shape*)pThis)->markRubyGC();} 
  • lang/ruby/RubyESRIShape/Shape.h

    r2062 r2076  
    1616 
    1717typedef long ESInt32; 
     18typedef short ESInt16; 
    1819typedef unsigned long ESUInt32; 
    1920typedef double ESDouble; // MSVC 
     
    5758} SHPFileHeader; 
    5859 
    59  
    6060typedef struct _SHPRecordHeader { 
    6161        ESInt32 index; 
     
    8484        VALUE getRecordAt(int index); 
    8585        int getLength() const; 
     86        int getTypeAsInt() const; 
    8687        void markRubyGC(); 
    8788 
     
    144145int   c_Shape_getLength(void* pThis); 
    145146void  c_Shape_markRubyGC(void* pThis); 
     147int   c_Shape_getType(void* pThis); 
    146148 
    147149void  c_Polygon_delete(void* pThis);