FROM : John Stiles
DATE : Fri Oct 15 19:30:06 2004
For every different type, you need a different swap function. You use
SwapLittleLong on little-endian longs; you use SwapLittleDouble on
little-endian doubles.
http://developer.apple.com/documentation/Cocoa/Reference/Foundation/
ObjC_classic/Functions/FoundationFunctions.html#//apple_ref/doc/uid/
20000055/BCICIDIA
On Oct 15, 2004, at 9:21 AM, Peter Schols wrote:
> Hi,
>
> I'm trying to read the header of a shape (.shp) file (containing
> geographical information). This works as expected for reading an
> integer, but it does not work for reading a double. The data is in
> little endian format. Any ideas what's going on here?
>
> The .shp file is available upon request.
>
> Thanks!
>
> Peter
>
> Peter Schols
> Laboratory of Plant Systematics - K.U.Leuven
> Belgium
>
> ---
>
> - (IBAction)read:(id)sender;
> {
> NSFileHandle *file;
> int type;
> double number;
>
> file = [NSFileHandle
> fileHandleForReadingAtPath:@"/Users/mac/Desktop/st12_d00_shp/
> st12_d00.shp"];
> [file readDataOfLength:32];
>
> [[file readDataOfLength:4] getBytes:&type];
> type = NSSwapLittleLongToHost(type);
> NSLog(@"Type: %d", type); // The type is correctly reported as
> being 5
>
> [[file readDataOfLength:8] getBytes:&number];
> number = NSSwapLittleLongToHost(number);
> NSLog(@"Number: %lf", number); // The Number is reported as
> being 0.00000 which is not the case
> }
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (<email_removed>)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>
DATE : Fri Oct 15 19:30:06 2004
For every different type, you need a different swap function. You use
SwapLittleLong on little-endian longs; you use SwapLittleDouble on
little-endian doubles.
http://developer.apple.com/documentation/Cocoa/Reference/Foundation/
ObjC_classic/Functions/FoundationFunctions.html#//apple_ref/doc/uid/
20000055/BCICIDIA
On Oct 15, 2004, at 9:21 AM, Peter Schols wrote:
> Hi,
>
> I'm trying to read the header of a shape (.shp) file (containing
> geographical information). This works as expected for reading an
> integer, but it does not work for reading a double. The data is in
> little endian format. Any ideas what's going on here?
>
> The .shp file is available upon request.
>
> Thanks!
>
> Peter
>
> Peter Schols
> Laboratory of Plant Systematics - K.U.Leuven
> Belgium
>
> ---
>
> - (IBAction)read:(id)sender;
> {
> NSFileHandle *file;
> int type;
> double number;
>
> file = [NSFileHandle
> fileHandleForReadingAtPath:@"/Users/mac/Desktop/st12_d00_shp/
> st12_d00.shp"];
> [file readDataOfLength:32];
>
> [[file readDataOfLength:4] getBytes:&type];
> type = NSSwapLittleLongToHost(type);
> NSLog(@"Type: %d", type); // The type is correctly reported as
> being 5
>
> [[file readDataOfLength:8] getBytes:&number];
> number = NSSwapLittleLongToHost(number);
> NSLog(@"Number: %lf", number); // The Number is reported as
> being 0.00000 which is not the case
> }
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (<email_removed>)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>
| Related mails | Author | Date |
|---|---|---|
| Peter Schols | Oct 15, 18:21 | |
| Robert Tillyard | Oct 15, 18:39 | |
| John Stiles | Oct 15, 19:30 | |
| Ricky Sharp | Oct 15, 19:30 |






Cocoa mail archive

