#915 Adding support for GeoJSON vector format. Many thanks to Chris for the exhaustive tests on this one.

git-svn-id: http://svn.openlayers.org/trunk/openlayers@3994 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2007-08-23 16:29:03 +00:00
parent c6850a2b6a
commit ab73cc3f79
7 changed files with 1500 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
<html>
<head>
<script src="../../lib/OpenLayers.js"></script>
<script type="text/javascript"><!--
function test_Format_JSON_constructor(t) {
t.plan(4);
var options = {'foo': 'bar'};
var format = new OpenLayers.Format.JSON(options);
t.ok(format instanceof OpenLayers.Format.JSON,
"new OpenLayers.Format.JSON returns object" );
t.eq(format.foo, "bar", "constructor sets options correctly");
t.eq(typeof format.read, "function", "format has a read function");
t.eq(typeof format.write, "function", "format has a write function");
}
function test_Format_JSON_parser(t) {
t.plan(2);
var format = new OpenLayers.Format.JSON();
var data = format.read('{"a":["b"], "c":1}');
var obj = {"a":["b"], "c":1};
t.eq(obj['a'], data['a'], "element with array parsed correctly.");
t.eq(obj['c'], data['c'], "element with number parsed correctly.");
}
function test_Format_JSON_writer(t) {
t.plan(1);
var format = new OpenLayers.Format.JSON();
var data = format.write({"a":["b"], "c":1});
var obj = '{"a":["b"],"c":1}';
t.eq(data, obj, "writing data to json works.");
}
// -->
</script>
</head>
<body>
</body>
</html>