localMaps.py - Map Background Configuration Override File

September 25, 2012

Organization

Overview
localMaps.py Format
    Header
    Adding new edit areas
    Removing edit areas defined in Maps.py
    Modifying the characteristics of existing edit areas
Placement of the localMaps.py file
Updating Map Shapefiles

Overview

The localMaps.py file provides a mechanism for a site to override entries in the supplied Maps.py file. New edit areas may be added, edit areas may be removed from the list, and existing edit area attributes may be changed. Refer to the Maps.py for the definition of the edit area attributes and how they are used. This document will explain how to add, remove, and modify edit areas.

See the server configuration overview for information on how to make changes that are supported to the map backgrounds.


localMaps.py Format

Example localMaps.py configuration file

Header

The localMaps.py file must begin with the following line. This line instructs the software to import all symbols from the primary Maps.py. Failure to include this line will result in your modifications not being recognized by the software:

from Maps import *
 

Adding New Edit Areas

New edit areas can be added through localMaps.py. Refer to the syntax requirements of defining a map in the Maps.py document. There is one additional line that is very important to add (i.e., the append line) in order for the system to recognize the new edit areas. It is also important NOT to duplicate the Python variable name (i.e., the name left of the equals ("=") sign) of any Python variable in the Maps.py file. For example, if a map is defined as "CWAzones = ..." in Maps.py, do not create a variable that says "CWAzones = ..." in the localMaps.py file. Note that this restriction is for adding new edit areas. If you are overriding the characteristics of edit areas that are already defined in Maps.py, then you will need to use the same Python variable name.

Here is an example of including a set of automatic edit areas for counties in Wyoming in group WYCounties):

WYcounties = ShapeTable('County')
WYcounties.name = 'WYCounties'
WYcounties.filter(lambda x : x['state'] == "WY") 
WYcounties.editAreaName = ['state','countyname'] 
WYcounties.groupName = 'WYCounties' 
maps.append(WYcounties)

In the above example, edit areas will be generated for all counties where attribute STATE equals "WY". The generated edit areas will have names of the form STATE_COUNTYNAME and will be part of the WYCounties edit area group. The very last line appends this new definition to the list of edit areas to be generated.

Note that if your new map background is using a new shapefile, you will also need to import the shape file into the maps database. Refer to section Map Files - Map Background Shapefile Handling

Example localMaps.py configuration file

Removing edit areas defined in Maps.py

Removing a map that is defined in Maps.py, but not desired is easy. Find the Python variable name of the map you wish to remove by examining Maps.py.  The python variable name is the name to the left of the "equals" ('=') sign.

For example, if you did not want to generate the marine zones, find the marine zones definition in Maps.py.  There are actually two maps generated. The identifiers are CWAmzones and Mzones. The following text would be included within localMaps.py:

maps.remove(CWAmzones)
maps.remove(Mzones)

Example localMaps.py configuration file

Modifying the characteristics of existing edit areas

You can modify the following characteristics of the map definition:

Database Table Name

If you want to change the name of the database table used for edit area generation, you will need to remove the existing definition and create a completely new map definition.

Name of the Map Background

The format of the line is identical to that found in Maps.py.  Simply repeat the line you want to change and then put the new map name. For example, if you want to change the CWAzones map name to MyCWAZones, you would add the following line to localMaps.py:
CWAzones.name = "MyCWAZones"
Note: this name is only used in text formatter definitions in the mapNameForCombinations setting.

Filter Changes

The format of the line is identical to that found in Maps.py.  Simply repeat the line you want to change and then put in the new filter string.  For example, if you want to change the CWAzones filter from all zones for the CWA to all zones for the state of Ohio, you would add the following line to localMaps.py:

CWAzones.filter(lambda x : x['state'] == "OH")

You can also use any of the alternate methods of specifying the filter as described in Maps.py. This shows much more complex types of filters than this file.

If you want to turn filtering off completely for a map, you will need to remove the existing definition and create a completely new map definition.

Attribute names in the database are all stored in lower case. 

Generation of Edit Area Changes

Name Changes

The format of the line is identical to that found in Maps.py. Simply repeat the line you want to change and then put in the new editAreaName definition. For example if you want the edit areas to be named using the contents of the 'cwa' attribute of the database record you would add the following line ot localMaps.py:

CWAzones.editAreaName = 'cwa'

For detailed examples of editAreaName configuration refer to Maps.py.

Note: if the generated edit area names are not unique undesirable results may occur.

Group Name for the Edit Areas

To have the generated edit areas included in an edit area group simply supply the group name as a string.

CWAzones.groupName = 'MyZones'

If you don't want the edit areas to be included in a group supply an empty string:

CWAzones.groupName = ''

Example localMaps.py configuration file


Placement of the localMaps.py file

The localMaps.py file should always be placed in the /awips2/edex/data/utility/edex_static/site/OAX/config/gfe/ directory on dx3/dx4 as explained here.


Updating Map Shapefiles

Map shape file updates must be imported into the maps database using the importShapeFile.sh script on dx1. Refer to section Map Files - Map Background Shapefile Handling
 



 
 
 Back To Top
 Back To TOC