MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / constructor

Method constructor

src/common/format/WKT.js:27–278  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

25export class WKT extends Format {
26
27 constructor(options) {
28 super(options);
29 this.regExes = {
30 'typeStr': /^\s*(\w+)\s*\(\s*(.*)\s*\)\s*$/,
31 'spaces': /\s+/,
32 'parenComma': /\)\s*,\s*\(/,
33 'doubleParenComma': /\)\s*\)\s*,\s*\(\s*\(/, // can't use {2} here
34 'trimParens': /^\s*\(?(.*?)\)?\s*$/
35 };
36 this.CLASS_NAME = "SuperMap.Format.WKT"; /**
37 * @private
38 * @description Object with properties corresponding to the geometry types.
39 * Property values are functions that do the actual data extraction.
40 */
41 this.extract = {
42 /**
43 * @description Return a space delimited string of point coordinates.
44 * @param {GeometryPoint} point
45 * @returns {string} A string of coordinates representing the point
46 */
47 'point': function (point) {
48 return point.x + ' ' + point.y;
49 },
50
51 /**
52 * @description Return a comma delimited string of point coordinates from a multipoint.
53 * @param {GeometryMultiPoint} multipoint
54 * @returns {string} A string of point coordinate strings representing
55 * the multipoint
56 */
57 'multipoint'(multipoint) {
58 var array = [];
59 for (var i = 0, len = multipoint.components.length; i < len; ++i) {
60 array.push('(' +
61 this.extract.point.apply(this, [multipoint.components[i]]) +
62 ')');
63 }
64 return array.join(',');
65 },
66
67 /**
68 * @description Return a comma delimited string of point coordinates from a line.
69 * @param {GeometryLineString} linestring
70 * @returns {string} A string of point coordinate strings representing
71 * the linestring
72 */
73 'linestring'(linestring) {
74 var array = [];
75 for (var i = 0, len = linestring.components.length; i < len; ++i) {
76 array.push(this.extract.point.apply(this, [linestring.components[i]]));
77 }
78 return array.join(',');
79 },
80
81 /**
82 * @description Return a comma delimited string of linestring strings from a multilinestring.
83 * @param {GeometryMultiLineString} multilinestring
84 * @returns {string} A string of of linestring strings representing

Callers

nothing calls this directly

Calls 3

readMethod · 0.95
trimMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected