County Outlines Mod/Creating Outline Files
From TNG Wiki
The County Outlines Mod allows use of cfile in addition to the auto detect mod for US and Canadian counties. You can create other outlines for any geopolitical feature, such as for the Regions or Departments in France.
The Mod is able to parse data in three related formats -- KMZ, KML and XML. Instructions for creating files in all three formats are listed below. See bottom of page for additional online map resources.
Creating and using Keyhole Markup Language (KML) Outlines
Keyhole Markup Language (KML) is the standard used by Google Earth for creating custom shapes and features. See Google Earth tutorial for more information about the contents of the .kml file.
KML is now the preferred format for map outlines in the TNG County Outlines Mod.
To create an outline in KML format:
- Click on the outline option in Google Earth
- Follow the outline of the county or other boundary in Google Earth and click to create the polygon for the outline. For example, Google Earth will show you current county or regions of France outlines when zoomed in far enough, so it is easy to place the points on the map by following the lines.
- Save the polygon file using the Save Place As option, once you have the complete shape.
- From the file type prompt, select KML. (Note that default file type is .kmz)
If you are unable to save the file in KML format, save as KMZ and follow these additional steps:
- Rename the .kmz file to .zip.
- Unzip the file and extract 'doc.kml'.
- Rename doc.kml to something appropriate. You can now delete the .kmz file.
Your file is now ready to use.
Creating and using KMZ Outlines
Keyhole Markup Zip (KMZ) files are compressed mapping files produced by Google Earth. Their primary purpose is to serve as a package file for complex mapping or drawing projects that utilize both vector and raster data. See Google's KMZ tutorial for more information about the format.
Google Maps, such as those used within TNG, can only display a subset of the features available within the KMZ format, so it is recommended that you convert the KMZ file into a KML file by following the steps listed above. However, if you obtain KMZ files from a third-party source that has additional data beyond a KML file, you can also use them directly with the Outlines Mod.
Make sure the KMZ file has an appropriate file name. Your file is ready to use.
NOTE: Due to the way Google servers must fetch and parse them, KMZ files are unable to be displayed on localhost installations. KML and XML files do not have this limitation and can be displayed in any server setting.
Creating XML Outlines
Previously, XML-based polygon files were the only option available for drawing polygon shapes onto Google Map images.Thus the original version of the US County Boundaries Mod was written to read this format, and all of the US County Boundaries provided by Bret Rumsey are in this format. The polygon XML format is a derivative of KML format. Although the current County Outlines Mod continues to read this format, there is no advantage to using this format over KML, and the use of KML is now preferred due to ease of file creation.
If you want to create polygon XML files, first follow the steps listed above to create a KML shape within Google Earth. (If you have a .KMZ file, rename it to .zip, unzip it and extract the doc.kml file.))
Editing the KML
You must manually edit the .kml file to convert it into the Google Maps polygon XML format.
The easiest way to do this is to use a text editor that offers a find/replace all function.
- Remove the extraneous lines from the Google Earth doc.kml.
- Manually add the <boundary> <polygon> lines as a replacement for <coordinates>
- Manually add the ending </polygon> </boundary> as a replacement for the </coordinate
- Manually add the <pt lng=" before the first longitude coordinate
- Replace all instances of the string ,0 with " /> <pt lng=" (replacement string includes the double quotes and a line-feed. Hint: use copy from a known .xml file and paste the string in the Replace With input field)
- Replace all instances of <pt lng=" that contains a blank or space between the double quote and the first number of the longitude with <pt lng=" (the same string without any spaces after the quotation mark.)
- Replace all , with " lat=" (replacement string includes the double quotes.) Hint: use copy from a known .xml file and paste the string in the Replace With input field
- Remove the extraneous <pt lng=" string before the </polygon> line
- Save the file as county-name.xml
The resultant file should look like the following
<boundary> <polygon> <pt lng="-0.04890072185177896" lat="47.11330564897132" /> <pt lng="-0.07382456621640499" lat="47.06483820872138" /> ... <pt lng="-0.04890072185177896" lat="47.11330564897132" /> </polygon> </boundary>
Note that the last set of coordinates should be the same as the first set of coordinates.
Save (or rename) the file to an .xml extension (e.g. filename.xml). Your file is ready to use.
Using the new outline file
- Copy the saved outline file to a location within your maps folder.
- Use any subfolder naming convention that makes sense to you and serves to differentiate groups of outlines.
- Update the Place location record by adding cfile:maps/area/outline.kml to the Notes field, where area is the folder name(s) into which you placed the new file. For example, for the Alsace region of France you might have cfile:maps/france/alsace.kml.
CAUTION: In some rare instances, a server will not serve files with unusual file extensions such as .kml and .kmz without modifying .htaccess or the server configuration. In the event that your server has this problem, the easiest workaround is to add .xml to the end of the file names (e.g. filename.kml.xml).