Skip to content

Commit

Permalink
Merge branch 'kantega-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
atlefren committed May 18, 2015
2 parents e4d9e33 + 919915c commit 072284c
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -87,6 +87,7 @@ Building
Running tests
-------------
$ buster-server &
Now open browser to http://localhost:1111 and click «Capture slave»
$ buster-test

Dependencies
Expand Down
31 changes: 31 additions & 0 deletions data/punktcoordinate.sos
@@ -0,0 +1,31 @@
.HODE
..TEGNSETT ISO8859-1
..SOSI-VERSJON 8.1
..DATAKATALOGVERSJON 2.01
..SOSINVDB-FORMAT-VERSJON 1.0
..SOSI-NIVÅ 1
..TRANSPAR
...KOORDSYS 23
...ORIGO-NØ 100000 10000
...ENHET 0.010
...VERT-DATUM NN54
..OMRÅDE
...MIN-NØ 7034310 569351
...MAX-NØ 7034406 569492
..EIER "Owner"
..PRODUSENT "Producer"
.PUNKT 1:
..OBJTYPE Skiltplate_96
..PTEMA 0999
..DATAFANGSTDATO 20131127
..KVALITET 96 5 0 * *
..SkiltnummerHB-050_5530 7691
..Ansiktsside_1894 2714
..Størrelse_1970 4132
..Skiltform_1892 2855
..Belysning_1879 3476
..Folieklasse_1921 2849
..Klappskilt_8828 11739
..NØH 2980 11668 995
..HREF 13692
.SLUTT
15 changes: 14 additions & 1 deletion src/feature.js
Expand Up @@ -35,7 +35,20 @@ var SOSI = window.SOSI || {};

var split = _.reduce(data.lines, function (dict, line) {
if (line.indexOf("..NØ") !== -1) {
dict.foundGeom = true;
/**
* The coordinates for a feature may be either on the same line
* as NØ[H], or on lines following it.
* Therefore we need to check this when encountering ..NØ.
* If the line contains more elements we assume the line is «..NØ[H] x y [h]», and push
* «..NØ[H]» and «x y [h]» to geom.
*/
var splitLine = line.split(" ");
if(splitLine.length > 1){
dict.geom.push(splitLine[0]);
dict.geom.push(line.replace(splitLine[0] + " ", ""));
} else {
dict.foundGeom = true;
}
}
if (dict.foundGeom) {
dict.geom.push(line);
Expand Down
1 change: 1 addition & 0 deletions test/buster.js
Expand Up @@ -23,6 +23,7 @@ config["My tests"] = {
resources: [
{path: "/testfile1.sos", content: fs.readFileSync('data/testfile1.sos')},
{path: "/punkttest.sos", content: fs.readFileSync('data/punkttest.sos')},
{path: "/punktcoordinate.sos", content: fs.readFileSync('data/punktcoordinate.sos')},
{path: "/kurvetest.sos", content: fs.readFileSync('data/kurvetest.sos')},
{path: "/flatetest.sos", content: fs.readFileSync('data/flatetest.sos')},
{path: "/flate_oy.sos", content: fs.readFileSync('data/flate_oy.sos')},
Expand Down
29 changes: 29 additions & 0 deletions test/punktcoordinate-test.js
@@ -0,0 +1,29 @@
(function (ns) {
"use strict";

var assert = assert || buster.assertions.assert;
var refute = refute || buster.assertions.refute;

buster.testCase('PUNKT coordinate Test', {

setUp: function () {

$.ajax({
async: false,
url: buster.env.contextPath + "/punktcoordinate.sos",
success:_.bind(function(data) {
this.sosidata = data;
}, this)
});
this.parser = new ns.Parser();
},

"NØH and coordinates on same line": function () {
var sosidata = this.parser.parse(this.sosidata);
var feature1 = sosidata.features.at(0);
assert(feature1.geometry instanceof ns.Point);
assert.equals(feature1.geometry.x, 10116.68);
assert.equals(feature1.geometry.y, 100029.8);
}
});
}(SOSI));

0 comments on commit 072284c

Please sign in to comment.