diff options
author | heather <unknown> | 2011-05-09 00:50:41 -0400 |
---|---|---|
committer | heather <unknown> | 2011-05-09 00:50:41 -0400 |
commit | e140c61a5f743e90ff0120f942056dbac581394a (patch) | |
tree | a789b5acc9e8814eb1e89c23fabd7977f15c8c48 | |
parent | 2ee96241f90c01b30bf5a0a86113c2ea18b94e92 (diff) | |
download | d2-e140c61a5f743e90ff0120f942056dbac581394a.tar.bz2 d2-e140c61a5f743e90ff0120f942056dbac581394a.tar.xz d2-e140c61a5f743e90ff0120f942056dbac581394a.zip |
cleaning up d2_svg_processor, commit what I have done so far
-rw-r--r-- | lib/d2/bin/d2_svg_processor.py | 122 | ||||
-rw-r--r-- | static/html/test_label.html | 3 |
2 files changed, 61 insertions, 64 deletions
diff --git a/lib/d2/bin/d2_svg_processor.py b/lib/d2/bin/d2_svg_processor.py index b5bb2aa..c423ec6 100644 --- a/lib/d2/bin/d2_svg_processor.py +++ b/lib/d2/bin/d2_svg_processor.py | |||
@@ -28,27 +28,27 @@ ROOM_X_RANGE = {'3D1': {'xmin': 0, | |||
28 | 'xmax': 4500} | 28 | 'xmax': 4500} |
29 | } | 29 | } |
30 | 30 | ||
31 | nsmap = {'svg': 'http://www.w3.org/2000/svg', | 31 | NSMAP = {'svg': 'http://www.w3.org/2000/svg', |
32 | 'xlink': "http://www.w3.org/1999/xlink"} | 32 | 'xlink': "http://www.w3.org/1999/xlink"} |
33 | nsmap2 = {None: 'http://www.w3.org/2000/svg'} | 33 | NSMAP2 = {None: 'http://www.w3.org/2000/svg'} |
34 | 34 | ||
35 | ROOMS = [u'3A1', u'3B1', u'3C1', u'3D1'] | 35 | ROOMS = [u'3A1', u'3B1', u'3C1', u'3D1'] |
36 | 36 | ||
37 | ntwk_number_id = {'3D13A1': 'NTWK_NUMBER', | 37 | NTWK_NUMBER_ID = {'3D13A1': 'NTWK_NUMBER', |
38 | '3C1': 'NTWK_NUMBER-7', | 38 | '3C1': 'NTWK_NUMBER-7', |
39 | '3B1': 'NTWK_NUMBER-1'} | 39 | '3B1': 'NTWK_NUMBER-1'} |
40 | 40 | ||
41 | name_label_id = {'3D13A1': 'NAME', | 41 | NAME_LABEL_ID = {'3D13A1': 'NAME', |
42 | '3C1': 'NAME-2', | 42 | '3C1': 'NAME-2', |
43 | '3B1': 'NAME-6'} | 43 | '3B1': 'NAME-6'} |
44 | 44 | ||
45 | main_room_nodes = ['draft', 'draft-3', 'draft-4'] | 45 | MAIN_ROOM_NODES = ['draft', 'draft-3', 'draft-4'] |
46 | 46 | ||
47 | group_id_room = {'draft': '3D13A1', | 47 | GROUP_ID_ROOM = {'draft': '3D13A1', |
48 | 'draft-3': '3C1', | 48 | 'draft-3': '3C1', |
49 | 'draft-4': '3B1'} | 49 | 'draft-4': '3B1'} |
50 | 50 | ||
51 | discard_ids = ['#REFR', '#REFR-3'] | 51 | DISCARD_IDS = ['#REFR', '#REFR-3'] |
52 | 52 | ||
53 | NAME_CORRECTIONS = {u'Deb Smith': u'Deborah Smith', | 53 | NAME_CORRECTIONS = {u'Deb Smith': u'Deborah Smith', |
54 | u'Ron Lacey': u'Ron Lacy', | 54 | u'Ron Lacey': u'Ron Lacy', |
@@ -76,7 +76,7 @@ floor_plan_data = {} | |||
76 | 76 | ||
77 | ntwk_number_data = {} | 77 | ntwk_number_data = {} |
78 | 78 | ||
79 | ntwk_id_pattern = re.compile("([A-Z]+)(\d+)") | 79 | NTWK_ID_PATTERN = re.compile("([A-Z]+)(\d+)") |
80 | 80 | ||
81 | class Args(object): | 81 | class Args(object): |
82 | 82 | ||
@@ -158,7 +158,7 @@ class Args(object): | |||
158 | 158 | ||
159 | class ParseFloorPlanXLS(object): | 159 | class ParseFloorPlanXLS(object): |
160 | 160 | ||
161 | OUTPUT_FILENAME = 'floor_plan.json' | 161 | MULTIPLE_RECORD_ERROR = "Data Error: multiple records for {0} in room {1}" |
162 | 162 | ||
163 | def __init__(self): | 163 | def __init__(self): |
164 | pass | 164 | pass |
@@ -182,21 +182,16 @@ class ParseFloorPlanXLS(object): | |||
182 | net_jack1 = unicode(sh.cell(rowx=rownum, colx=3).value) | 182 | net_jack1 = unicode(sh.cell(rowx=rownum, colx=3).value) |
183 | net_jack2 = unicode(sh.cell(rowx=rownum, colx=4).value) | 183 | net_jack2 = unicode(sh.cell(rowx=rownum, colx=4).value) |
184 | if room_name not in floor_plan_data: | 184 | if room_name not in floor_plan_data: |
185 | floor_plan_data[room_name] = {} | 185 | floor_plan_data[room_name] = {} |
186 | if cube in floor_plan_data[room_name]: | 186 | if cube in floor_plan_data[room_name]: |
187 | log_obj.error("""DATA ERROR: | 187 | log_obj.error(self.MULTIPLE_RECORD_ERROR.format(cube, |
188 | multiple records for %s in room %s""" %(cube, | 188 | room_name)) |
189 | room_name)) | ||
190 | else: | 189 | else: |
191 | floor_plan_data[room_name][cube] = {'name': name, | 190 | floor_plan_data[room_name][cube] = {'name': name, |
192 | 'net_jack1': net_jack1, | 191 | 'net_jack1': net_jack1, |
193 | 'net_jack2': net_jack2} | 192 | 'net_jack2': net_jack2} |
194 | 193 | ||
195 | def __call__(self, args): | 194 | def __call__(self, args): |
196 | output_filepath = os.path.join( | ||
197 | args.data_directory, | ||
198 | args.project + '_' + self.OUTPUT_FILENAME | ||
199 | ) | ||
200 | wb = xlrd.open_workbook(args.master_spreadsheet) | 195 | wb = xlrd.open_workbook(args.master_spreadsheet) |
201 | for sheet_name in wb.sheet_names(): | 196 | for sheet_name in wb.sheet_names(): |
202 | room_name = self._determine_room(sheet_name) | 197 | room_name = self._determine_room(sheet_name) |
@@ -204,25 +199,22 @@ class ParseFloorPlanXLS(object): | |||
204 | self._process_sheet(wb.sheet_by_name(sheet_name), | 199 | self._process_sheet(wb.sheet_by_name(sheet_name), |
205 | room_name, args.log) | 200 | room_name, args.log) |
206 | 201 | ||
207 | with open(output_filepath, 'wb') as output_fileobj: | ||
208 | output_fileobj.write(json.dumps(floor_plan_data)) | ||
209 | |||
210 | class CreateStructureSVG(object): | 202 | class CreateStructureSVG(object): |
211 | 203 | ||
212 | OUTPUT_FILENAME = 'structure.svg' | 204 | OUTPUT_FILENAME = 'structure.svg' |
213 | 205 | ||
214 | reg_keep_elements = re.compile("(FIXED_OUTLINE$)|(FIXED_OUTLINE-\d+)|"\ | 206 | REG_KEEP_ELEMENTS = re.compile("(FIXED_OUTLINE$)|(FIXED_OUTLINE-\d+)|"\ |
215 | "(FURN-8$)|(FINISHES-8$)|"\ | 207 | "(FURN-8$)|(FINISHES-8$)|"\ |
216 | "(OUTLN$)|(OUTLN-\d+)|"\ | 208 | "(OUTLN$)|(OUTLN-\d+)|"\ |
217 | "(PANELS$)|(PANELS-\d+)|"\ | 209 | "(PANELS$)|(PANELS-\d+)|"\ |
218 | "(g141075$)|(g163196$)|(g55578$)|"\ | 210 | "(g141075$)|(g163196$)|(g55578$)|"\ |
219 | "(WALL$)|(WALL-\d+)") | 211 | "(WALL$)|(WALL-\d+)") |
220 | 212 | ||
221 | reg_pat_1 = re.compile('ID_(.*)_PANEL', re.IGNORECASE) | 213 | REG_PAT_1 = re.compile('ID_(.*)_PANEL', re.IGNORECASE) |
222 | reg_pat_2 = re.compile('ID_(.*)_pan', re.IGNORECASE) | 214 | REG_PAT_2 = re.compile('ID_(.*)_pan', re.IGNORECASE) |
223 | reg_pat_3 = re.compile('ID_(.*)_panels', re.IGNORECASE) | 215 | REG_PAT_3 = re.compile('ID_(.*)_panels', re.IGNORECASE) |
224 | 216 | ||
225 | reg_panels = [reg_pat_1, reg_pat_2, reg_pat_3] | 217 | REG_PANELS = [REG_PAT_1, REG_PAT_2, REG_PAT_3] |
226 | 218 | ||
227 | def __init__(self): | 219 | def __init__(self): |
228 | self.input_svg = "" | 220 | self.input_svg = "" |
@@ -235,10 +227,10 @@ class CreateStructureSVG(object): | |||
235 | def_node = etree.SubElement(parent_el, def_el.tag, | 227 | def_node = etree.SubElement(parent_el, def_el.tag, |
236 | def_el.attrib) | 228 | def_el.attrib) |
237 | for el in def_el: | 229 | for el in def_el: |
238 | if el.tag == '{%s}g' %nsmap['svg']: | 230 | if el.tag == '{{{0}}}g'.format(NSMAP['svg']): |
239 | el_id = el.attrib['id'] | 231 | el_id = el.attrib['id'] |
240 | is_panel_node = False | 232 | is_panel_node = False |
241 | for reg_pat in self.reg_panels: | 233 | for reg_pat in self.REG_PANELS: |
242 | if reg_pat.match(el_id): | 234 | if reg_pat.match(el_id): |
243 | Util.remove_text_node(def_node, el) | 235 | Util.remove_text_node(def_node, el) |
244 | is_panel_node = True | 236 | is_panel_node = True |
@@ -254,14 +246,14 @@ class CreateStructureSVG(object): | |||
254 | the_node = etree.SubElement(parent_node, the_el.tag, | 246 | the_node = etree.SubElement(parent_node, the_el.tag, |
255 | the_el.attrib) | 247 | the_el.attrib) |
256 | for el in the_el: | 248 | for el in the_el: |
257 | if el.tag != '{%s}text' %nsmap['svg']: | 249 | if el.tag != '{{{0}}}text'.format(NSMAP['svg']): |
258 | the_node.append(el) | 250 | the_node.append(el) |
259 | 251 | ||
260 | def _get_room_structure_svg(self, parent_el, el, room_name): | 252 | def _get_room_structure_svg(self, parent_el, el, room_name): |
261 | group_node = etree.SubElement(parent_el, el.tag, | 253 | group_node = etree.SubElement(parent_el, el.tag, |
262 | el.attrib) | 254 | el.attrib) |
263 | for sub_el in el: | 255 | for sub_el in el: |
264 | if self.reg_keep_elements.match(sub_el.attrib['id']): | 256 | if self.REG_KEEP_ELEMENTS.match(sub_el.attrib['id']): |
265 | self._remove_all_texts(group_node, sub_el) | 257 | self._remove_all_texts(group_node, sub_el) |
266 | 258 | ||
267 | def _get_structure_svg(self): | 259 | def _get_structure_svg(self): |
@@ -269,8 +261,8 @@ class CreateStructureSVG(object): | |||
269 | 261 | ||
270 | #create svg root element: | 262 | #create svg root element: |
271 | parser = etree.XMLParser() | 263 | parser = etree.XMLParser() |
272 | structure_svg = parser.makeelement('{%s}' %nsmap['svg'] + 'svg', | 264 | structure_svg = parser.makeelement( |
273 | nsmap = nsmap2) | 265 | '{{{0}}}{1}'.format(NSMAP['svg'], 'svg'), nsmap = NSMAP2) |
274 | #copy the root element attributes to the newly created svgs: | 266 | #copy the root element attributes to the newly created svgs: |
275 | root = data.getroottree().getroot() | 267 | root = data.getroottree().getroot() |
276 | 268 | ||
@@ -280,15 +272,14 @@ class CreateStructureSVG(object): | |||
280 | #main_el includes defs, meta info and one main group node | 272 | #main_el includes defs, meta info and one main group node |
281 | #that includes a translation | 273 | #that includes a translation |
282 | for main_el in data: | 274 | for main_el in data: |
283 | if main_el.tag == '{%s}defs' %nsmap['svg']: | 275 | if main_el.tag == '{{{0}}}defs'.format(NSMAP['svg']): |
284 | self._process_def(structure_svg, main_el) | 276 | self._process_def(structure_svg, main_el) |
285 | elif main_el.tag == '{%s}g' %nsmap['svg']: | 277 | elif main_el.tag == '{{{0}}}g'.format(NSMAP['svg']): |
286 | group_node = etree.SubElement(structure_svg, main_el.tag, | 278 | group_node = etree.SubElement(structure_svg, main_el.tag, |
287 | main_el.attrib) | 279 | main_el.attrib) |
288 | for el in main_el: | 280 | for el in main_el: |
289 | if el.attrib['id'] in main_room_nodes: | 281 | if el.attrib['id'] in MAIN_ROOM_NODES: |
290 | room_name = group_id_room.get(el.attrib['id']) | 282 | room_name = GROUP_ID_ROOM.get(el.attrib['id']) |
291 | #print "processing %s" %room_name | ||
292 | self._get_room_structure_svg(group_node, el, room_name) | 283 | self._get_room_structure_svg(group_node, el, room_name) |
293 | else: | 284 | else: |
294 | main_el.append(el) | 285 | main_el.append(el) |
@@ -300,7 +291,7 @@ class CreateStructureSVG(object): | |||
300 | return etree.tostring(structure_svg) | 291 | return etree.tostring(structure_svg) |
301 | 292 | ||
302 | def _remove_extra_nodes(self, top_node): | 293 | def _remove_extra_nodes(self, top_node): |
303 | for href_to_avoid in discard_ids: | 294 | for href_to_avoid in DISCARD_IDS: |
304 | Util.remove_node_by_href_id(top_node, href_to_avoid) | 295 | Util.remove_node_by_href_id(top_node, href_to_avoid) |
305 | 296 | ||
306 | def __call__(self, args): | 297 | def __call__(self, args): |
@@ -321,6 +312,8 @@ class PopulateTables(object): | |||
321 | OUTPUT_JSON_FILENAME = 'ntwk_number_data.json' | 312 | OUTPUT_JSON_FILENAME = 'ntwk_number_data.json' |
322 | TABLES = [u'forge', u'label_coordinate', u'plot'] | 313 | TABLES = [u'forge', u'label_coordinate', u'plot'] |
323 | 314 | ||
315 | TRANSFORM_MATRIX_ERROR = "Error: transform matrix of {0} not implemented" | ||
316 | |||
324 | def __init__(self): | 317 | def __init__(self): |
325 | self.input_svg = "" | 318 | self.input_svg = "" |
326 | self._db = None | 319 | self._db = None |
@@ -353,16 +346,18 @@ class PopulateTables(object): | |||
353 | for matrix in matrices: | 346 | for matrix in matrices: |
354 | if matrix[0:6] == "matrix": | 347 | if matrix[0:6] == "matrix": |
355 | matrix_element_list = map(float, matrix[7:-1].split(',')) | 348 | matrix_element_list = map(float, matrix[7:-1].split(',')) |
356 | ret_x = matrix_element_list[0] * x + matrix_element_list[2] * y\ | 349 | ret_x = matrix_element_list[0] * x \ |
350 | + matrix_element_list[2] * y \ | ||
357 | + matrix_element_list[4] | 351 | + matrix_element_list[4] |
358 | ret_y = matrix_element_list[1] * x + matrix_element_list[3] * y\ | 352 | ret_y = matrix_element_list[1] * x \ |
353 | + matrix_element_list[3] * y \ | ||
359 | + matrix_element_list[5] | 354 | + matrix_element_list[5] |
360 | elif matrix[0:9] == "translate": | 355 | elif matrix[0:9] == "translate": |
361 | (tx, ty) = map(float, matrix[10:-1].split(',')) | 356 | (tx, ty) = map(float, matrix[10:-1].split(',')) |
362 | ret_x = x + tx | 357 | ret_x = x + tx |
363 | ret_y = y + ty | 358 | ret_y = y + ty |
364 | else: | 359 | else: |
365 | raise Exception("transform matrix of %s, is not implemented" %matrix) | 360 | raise Exception(self.TRANSFORM_MATRIX_ERROR.format(matrix)) |
366 | 361 | ||
367 | x = ret_x | 362 | x = ret_x |
368 | y = ret_y | 363 | y = ret_y |
@@ -384,13 +379,13 @@ class PopulateTables(object): | |||
384 | transform=node.attrib['transform'], | 379 | transform=node.attrib['transform'], |
385 | id="%s_NTWK_NUMBER" %room_name) | 380 | id="%s_NTWK_NUMBER" %room_name) |
386 | 381 | ||
387 | room_ntwk_id = ntwk_number_id.get(room_name) | 382 | room_ntwk_id = NTWK_NUMBER_ID.get(room_name) |
388 | for el in node: | 383 | for el in node: |
389 | if el.attrib['id'] == room_ntwk_id: | 384 | if el.attrib['id'] == room_ntwk_id: |
390 | for sub_el in el: | 385 | for sub_el in el: |
391 | if sub_el.tag == '{%s}text' %nsmap['svg']: | 386 | if sub_el.tag == '{{{0}}}text'.format(NSMAP['svg']): |
392 | tspan_elem = sub_el.xpath('./svg:tspan', | 387 | tspan_elem = sub_el.xpath('./svg:tspan', |
393 | namespaces=nsmap)[0] | 388 | namespaces=NSMAP)[0] |
394 | ntwk_id = tspan_elem.text | 389 | ntwk_id = tspan_elem.text |
395 | #tspan_elem.attrib['font-size'] = "36" | 390 | #tspan_elem.attrib['font-size'] = "36" |
396 | ntwk_group.append(sub_el) | 391 | ntwk_group.append(sub_el) |
@@ -475,8 +470,9 @@ class PopulateTables(object): | |||
475 | 470 | ||
476 | #create svg root element: | 471 | #create svg root element: |
477 | parser = etree.XMLParser() | 472 | parser = etree.XMLParser() |
478 | ntwk_id_svg = parser.makeelement('{%s}' %nsmap['svg'] + 'svg', | 473 | ntwk_id_svg = parser.makeelement( |
479 | nsmap = nsmap2) | 474 | '{{{0}}}{1}'.format(NSMAP['svg'], 'svg'), |
475 | nsmap = NSMAP2) | ||
480 | #copy the root element attributes to the newly created svgs: | 476 | #copy the root element attributes to the newly created svgs: |
481 | root = data.getroottree().getroot() | 477 | root = data.getroottree().getroot() |
482 | for key, value in root.attrib.iteritems(): | 478 | for key, value in root.attrib.iteritems(): |
@@ -487,13 +483,13 @@ class PopulateTables(object): | |||
487 | map(float, re.split('\s+', view_box[:])) | 483 | map(float, re.split('\s+', view_box[:])) |
488 | 484 | ||
489 | for main_el in data: | 485 | for main_el in data: |
490 | if main_el.tag == '{%s}g' %nsmap['svg']: | 486 | if main_el.tag == '{%s}g' %NSMAP['svg']: |
491 | main_el_matrix = main_el.attrib['transform'] | 487 | main_el_matrix = main_el.attrib['transform'] |
492 | group_node = etree.SubElement(ntwk_id_svg, main_el.tag, | 488 | group_node = etree.SubElement(ntwk_id_svg, main_el.tag, |
493 | main_el.attrib) | 489 | main_el.attrib) |
494 | for el in main_el: | 490 | for el in main_el: |
495 | if el.attrib['id'] in main_room_nodes: | 491 | if el.attrib['id'] in MAIN_ROOM_NODES: |
496 | room_name = group_id_room.get(el.attrib['id']) | 492 | room_name = GROUP_ID_ROOM.get(el.attrib['id']) |
497 | self._get_room_ntwk_id_svg(group_node, el, room_name, | 493 | self._get_room_ntwk_id_svg(group_node, el, room_name, |
498 | view_box_xmin, | 494 | view_box_xmin, |
499 | view_box_ymin, | 495 | view_box_ymin, |
@@ -507,8 +503,8 @@ class PopulateTables(object): | |||
507 | 503 | ||
508 | #create svg root element: | 504 | #create svg root element: |
509 | parser = etree.XMLParser() | 505 | parser = etree.XMLParser() |
510 | name_label_svg = parser.makeelement('{%s}' %nsmap['svg'] + 'svg', | 506 | name_label_svg = parser.makeelement('{%s}' %NSMAP['svg'] + 'svg', |
511 | nsmap = nsmap2) | 507 | nsmap = NSMAP2) |
512 | #copy the root element attributes to the newly created svgs: | 508 | #copy the root element attributes to the newly created svgs: |
513 | root = data.getroottree().getroot() | 509 | root = data.getroottree().getroot() |
514 | for key, value in root.attrib.iteritems(): | 510 | for key, value in root.attrib.iteritems(): |
@@ -519,13 +515,13 @@ class PopulateTables(object): | |||
519 | map(float, re.split('\s+', view_box[:])) | 515 | map(float, re.split('\s+', view_box[:])) |
520 | 516 | ||
521 | for main_el in data: | 517 | for main_el in data: |
522 | if main_el.tag == '{%s}g' %nsmap['svg']: | 518 | if main_el.tag == '{%s}g' %NSMAP['svg']: |
523 | main_el_matrix = main_el.attrib['transform'] | 519 | main_el_matrix = main_el.attrib['transform'] |
524 | group_node = etree.SubElement(name_label_svg, main_el.tag, | 520 | group_node = etree.SubElement(name_label_svg, main_el.tag, |
525 | main_el.attrib) | 521 | main_el.attrib) |
526 | for el in main_el: | 522 | for el in main_el: |
527 | if el.attrib['id'] in main_room_nodes: | 523 | if el.attrib['id'] in MAIN_ROOM_NODES: |
528 | room_name = group_id_room.get(el.attrib['id']) | 524 | room_name = GROUP_ID_ROOM.get(el.attrib['id']) |
529 | self._get_room_name_label_svg(group_node, | 525 | self._get_room_name_label_svg(group_node, |
530 | el, | 526 | el, |
531 | room_name, | 527 | room_name, |
@@ -554,13 +550,13 @@ class PopulateTables(object): | |||
554 | transform=node.attrib['transform'], | 550 | transform=node.attrib['transform'], |
555 | id="%s_NAME_LABEL" %approx_room_name) | 551 | id="%s_NAME_LABEL" %approx_room_name) |
556 | 552 | ||
557 | room_name_label_id = name_label_id.get(approx_room_name) | 553 | room_name_label_id = NAME_LABEL_ID.get(approx_room_name) |
558 | for el in node: | 554 | for el in node: |
559 | if el.attrib['id'] == room_name_label_id: | 555 | if el.attrib['id'] == room_name_label_id: |
560 | for sub_el in el: | 556 | for sub_el in el: |
561 | if sub_el.tag == '{%s}text' %nsmap['svg']: | 557 | if sub_el.tag == '{%s}text' %NSMAP['svg']: |
562 | tspan_elem = sub_el.xpath('./svg:tspan', | 558 | tspan_elem = sub_el.xpath('./svg:tspan', |
563 | namespaces=nsmap)[0] | 559 | namespaces=NSMAP)[0] |
564 | transform_matrix = sub_el.attrib['transform'] | 560 | transform_matrix = sub_el.attrib['transform'] |
565 | matrices = list(base_matrices) | 561 | matrices = list(base_matrices) |
566 | matrices.insert(0, transform_matrix) | 562 | matrices.insert(0, transform_matrix) |
@@ -583,7 +579,7 @@ class PopulateTables(object): | |||
583 | 579 | ||
584 | current_name_shown = "" | 580 | current_name_shown = "" |
585 | tspan_elem = sub_el.xpath('./svg:tspan', | 581 | tspan_elem = sub_el.xpath('./svg:tspan', |
586 | namespaces=nsmap) | 582 | namespaces=NSMAP) |
587 | for ts in tspan_elem: | 583 | for ts in tspan_elem: |
588 | current_name_shown += " " + ts.text | 584 | current_name_shown += " " + ts.text |
589 | 585 | ||
@@ -682,7 +678,7 @@ class PopulateTables(object): | |||
682 | @return floor_plan format | 678 | @return floor_plan format |
683 | """ | 679 | """ |
684 | normalized_ntwk_id = ntwk_id | 680 | normalized_ntwk_id = ntwk_id |
685 | matched = ntwk_id_pattern.match(ntwk_id) | 681 | matched = NTWK_ID_PATTERN.match(ntwk_id) |
686 | if matched: | 682 | if matched: |
687 | (letters, numbers) = matched.groups() | 683 | (letters, numbers) = matched.groups() |
688 | if len(numbers) == 1: | 684 | if len(numbers) == 1: |
@@ -813,19 +809,19 @@ class Util(object): | |||
813 | el.tag, | 809 | el.tag, |
814 | el.attrib) | 810 | el.attrib) |
815 | for sub_el in el: | 811 | for sub_el in el: |
816 | if sub_el.tag != '{%s}text' %nsmap['svg']: | 812 | if sub_el.tag != '{%s}text' %NSMAP['svg']: |
817 | el_wrapper_node.append(sub_el) | 813 | el_wrapper_node.append(sub_el) |
818 | 814 | ||
819 | 815 | ||
820 | @staticmethod | 816 | @staticmethod |
821 | def remove_node_by_href_id(top_node, href_id): | 817 | def remove_node_by_href_id(top_node, href_id): |
822 | use_nodes = top_node.xpath('//svg:use', | 818 | use_nodes = top_node.xpath('//svg:use', |
823 | namespaces = nsmap) | 819 | namespaces = NSMAP) |
824 | 820 | ||
825 | for el in use_nodes: | 821 | for el in use_nodes: |
826 | href = '{%s}href' %nsmap['xlink'] | 822 | href = '{%s}href' %NSMAP['xlink'] |
827 | if href in el.attrib: | 823 | if href in el.attrib: |
828 | el_href = el.attrib['{%s}href' %nsmap['xlink']] | 824 | el_href = el.attrib['{%s}href' %NSMAP['xlink']] |
829 | if el_href == href_id: | 825 | if el_href == href_id: |
830 | el.getparent().remove(el) | 826 | el.getparent().remove(el) |
831 | 827 | ||
diff --git a/static/html/test_label.html b/static/html/test_label.html index 0c45e1d..a4a0b65 100644 --- a/static/html/test_label.html +++ b/static/html/test_label.html | |||
@@ -25,6 +25,7 @@ | |||
25 | new OpenLayers.Control.Navigation(), | 25 | new OpenLayers.Control.Navigation(), |
26 | new OpenLayers.Control.PanZoomBar(), | 26 | new OpenLayers.Control.PanZoomBar(), |
27 | new OpenLayers.Control.LayerSwitcher(), | 27 | new OpenLayers.Control.LayerSwitcher(), |
28 | new OpenLayers.Control.MousePosition(), | ||
28 | new OpenLayers.Control.Attribution()]}; | 29 | new OpenLayers.Control.Attribution()]}; |
29 | 30 | ||
30 | map = new OpenLayers.Map ("map", options); | 31 | map = new OpenLayers.Map ("map", options); |
@@ -55,7 +56,7 @@ | |||
55 | //map.addLayers([outline]); | 56 | //map.addLayers([outline]); |
56 | map.zoomToExtent(ext); | 57 | map.zoomToExtent(ext); |
57 | //Note: origin is set at the bottom left corner for OpenLayers !!! | 58 | //Note: origin is set at the bottom left corner for OpenLayers !!! |
58 | map.setCenter(new OpenLayers.LonLat(-900, 3650), 0, true, true) ; | 59 | map.setCenter(new OpenLayers.LonLat(0, 3650), 0, true, true) ; |
59 | } | 60 | } |
60 | 61 | ||
61 | </script> | 62 | </script> |