GeoJSON should parse and serialize GeometryCollections as a Geometry.Collection
object. (Closes #1067) git-svn-id: http://svn.openlayers.org/trunk/openlayers@5435 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -0,0 +1,66 @@
|
|||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
<style type="text/css">
|
||||||
|
#map {
|
||||||
|
width: 800px;
|
||||||
|
height: 475px;
|
||||||
|
border: 1px solid black;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script src="../lib/OpenLayers.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var lon = 5;
|
||||||
|
var lat = 40;
|
||||||
|
var zoom = 5;
|
||||||
|
var map, layer;
|
||||||
|
|
||||||
|
function init(){
|
||||||
|
map = new OpenLayers.Map( 'map' );
|
||||||
|
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
|
||||||
|
"http://labs.metacarta.com/wms/vmap0",
|
||||||
|
{layers: 'basic'} );
|
||||||
|
map.addLayer(layer);
|
||||||
|
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
|
||||||
|
var featurecollection = {
|
||||||
|
"type": "FeatureCollection",
|
||||||
|
"features": [
|
||||||
|
{"geometry": {
|
||||||
|
"type": "GeometryCollection",
|
||||||
|
"geometries": [
|
||||||
|
{
|
||||||
|
"type": "LineString",
|
||||||
|
"coordinates":
|
||||||
|
[[11.0878902207, 45.1602390564],
|
||||||
|
[15.01953125, 48.1298828125]]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Polygon",
|
||||||
|
"coordinates":
|
||||||
|
[[[11.0878902207, 45.1602390564],
|
||||||
|
[14.931640625, 40.9228515625],
|
||||||
|
[0.8251953125, 41.0986328125],
|
||||||
|
[7.63671875, 48.96484375],
|
||||||
|
[11.0878902207, 45.1602390564]]]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type":"Point",
|
||||||
|
"coordinates":[15.87646484375, 44.1748046875]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"type": "Feature",
|
||||||
|
"properties": {}}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
var geojson_format = new OpenLayers.Format.GeoJSON();
|
||||||
|
var vector_layer = new OpenLayers.Layer.Vector();
|
||||||
|
map.addLayer(vector_layer);
|
||||||
|
vector_layer.addFeatures(geojson_format.read(featurecollection));
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body onload="init()">
|
||||||
|
<div id="map"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -40,9 +40,9 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, {
|
|||||||
* Parameters:
|
* Parameters:
|
||||||
* json - {String} A GeoJSON string
|
* json - {String} A GeoJSON string
|
||||||
* type - {String} Optional string that determines the structure of
|
* type - {String} Optional string that determines the structure of
|
||||||
* the output. Supported values are "Geometry", "Feature",
|
* the output. Supported values are "Geometry", "Feature", and
|
||||||
* "GeometryCollection", and "FeatureCollection". If absent or null,
|
* "FeatureCollection". If absent or null, a default of
|
||||||
* a default of "FeatureCollection" is assumed.
|
* "FeatureCollection" is assumed.
|
||||||
* filter - {Function} A function which will be called for every key and
|
* filter - {Function} A function which will be called for every key and
|
||||||
* value at every level of the final result. Each value will be
|
* value at every level of the final result. Each value will be
|
||||||
* replaced by the result of the filter function. This can be used to
|
* replaced by the result of the filter function. This can be used to
|
||||||
@@ -56,9 +56,7 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, {
|
|||||||
* must represent a single geometry, and the return will be an
|
* must represent a single geometry, and the return will be an
|
||||||
* <OpenLayers.Geometry>. If type is "Feature", the input json must
|
* <OpenLayers.Geometry>. If type is "Feature", the input json must
|
||||||
* represent a single feature, and the return will be an
|
* represent a single feature, and the return will be an
|
||||||
* <OpenLayers.Feature.Vector>. If type is "GeometryCollection", the
|
* <OpenLayers.Feature.Vector>.
|
||||||
* input json must represent a geometry collection, and the return will
|
|
||||||
* be an array of <OpenLayers.Geometry>.
|
|
||||||
*/
|
*/
|
||||||
read: function(json, type, filter) {
|
read: function(json, type, filter) {
|
||||||
type = (type) ? type : "FeatureCollection";
|
type = (type) ? type : "FeatureCollection";
|
||||||
@@ -91,17 +89,6 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, {
|
|||||||
OpenLayers.Console.error(err);
|
OpenLayers.Console.error(err);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "GeometryCollection":
|
|
||||||
results = [];
|
|
||||||
for(var i=0; i<obj.geometries.length; ++i) {
|
|
||||||
try {
|
|
||||||
results.push(this.parseGeometry(obj.geometries[i]));
|
|
||||||
} catch(err) {
|
|
||||||
results = null;
|
|
||||||
OpenLayers.Console.error(err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "FeatureCollection":
|
case "FeatureCollection":
|
||||||
// for type FeatureCollection, we allow input to be any type
|
// for type FeatureCollection, we allow input to be any type
|
||||||
results = [];
|
results = [];
|
||||||
@@ -124,17 +111,6 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "GeometryCollection":
|
|
||||||
for(var i=0; i<obj.geometries.length; ++i) {
|
|
||||||
try {
|
|
||||||
var geom = this.parseGeometry(obj.geometries[i]);
|
|
||||||
results.push(new OpenLayers.Feature.Vector(geom));
|
|
||||||
} catch(err) {
|
|
||||||
results = null;
|
|
||||||
OpenLayers.Console.error(err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
try {
|
try {
|
||||||
var geom = this.parseGeometry(obj);
|
var geom = this.parseGeometry(obj);
|
||||||
@@ -161,9 +137,10 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, {
|
|||||||
var valid = false;
|
var valid = false;
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case "Geometry":
|
case "Geometry":
|
||||||
if(OpenLayers.Util.indexOf(["Point", "MultiPoint", "LineString",
|
if(OpenLayers.Util.indexOf(
|
||||||
"MultiLineString", "Polygon",
|
["Point", "MultiPoint", "LineString", "MultiLineString",
|
||||||
"MultiPolygon", "Box"], obj.type) == -1) {
|
"Polygon", "MultiPolygon", "Box", "GeometryCollection"],
|
||||||
|
obj.type) == -1) {
|
||||||
// unsupported geometry type
|
// unsupported geometry type
|
||||||
OpenLayers.Console.error("Unsupported geometry type: " +
|
OpenLayers.Console.error("Unsupported geometry type: " +
|
||||||
obj.type);
|
obj.type);
|
||||||
@@ -176,7 +153,7 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, {
|
|||||||
valid = true;
|
valid = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// for GeometryCollection and Feature, types must match
|
// for Feature types must match
|
||||||
if(obj.type == type) {
|
if(obj.type == type) {
|
||||||
valid = true;
|
valid = true;
|
||||||
} else {
|
} else {
|
||||||
@@ -226,17 +203,33 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, {
|
|||||||
*/
|
*/
|
||||||
parseGeometry: function(obj) {
|
parseGeometry: function(obj) {
|
||||||
var geometry;
|
var geometry;
|
||||||
if(!(obj.coordinates instanceof Array)) {
|
if(obj.type == "GeometryCollection") {
|
||||||
throw "Geometry must have coordinates array: " + obj;
|
if(!(obj.geometries instanceof Array)) {
|
||||||
}
|
throw "GeometryCollection must have geometries array: " + obj;
|
||||||
if(!this.parseCoords[obj.type.toLowerCase()]) {
|
}
|
||||||
throw "Unsupported geometry type: " + obj.type;
|
var numGeom = obj.geometries.length;
|
||||||
}
|
var components = new Array(numGeom);
|
||||||
try {
|
for(var i=0; i<numGeom; ++i) {
|
||||||
geometry = this.parseCoords[obj.type.toLowerCase()].apply(this, [obj.coordinates]);
|
components[i] = this.parseGeometry.apply(
|
||||||
} catch(err) {
|
this, [obj.geometries[i]]
|
||||||
// deal with bad coordinates
|
);
|
||||||
throw err;
|
}
|
||||||
|
geometry = new OpenLayers.Geometry.Collection(components);
|
||||||
|
} else {
|
||||||
|
if(!(obj.coordinates instanceof Array)) {
|
||||||
|
throw "Geometry must have coordinates array: " + obj;
|
||||||
|
}
|
||||||
|
if(!this.parseCoords[obj.type.toLowerCase()]) {
|
||||||
|
throw "Unsupported geometry type: " + obj.type;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
geometry = this.parseCoords[obj.type.toLowerCase()].apply(
|
||||||
|
this, [obj.coordinates]
|
||||||
|
);
|
||||||
|
} catch(err) {
|
||||||
|
// deal with bad coordinates
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return geometry;
|
return geometry;
|
||||||
},
|
},
|
||||||
@@ -418,53 +411,38 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* APIMethod: write
|
* APIMethod: write
|
||||||
* Serialize a feature, geometry, array of features, or array of geometries
|
* Serialize a feature, geometry, array of features into a GeoJSON string.
|
||||||
* into a GeoJSON string.
|
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* obj - {Object} An <OpenLayers.Feature.Vector>, <OpenLayers.Geometry>,
|
* obj - {Object} An <OpenLayers.Feature.Vector>, <OpenLayers.Geometry>,
|
||||||
* or an array of either features or geometries.
|
* or an array of features.
|
||||||
* pretty - {Boolean} Structure the output with newlines and indentation.
|
* pretty - {Boolean} Structure the output with newlines and indentation.
|
||||||
* Default is false.
|
* Default is false.
|
||||||
*
|
*
|
||||||
* Returns:
|
* Returns:
|
||||||
* {String} The GeoJSON string representation of the input geometry,
|
* {String} The GeoJSON string representation of the input geometry,
|
||||||
* features, array of geometries, or array of features.
|
* features, or array of features.
|
||||||
*/
|
*/
|
||||||
write: function(obj, pretty) {
|
write: function(obj, pretty) {
|
||||||
var geojson = {
|
var geojson = {
|
||||||
"type": null
|
"type": null
|
||||||
};
|
};
|
||||||
if(obj instanceof Array) {
|
if(obj instanceof Array) {
|
||||||
if(obj[0] instanceof OpenLayers.Feature.Vector) {
|
geojson.type = "FeatureCollection";
|
||||||
geojson.features = [];
|
var numFeatures = obj.length;
|
||||||
} else if (obj[0].CLASS_NAME.search("OpenLayers.Geometry") == 0) {
|
geojson.features = new Array(numFeatures);
|
||||||
geojson.geometries = [];
|
for(var i=0; i<numFeatures; ++i) {
|
||||||
}
|
|
||||||
for(var i=0; i<obj.length; ++i) {
|
|
||||||
var element = obj[i];
|
var element = obj[i];
|
||||||
if(element instanceof OpenLayers.Feature.Vector) {
|
if(!element instanceof OpenLayers.Feature.Vector) {
|
||||||
if(geojson.type == null) {
|
var msg = "FeatureCollection only supports collections " +
|
||||||
geojson.type = "FeatureCollection";
|
"of features: " + element;
|
||||||
if(element.layer && element.layer.projection) {
|
throw msg;
|
||||||
geojson.crs = this.createCRSObject(element);
|
|
||||||
}
|
|
||||||
} else if(geojson.type != "FeatureCollection") {
|
|
||||||
OpenLayers.Console.error("FeatureCollection only supports collections of features: " + element);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
geojson.features.push(this.extract.feature.apply(this, [element]));
|
|
||||||
} else if (element.CLASS_NAME.search("OpenLayers.Geometry") == 0) {
|
|
||||||
if(geojson.type == null) {
|
|
||||||
geojson.type = "GeometryCollection";
|
|
||||||
} else if(geojson.type != "GeometryCollection") {
|
|
||||||
OpenLayers.Console.error("GeometryCollection only supports collections of geometries: " + element);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
geojson.geometries.push(this.extract.geometry.apply(this, [element]));
|
|
||||||
}
|
}
|
||||||
|
geojson.features[i] = this.extract.feature.apply(
|
||||||
|
this, [element]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else if (obj.CLASS_NAME.search("OpenLayers.Geometry") == 0) {
|
} else if (obj.CLASS_NAME.indexOf("OpenLayers.Geometry") == 0) {
|
||||||
geojson = this.extract.geometry.apply(this, [obj]);
|
geojson = this.extract.geometry.apply(this, [obj]);
|
||||||
} else if (obj instanceof OpenLayers.Feature.Vector) {
|
} else if (obj instanceof OpenLayers.Feature.Vector) {
|
||||||
geojson = this.extract.feature.apply(this, [obj]);
|
geojson = this.extract.feature.apply(this, [obj]);
|
||||||
@@ -550,14 +528,24 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, {
|
|||||||
'geometry': function(geometry) {
|
'geometry': function(geometry) {
|
||||||
var geometryType = geometry.CLASS_NAME.split('.')[2];
|
var geometryType = geometry.CLASS_NAME.split('.')[2];
|
||||||
var data = this.extract[geometryType.toLowerCase()].apply(this, [geometry]);
|
var data = this.extract[geometryType.toLowerCase()].apply(this, [geometry]);
|
||||||
return {
|
var json;
|
||||||
"type": geometryType,
|
if(geometryType == "Collection") {
|
||||||
"coordinates": data
|
json = {
|
||||||
};
|
"type": "GeometryCollection",
|
||||||
|
"geometries": data
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
json = {
|
||||||
|
"type": geometryType,
|
||||||
|
"coordinates": data
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return json;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: extract.poin
|
* Method: extract.point
|
||||||
* Return an array of coordinates from a point.
|
* Return an array of coordinates from a point.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
@@ -662,7 +650,30 @@ OpenLayers.Format.GeoJSON = OpenLayers.Class(OpenLayers.Format.JSON, {
|
|||||||
array.push(this.extract.polygon.apply(this, [multipolygon.components[i]]));
|
array.push(this.extract.polygon.apply(this, [multipolygon.components[i]]));
|
||||||
}
|
}
|
||||||
return array;
|
return array;
|
||||||
}
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: extract.collection
|
||||||
|
* Return an array of geometries from a geometry collection.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* collection - {<OpenLayers.Geometry.Collection>}
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* {Array} An array of geometry objects representing the geometry
|
||||||
|
* collection.
|
||||||
|
*/
|
||||||
|
'collection': function(collection) {
|
||||||
|
var len = collection.components.length;
|
||||||
|
var array = new Array(len);
|
||||||
|
for(var i=0; i<len; ++i) {
|
||||||
|
array[i] = this.extract.geometry.apply(
|
||||||
|
this, [collection.components[i]]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return array;
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -22,10 +22,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_Format_GeoJSON_valid_type(t) {
|
function test_Format_GeoJSON_valid_type(t) {
|
||||||
t.plan(13);
|
t.plan(14);
|
||||||
|
|
||||||
OpenLayers.Console.error = function(error) { window.global_error = error; }
|
OpenLayers.Console.error = function(error) { window.global_error = error; }
|
||||||
var types = ["Point", "MultiPoint", "LineString", "MultiLineString", "Polygon", "MultiPolygon", "Box"];
|
var types = ["Point", "MultiPoint", "LineString", "MultiLineString", "Polygon", "MultiPolygon", "Box", "GeometryCollection"];
|
||||||
for (var i = 0; i < types.length; i++) {
|
for (var i = 0; i < types.length; i++) {
|
||||||
t.ok(parser.isValidType({'type':types[i]}, "Geometry"), "Geometry with type " + types[i] + " is valid");
|
t.ok(parser.isValidType({'type':types[i]}, "Geometry"), "Geometry with type " + types[i] + " is valid");
|
||||||
}
|
}
|
||||||
@@ -140,8 +140,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This test is from the geom_collection example on geojson spec.
|
// This test is from the geom_collection example on geojson spec.
|
||||||
function test_Format_GeoJSON_geom_collection(t) {
|
function test_Format_GeoJSON_collection(t) {
|
||||||
t.plan(7);
|
t.plan(10);
|
||||||
|
|
||||||
var geomcol = {
|
var geomcol = {
|
||||||
"type": "GeometryCollection",
|
"type": "GeometryCollection",
|
||||||
@@ -158,17 +158,57 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
data = parser.read(geomcol, "GeometryCollection");
|
data = parser.read(geomcol, "Geometry");
|
||||||
t.eq(data[0].CLASS_NAME,
|
t.eq(data.CLASS_NAME, "OpenLayers.Geometry.Collection",
|
||||||
"OpenLayers.Geometry.Point", "First geom in geom collection is point type");
|
"GeometryCollection deserialized into geometry.collection");
|
||||||
t.eq(data[0].x, 100, "First geom in geom collection has correct x");
|
t.eq(data.components[0].CLASS_NAME, "OpenLayers.Geometry.Point",
|
||||||
t.eq(data[0].y, 0, "First geom in geom collection has correct x");
|
"First geom is correct type");
|
||||||
|
t.eq(data.components[0].x, 100,
|
||||||
|
"First geom in geom collection has correct x");
|
||||||
|
t.eq(data.components[0].y, 0,
|
||||||
|
"First geom in geom collection has correct x");
|
||||||
|
|
||||||
t.eq(data[1].CLASS_NAME,
|
t.eq(data.components[1].CLASS_NAME, "OpenLayers.Geometry.LineString",
|
||||||
"OpenLayers.Geometry.LineString", "Second geom in geom collection is point linestring");
|
"Second geom in geom collection is point linestring");
|
||||||
t.eq(data[1].components.length, 2, "linestring is correct length");
|
t.eq(data.components[1].components.length, 2,
|
||||||
t.eq(data[1].components[1].x, 102, "linestring is correct x end");
|
"linestring is correct length");
|
||||||
t.eq(data[1].components[1].y, 1, "linestring is correct y end");
|
t.eq(data.components[1].components[1].x, 102,
|
||||||
|
"linestring is correct x end");
|
||||||
|
t.eq(data.components[1].components[1].y, 1,
|
||||||
|
"linestring is correct y end");
|
||||||
|
|
||||||
|
data = parser.read(geomcol, "FeatureCollection");
|
||||||
|
t.eq(data[0].CLASS_NAME, "OpenLayers.Feature.Vector",
|
||||||
|
"GeometryCollection can be read in as a feature collection");
|
||||||
|
t.eq(data[0].geometry.CLASS_NAME, "OpenLayers.Geometry.Collection",
|
||||||
|
"feature contains the correct geometry type");
|
||||||
|
var feature = {
|
||||||
|
"type": "Feature",
|
||||||
|
"geometry": {
|
||||||
|
"type": "GeometryCollection",
|
||||||
|
"geometries": [
|
||||||
|
{
|
||||||
|
"type": "Point",
|
||||||
|
"coordinates": [100.0, 0.0]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "LineString",
|
||||||
|
"coordinates": [
|
||||||
|
[101.0, 0.0], [102.0, 1.0]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"prop0": "value0",
|
||||||
|
"prop1": "value1"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
data = parser.read(feature);
|
||||||
|
t.eq(data.geometry.CLASS_NAME, "OpenLayers.Geometry.Collection", "Geometry of feature is a collection");
|
||||||
|
var l = new OpenLayers.Layer.Vector();
|
||||||
|
l.addFeatures(data);
|
||||||
|
t.ok(true, "adding a feature with geomcollection to layer doesn't cause error.");
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_Format_GeoJSON_multipleFeatures(t) {
|
function test_Format_GeoJSON_multipleFeatures(t) {
|
||||||
@@ -263,6 +303,23 @@
|
|||||||
])
|
])
|
||||||
]),
|
]),
|
||||||
'{"type":"Polygon","coordinates":[[[1,2],[3,4],[5,6],[1,2]]]}'
|
'{"type":"Polygon","coordinates":[[[1,2],[3,4],[5,6],[1,2]]]}'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
new OpenLayers.Geometry.Collection([
|
||||||
|
new OpenLayers.Geometry.Polygon([
|
||||||
|
new OpenLayers.Geometry.LinearRing([
|
||||||
|
new OpenLayers.Geometry.Point(1,2),
|
||||||
|
new OpenLayers.Geometry.Point(3,4),
|
||||||
|
new OpenLayers.Geometry.Point(5,6)
|
||||||
|
])
|
||||||
|
]),
|
||||||
|
new OpenLayers.Geometry.LineString([
|
||||||
|
new OpenLayers.Geometry.Point(1,2),
|
||||||
|
new OpenLayers.Geometry.Point(3,4)
|
||||||
|
]),
|
||||||
|
new OpenLayers.Geometry.Point(1,2)
|
||||||
|
]),
|
||||||
|
'{"type":"GeometryCollection","geometries":[{"type":"Polygon","coordinates":[[[1,2],[3,4],[5,6],[1,2]]]},{"type":"LineString","coordinates":[[1,2],[3,4]]},{"type":"Point","coordinates":[1,2]}]}'
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
serialize_tests[0][0].fid = 0;
|
serialize_tests[0][0].fid = 0;
|
||||||
@@ -271,7 +328,6 @@
|
|||||||
multipolygon = new OpenLayers.Geometry.MultiPolygon([serialize_tests[4][0], serialize_tests[4][0]]);
|
multipolygon = new OpenLayers.Geometry.MultiPolygon([serialize_tests[4][0], serialize_tests[4][0]]);
|
||||||
serialize_tests.push([multipolygon, '{"type":"MultiPolygon","coordinates":[[[[1,2],[3,4],[5,6],[1,2]]],[[[1,2],[3,4],[5,6],[1,2]]]]}']);
|
serialize_tests.push([multipolygon, '{"type":"MultiPolygon","coordinates":[[[[1,2],[3,4],[5,6],[1,2]]],[[[1,2],[3,4],[5,6],[1,2]]]]}']);
|
||||||
serialize_tests.push([ [ serialize_tests[0][0] ], '{"type":"FeatureCollection","features":[{"type":"Feature","id":0,"properties":{},"geometry":{"type":"Point","coordinates":[1,2]}}]}' ]);
|
serialize_tests.push([ [ serialize_tests[0][0] ], '{"type":"FeatureCollection","features":[{"type":"Feature","id":0,"properties":{},"geometry":{"type":"Point","coordinates":[1,2]}}]}' ]);
|
||||||
serialize_tests.push([ [ serialize_tests[1][0], serialize_tests[2][0] ], '{"type":"GeometryCollection","geometries":[{"type":"Point","coordinates":[1,2]},{"type":"MultiPoint","coordinates":[[1,2]]}]}' ]);
|
|
||||||
for (var i = 0; i < serialize_tests.length; i++) {
|
for (var i = 0; i < serialize_tests.length; i++) {
|
||||||
var input = serialize_tests[i][0];
|
var input = serialize_tests[i][0];
|
||||||
var output = serialize_tests[i][1];
|
var output = serialize_tests[i][1];
|
||||||
|
|||||||
Reference in New Issue
Block a user