Is there a way that OpenLayers.Format.JSON write() method to serialize coordinates using 6 decimals only ?
Example: instead of http://pastie.org/4200997 to have http://pastie.org/4200994
|
Is there a way that OpenLayers.Format.JSON write() method to serialize coordinates using 6 decimals only ? Example: instead of http://pastie.org/4200997 to have http://pastie.org/4200994 |
|||
|
|
|
OpenLayers geometries use 14 significant digits, and the GeoJSON writer simply extracts geometry coordinates using the same number of significant digits:
If you want to limit the number of digits in the GeoJSON writer, you'd need to replace the function to extract points, by putting the following lines in your code:
Note this creates string coordinates rather than floats which may cause problems, so you can check out other options to round floats at http://stackoverflow.com/questions/661562/how-to-format-a-float-in-javascript However you may want to consider why you want to reduce the accuracy of the GeoJSON. Is this to format display to a user? If this is the case the GeoJSON should be left alone, and the rounding of the numbers left to the user interface. It is also not going to save any noticeable network traffic. |
|||
|
|
|
write your own method for your json type:
i hope it helps you... |
|||
|
|