Skip to content

Commit d3f473d

Browse files
committed
update artifical objects
1 parent f26bfa8 commit d3f473d

File tree

1 file changed

+37
-34
lines changed

1 file changed

+37
-34
lines changed

landmarks/tsv2xml.py

+37-34
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@
99
# same directory as the script file.
1010
#
1111
# To generate TSV file go to https://planetarynames.wr.usgs.gov/AdvancedSearch
12-
# Select System: MARS and target: Mars;
12+
# Select System: MARS and target: Mars;
1313
# Under "Columns to include": add column 'Feature Type Code';
1414
# Click 'Search'
15-
# Scroll down to the bottom and click 'TSV (tab separated values) for importing into other spread sheets'
16-
# Save the file as SearchResults in the same directory as this script.
15+
# Scroll down to the bottom and click 'TSV (tab separated values) for importing into other spread sheets'
16+
# Save the file as SearchResults in the same directory as this script.
1717
# Usage : 'python tsv2xml.py' and the resulting file landmarks.xml is fit for use with MSP
1818
# when put in the correct directory
1919

20-
# TODO:
20+
# TODO:
2121
# Insert doctype - <!DOCTYPE landmark-list SYSTEM "conf/dtd/landmarks.dtd">
2222
# Add parameters
2323
# Refactor
2424

2525
from xml.dom.minidom import Document
2626
from decimal import Decimal
2727

28-
# Initialize types
28+
# Initialize types
2929
xmldoc = Document()
3030
# in case we don't have a key line (bad!), assume some default field indices
3131
index_feature_name = 0
@@ -39,14 +39,14 @@
3939
index_approval = 8
4040
index_origin = 9
4141

42-
# Add introductory comments
42+
# Add introductory comments
4343
introcomment1 = xmldoc.createComment("Landmark coordinates from USGS Astrogeology Research Program")
4444
introcomment2 = xmldoc.createComment("https://planetarynames.wr.usgs.gov/AdvancedSearch")
4545
introcomment3 = xmldoc.createComment("Landmarks to be displayed in the user interface. ")
4646
xmldoc.appendChild(introcomment1)
4747
xmldoc.appendChild(introcomment2)
4848
xmldoc.appendChild(introcomment3)
49-
49+
5050
# Create the base XML element
5151
landmarks = xmldoc.createElement("landmark-list")
5252
#landmarks.setAttribute("xmlns", "http://mars-sim.sourceforge.net/landmarks")
@@ -61,7 +61,7 @@
6161
tsvlinelist = f.readlines() # fill a list with TSV lines
6262

6363
# Main parsing loop
64-
for tsvline in tsvlinelist:
64+
for tsvline in tsvlinelist:
6565
if tsvline == "\n":
6666
print "Skipped empty line..." # ignore empty lines
6767
elif "Feature_Name" in tsvline:
@@ -81,20 +81,20 @@
8181
else:
8282
print "Found data line, parsing..." #ready to move data into XML DOM
8383
valuelist = tsvline.split("\t") # explode into a list of values
84-
84+
8585
landmark = xmldoc.createElement("landmark")
86-
86+
8787
namestring = valuelist[index_feature_name]
8888
namestring = namestring.replace('[', '')
8989
namestring = namestring.replace(']', '')
9090
landmark.setAttribute("name", namestring) # Feature_Name
91-
91+
9292
landmark.setAttribute("diameter", valuelist[index_diameter]) # Diameter of feature
9393
# Center_Longitude
9494
if Decimal(valuelist[index_long]) > 180:
9595
landmark.setAttribute("longitude", str((360 - Decimal(valuelist[index_long])))+" W")
9696
else:
97-
landmark.setAttribute("longitude", str((Decimal(valuelist[index_long])))+" E")
97+
landmark.setAttribute("longitude", str((Decimal(valuelist[index_long])))+" E")
9898
# Center_Latitude
9999
if Decimal(valuelist[index_lat]) < 0:
100100
landmark.setAttribute("latitude", str(abs(Decimal(valuelist[index_lat])))+" S")
@@ -107,37 +107,40 @@
107107
landmarks.appendChild(landmark)
108108

