| | 48 | function test_Format_GML_read_linestring_geom(t) { |
|---|
| | 49 | t.plan(5); |
|---|
| | 50 | |
|---|
| | 51 | var line = shell_start + geoms['linestring'] + shell_end; |
|---|
| | 52 | var parser = new OpenLayers.Format.GML(); |
|---|
| | 53 | data = parser.read(line); |
|---|
| | 54 | t.eq(data[0].geometry.CLASS_NAME, "OpenLayers.Geometry.LineString", "LineString GML returns correct classname"); |
|---|
| | 55 | t.eq(data[0].geometry.components[0].x, 1, "first x coord correct"); |
|---|
| | 56 | t.eq(data[0].geometry.components[0].y, 2, "first y coord correct"); |
|---|
| | 57 | t.eq(data[0].geometry.components[1].x, 4, "second x coord correct"); |
|---|
| | 58 | t.eq(data[0].geometry.components[1].y, 5, "second y coord correct"); |
|---|
| | 59 | } |
|---|
| | 60 | function test_Format_GML_read_polygon_geom(t) { |
|---|
| | 61 | t.plan(7); |
|---|
| | 62 | |
|---|
| | 63 | var polygon = shell_start + geoms['polygon'] + shell_end; |
|---|
| | 64 | var parser = new OpenLayers.Format.GML(); |
|---|
| | 65 | data = parser.read(polygon); |
|---|
| | 66 | t.eq(data[0].geometry.CLASS_NAME, "OpenLayers.Geometry.Polygon", "Polygon GML returns correct classname"); |
|---|
| | 67 | t.eq(data[0].geometry.components[0].components[0].x, 1, "first x coord correct"); |
|---|
| | 68 | t.eq(data[0].geometry.components[0].components[0].y, 2, "first y coord correct"); |
|---|
| | 69 | t.eq(data[0].geometry.components[0].components[1].x, 4, "second x coord correct"); |
|---|
| | 70 | t.eq(data[0].geometry.components[0].components[1].y, 5, "second y coord correct"); |
|---|
| | 71 | t.eq(data[0].geometry.components[0].components.length, 4, "coords length correct"); |
|---|
| | 72 | t.eq(data[0].geometry.components.length, 1, "rings length correct"); |
|---|
| | 73 | } |
|---|
| | 74 | function test_Format_GML_read_multipoint_geom(t) { |
|---|
| | 75 | t.plan(1); |
|---|
| | 76 | |
|---|
| | 77 | var multipoint = shell_start + geoms['multipoint'] + shell_end; |
|---|
| | 78 | var parser = new OpenLayers.Format.GML(); |
|---|
| | 79 | data = parser.read(multipoint); |
|---|
| | 80 | console.log(data); |
|---|
| | 81 | t.eq(data[0].geometry.CLASS_NAME, "OpenLayers.Geometry.MultiPoint", "MultiPoint GML returns correct classname (GML was: " + multipoint + ")"); |
|---|
| | 82 | /* t.eq(data[0].geometry.components[0].x, 1, "x coord correct"); |
|---|
| | 83 | t.eq(data[0].geometry.components[0].y, 2, "y coord correct"); |
|---|
| | 84 | t.eq(data[0].geometry.components.length, 2, "length correct"); |
|---|
| | 85 | t.eq(data[0].geometry.components[1].x, 4, "x coord correct"); |
|---|
| | 86 | t.eq(data[0].geometry.components[1].y, 5, "y coord correct"); |
|---|
| | 87 | */ |
|---|
| | 88 | } |
|---|
| | 89 | function test_Format_GML_read_multilinestring_geom(t) { |
|---|
| | 90 | t.plan(1); |
|---|
| | 91 | |
|---|
| | 92 | var multilinestring = shell_start + geoms['multipoint'] + shell_end; |
|---|
| | 93 | var parser = new OpenLayers.Format.GML(); |
|---|
| | 94 | data = parser.read(multilinestring); |
|---|
| | 95 | t.eq(data[0].geometry.CLASS_NAME, "OpenLayers.Geometry.MultiLineString", "MultiLineString GML returns correct classname (GML was: " + multilinestring + ")"); |
|---|
| | 96 | /* t.eq(data[0].geometry.components[0].x, 1, "x coord correct"); |
|---|
| | 97 | t.eq(data[0].geometry.components[0].y, 2, "y coord correct"); |
|---|
| | 98 | t.eq(data[0].geometry.components.length, 2, "length correct"); |
|---|
| | 99 | t.eq(data[0].geometry.components[1].x, 4, "x coord correct"); |
|---|
| | 100 | t.eq(data[0].geometry.components[1].y, 5, "y coord correct"); |
|---|
| | 101 | */ |
|---|
| | 102 | } |
|---|
| | 103 | /* |
|---|
| | 104 | function test_Format_GML_read_polygon_with_holes_geom(t) { |
|---|
| | 105 | t.plan(5); |
|---|
| | 106 | |
|---|
| | 107 | var polygon_with_holes = shell_start + geoms['polygon_with_holes'] + shell_end; |
|---|
| | 108 | console.log(polygon_with_holes); |
|---|
| | 109 | var parser = new OpenLayers.Format.GML(); |
|---|
| | 110 | data = parser.read(polygon_with_holes); |
|---|
| | 111 | console.log(data[0].geometry); |
|---|
| | 112 | t.eq(data[0].geometry.CLASS_NAME, "OpenLayers.Geometry.Polygon", "Polygon GML returns correct classname"); |
|---|
| | 113 | t.eq(data[0].geometry.components[0].components[0].x, 1, "first x coord correct"); |
|---|
| | 114 | t.eq(data[0].geometry.components[0].components[0].y, 2, "first y coord correct"); |
|---|
| | 115 | t.eq(data[0].geometry.components[0].components[1].x, 4, "second x coord correct"); |
|---|
| | 116 | t.eq(data[0].geometry.components[0].components[1].y, 5, "second y coord correct"); |
|---|
| | 117 | t.eq(data[0].geometry.components[0].components.length, 4, "coords length correct"); |
|---|
| | 118 | t.eq(data[0].geometry.components[1].components[0].x, 11, "first x coord correct"); |
|---|
| | 119 | t.eq(data[0].geometry.components[1].components[0].y, 12, "first y coord correct"); |
|---|
| | 120 | t.eq(data[0].geometry.components[1].components[1].x, 14, "second x coord correct"); |
|---|
| | 121 | t.eq(data[0].geometry.components[1].components[1].y, 15, "second y coord correct"); |
|---|
| | 122 | t.eq(data[0].geometry.components[1].components.length, 4, "coords length correct"); |
|---|
| | 123 | t.eq(data[0].geometry.components.length, 2, "rings length correct"); |
|---|
| | 124 | } */ |
|---|
| 72 | | '</wfs:FeatureCollection>'] |
|---|
| | 158 | '</wfs:FeatureCollection>' |
|---|
| | 159 | ] |
|---|
| | 160 | |
|---|
| | 161 | var shell_start = '<wfs:FeatureCollection' + |
|---|
| | 162 | ' xmlns:fs="http://example.com/featureserver"' + |
|---|
| | 163 | ' xmlns:wfs="http://www.opengis.net/wfs"' + |
|---|
| | 164 | ' xmlns:gml="http://www.opengis.net/gml"' + |
|---|
| | 165 | ' xmlns:ogc="http://www.opengis.net/ogc"' + |
|---|
| | 166 | ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' + |
|---|
| | 167 | ' xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengeospatial.net//wfs/1.0.0/WFS-basic.xsd">' + |
|---|
| | 168 | ' ' + |
|---|
| | 169 | '' + |
|---|
| | 170 | ' <gml:featureMember>' + |
|---|
| | 171 | ' \n<fs:scribble fid="221">' + |
|---|
| | 172 | ' <fs:geometry>'; |
|---|
| | 173 | var shell_end = ' </fs:geometry> </fs:scribble></gml:featureMember>' + |
|---|
| | 174 | '</wfs:FeatureCollection>'; |
|---|
| | 175 | var geoms = { |
|---|
| | 176 | 'point':'<gml:Point><gml:coordinates>1,2,3</gml:coordinates></gml:Point>', |
|---|
| | 177 | 'linestring':'<gml:LineString><gml:coordinates>4,2,3 4,5,6</gml:coordinates></gml:LineString>', |
|---|
| | 178 | 'polygon':'<gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>1,2 4,5 3,6 1,2</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon>', |
|---|
| | 179 | //'polygon_with_holes':'<gml:Polygon><gml:outerBoundaryIs>1,2 4,5 3,6 1,2</gml:outerBoundaryIs><gml:innerBoundaryIs>11,12 14,15 13,16 11,12</gml:innerBoundaryIs></gml:Polygon>', |
|---|
| | 180 | 'multipoint':'<gml:MultiPoint><gml:Point><gml:coordinates>1,2,3</gml:coordinates></gml:Point><gml:Point><gml:coordinates>4,5,6</gml:coordinates></gml:Point></gml:MultiPoint>', |
|---|
| | 181 | 'multilinestring':'<gml:MultiLineString><gml:LineString><gml:coordinates>1,2,3 4,5,6</gml:coordinates></gml:LineString><gml:LineString><gml:coordinates>11,12,13 14,15,16</gml:coordinates></gml:LineString></gml:MultiLineString>' // , |
|---|
| | 182 | // 'multipolygon_with_holes': '<gml:MultiPolygon><gml:Polygon><gml:outerBoundaryIs>1,2 4,5 3,6 1,2</gml:outerBoundaryIs><gml:innerBoundaryIs>11,12 14,15 13,16 11,12</gml:innerBoundaryIs></gml:Polygon><gml:Polygon><gml:outerBoundaryIs>101,102 104,105 103,106 101,102</gml:outerBoundaryIs><gml:innerBoundaryIs>111,112 114,115 113,116 111,112</gml:innerBoundaryIs></gml:Polygon></gml:MultiPolygon>' |
|---|
| | 183 | } |
|---|