Skip to content

Commit

Permalink
closing polygons frontend side to store paths already closed
Browse files Browse the repository at this point in the history
  • Loading branch information
javisantana committed Oct 14, 2013
1 parent 20eb3fd commit 0135203
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 6 deletions.
6 changes: 0 additions & 6 deletions src/application/kml.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ def path_to_kml(paths):
kml+="<coordinates>"
for p in paths[0]:
kml+= str(p[1]) + "," + str(p[0]) + ",0\n"
# close polygon
p = paths[0][0]
kml += str(p[1]) + "," + str(p[0]) + ",0\n"
kml += "</coordinates>"
kml+= "</LinearRing>"
kml+= "</outerBoundaryIs>"
Expand All @@ -19,9 +16,6 @@ def path_to_kml(paths):
kml+="<coordinates>"
for p in inner:
kml+= str(p[1]) + "," + str(p[0]) + ",0\n"
# close polygon
p = inner[0][0]
kml += str(p[1]) + "," + str(p[0]) + ",0\n"
kml += "</coordinates>"
kml+= "</LinearRing>"
kml +="</innerBoundaryIs>"
Expand Down
45 changes: 45 additions & 0 deletions src/tests/frontend/polygon.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

module("polygon")

test('tojson', function() {
var p = new Polygon({
type: 'test',
paths: [
[ [0, 1], [1, 1], [1, 0] ],
[ [5, 1], [1, 1], [1, 5] ]
]
});
equal(_.isEqual(p.toJSON().paths, [
[ [0, 1], [1, 1], [1, 0], [0, 1] ],
[ [5, 1], [1, 1], [1, 5], [5, 1] ]
]), true)
});

test('parse', function() {
var p = new Polygon()
var res = p.parse({
type: 'test',
paths: [
[ [0, 1], [1, 1], [1, 0] ],
[ [5, 1], [1, 1], [1, 5] ]
]
});
equal(_.isEqual(res.paths, [
[ [0, 1], [1, 1], [1, 0] ],
[ [5, 1], [1, 1], [1, 5] ]
]), true)

var res = p.parse({
type: 'test',
paths: [
[ [0, 1], [1, 1], [1, 0], [0, 1] ],
[ [5, 1], [1, 1], [1, 5], [5, 1] ]
]
});

equal(_.isEqual(res.paths, [
[ [0, 1], [1, 1], [1, 0] ],
[ [5, 1], [1, 1], [1, 5] ]
]), true)

});

0 comments on commit 0135203

Please # to comment.