options.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import * as interpolate from './interpolation';
  2. function Options() {
  3. /* Settings common to all implemented algorithms */
  4. this.successCallback = null;
  5. this.verbose = false;
  6. this.polygons = false;
  7. this.polygons_full = false;
  8. this.linearRing = true;
  9. this.noQuadTree = false;
  10. this.noFrame = false;
  11. }
  12. /* Compose settings specific to IsoBands algorithm */
  13. function isoBandOptions(userSettings) {
  14. var i,
  15. key,
  16. val,
  17. bandOptions,
  18. optionKeys;
  19. bandOptions = new Options();
  20. userSettings = userSettings ? userSettings : {};
  21. optionKeys = Object.keys(bandOptions);
  22. for(i = 0; i < optionKeys.length; i++) {
  23. key = optionKeys[i];
  24. val = userSettings[key];
  25. if ((typeof val !== 'undefined') && (val !== null))
  26. bandOptions[key] = val;
  27. }
  28. /* restore compatibility */
  29. bandOptions.polygons_full = !bandOptions.polygons;
  30. /* add interpolation functions (not yet user customizable) */
  31. bandOptions.interpolate = interpolate.linear_ab;
  32. bandOptions.interpolate_a = interpolate.linear_a;
  33. bandOptions.interpolate_b = interpolate.linear_b;
  34. return bandOptions;
  35. }
  36. /* Compose settings specific to IsoLines algorithm */
  37. function isoLineOptions(userSettings) {
  38. var i,
  39. key,
  40. val,
  41. lineOptions,
  42. optionKeys;
  43. lineOptions = new Options();
  44. userSettings = userSettings ? userSettings : {};
  45. optionKeys = Object.keys(lineOptions);
  46. for(i = 0; i < optionKeys.length; i++) {
  47. key = optionKeys[i];
  48. val = userSettings[key];
  49. if ((typeof val !== 'undefined') && (val !== null))
  50. lineOptions[key] = val;
  51. }
  52. /* restore compatibility */
  53. lineOptions.polygons_full = !lineOptions.polygons;
  54. /* add interpolation functions (not yet user customizable) */
  55. lineOptions.interpolate = interpolate.linear;
  56. return lineOptions;
  57. }
  58. export {
  59. isoBandOptions,
  60. isoLineOptions
  61. };