109109

110-
# Add fixed external data for artificial objects (from Google Mars and Wikipedia)
110+
# Add fixed external data for artificial objects
111+
# Source: https://en.wikipedia.org/wiki/List_of_artificial_objects_on_Mars#Table_of_objects
111112
artobjcomment = xmldoc.createComment("Artificial Objects")
112113
landmarks.appendChild(artobjcomment)
113114

114-
artobjarray =[["Beagle 2 Lander", "90.0 E", "10.6 N", "0.1"],
115-
["Mars 2 Lander", "47.0 E", "45.0 S", "0.1"],
116-
["Mars 3 Lander", "158.0 W", "45.0 S", "0.1"],
117-
["Mars 6 Lander", "19.5 W", "23.9 S", "0.1"],
118-
["Mars Pathfinder Rover", "33.3 W", "19.3 N", "0.1"],
119-
["Mars Polar Lander", "164.7 E", "76.7 S", "0.1"],
120-
["MSL Curiosity Rover", "137.2 E", "4.3 S", "0.1"],
121-
["MER Spirit Rover", "175.47 E", "14.57 S", "0.1"],
122-
["MER Opportunity Rover", "5.53 W", "1.95 S", "0.1"],
123-
["Phoenix Mars Lander", "125.7 W", "68.22 N", "0.1"],
124-
["Viking Lander 1", "48.0 W", "22.5 N", "0.1"],
125-
["Viking Lander 2", "133.7 E", "47.9 N", "0.1"]]
126-
127-
for artobj in artobjarray:
115+
artobjarray =[["Mars 2", "313.0 W", "45.0 S", "0.1"],
116+
["Mars 3", "158.0 W", "45.0 S", "0.1"],
117+
["Mars 6", "19.42 W", "23.9 S", "0.1"],
118+
["Viking 1 Lander", "48.222 W", "22.697 N", "0.1"],
119+
["Viking 2 Lander", "225.99 W", "48.269 N", "0.1"],
120+
["Mars Pathfinder + Sojourner Rover", "33.55 W", "19.33 N", "0.1"],
121+
["Mars Polar Lander + Deep Space 2", "195.0 W", "76.0 S", "0.1"],
122+
["Beagle 2", "90.4295 E", "11.5265 N", "0.1"],
123+
["Spirit Rover (MER-A)", "175.4785 E", "14.5718 S", "0.1"],
124+
["Opportunity Rover (MER-B)", "354.4734 E", "1.9462 S", "0.1"],
125+
["Phoenix Mars Lander", "125.9 W", "68.15 N", "0.1"],
126+
["Mars Science Laboratory (Curiosity)", "137.2 E", "4.6 S", "0.1"],
127+
["Schiaparelli EDM Lander", "357.5 E", "0.2 N", "0.1"],
128+
["inSight Lander", "135.0 E", "4.5 N", "0.1"]]
129+
130+
for artobj in artobjarray:
128131
landmark = xmldoc.createElement("landmark")
129-
landmark.setAttribute("name", artobj[0])
130-
landmark.setAttribute("longitude", artobj[1])
131-
landmark.setAttribute("latitude", artobj[2])
132-
landmark.setAttribute("diameter", artobj[3])
133-
landmark.setAttribute("approvaldate", "N/A")
132+
landmark.setAttribute("name", artobj[0])
133+
landmark.setAttribute("longitude", artobj[1])
134+
landmark.setAttribute("latitude", artobj[2])
135+
landmark.setAttribute("diameter", artobj[3])
136+
landmark.setAttribute("approvaldate", "N/A")
134137
landmark.setAttribute("type", "AO") # artificial object
135-
landmark.setAttribute("origin", "N/A")
138+
landmark.setAttribute("origin", "N/A")
136139

137140
landmarks.appendChild(landmark)
138141

139142
f.close() # close our TSV file stream nicely
140-
143+
141144
# Write out the final XML data to file landmarks.xml
142145
f = open('landmarks.xml', 'w')
143146
xmldoc.writexml(f, encoding= 'utf-8', indent=" ",addindent=" ",newl="\n")

0 commit comments

Comments
 (0)