1
0
mirror of https://github.com/wavded/js-shapefile-to-geojson synced 2024-11-23 14:34:54 +00:00

fix a problem of precision loss.

the previous code on reading floating point number will cause a precision loss on centimeters, found it when using.
This commit is contained in:
田至伟 2016-11-22 23:38:59 +08:00 committed by GitHub
parent 6ee60833bc
commit 24467d76fd

View File

@ -131,16 +131,13 @@ var win = self,
t = this, t = this,
val = 0.0; val = 0.0;
if(numBytes > 4){ if(numBytes > 4){
var i = Math.ceil(numBytes / 4); var buff=[]
while(i--){ var o = t.offset,
var buff = [], j = o + numBytes;
o = t.offset, while(j > o){
j = o + (numBytes >= 4 ? 4 : numBytes % 4); buff.push(t.readByteAt(--j));
while(j > o){ numBytes--;
buff.push(t.readByteAt(--j)); t.offset++;
numBytes--;
t.offset++;
}
} }
var s = new Gordon.Stream(fromCharCode.apply(String, buff)), var s = new Gordon.Stream(fromCharCode.apply(String, buff)),
sign = s.readUB(1), sign = s.readUB(1),