From 0554e1a18bfb3bdb60cfe4754fd762cef2927a05 Mon Sep 17 00:00:00 2001 From: Serge Barbosa Da Torre Date: Fri, 3 May 2019 08:21:39 -0700 Subject: [PATCH 1/2] Python3 support. Both python2 and Python3 now supported. This is minimal set of required changes. Notes: - examples have been run on both version and provides identical results. - unit test now working on both. It is possible however that failure is reported, just because of order in tags (this may depend on lxml version used). Content is same. Proper way would be to change how the test are asserted, but the effort is too big for me right now. - tested with older lxml version 3.3.6. Could not test with older version as I could not install those properly. --- setup.py | 4 +- .../KmlReference/altitudemode_reference.py | 6 +- .../KmlReference/animatedupdate_example.py | 8 +- src/examples/Tours/circle_around_landmarks.py | 6 +- src/examples/Tours/example_spline_camera.py | 6 +- .../working_files/tour_from_linestring.py | 6 +- src/examples/data_conversion/eqs7day-M2.5.txt | 333 ++++++++++++++++++ .../data_conversion/example_csv_to_kml.py | 13 +- .../misc/base_jump/virtual_base_jump.py | 11 +- .../hello_world_1_simple_placemark.py | 3 +- .../hello_world/hello_world_2_spiral_words.py | 2 +- .../hello_world_3_spiral_characters.py | 2 +- .../hello_world/hello_world_4_gateway_arch.py | 2 +- .../hello_world/hello_world_5_globe_scale.py | 2 +- src/examples/misc/pyephem/pyephem_example.py | 7 +- src/pykml/factory.py | 51 +-- src/pykml/helpers.py | 24 +- src/pykml/parser.py | 42 +-- src/pykml/test/test_factory.py | 117 +++--- src/pykml/test/test_helpers.py | 72 ++-- src/pykml/test/test_parser.py | 79 +++-- src/pykml/test/test_util.py | 73 ++-- src/pykml/util.py | 66 ++-- src/utilities/kml2pykml.py | 8 +- src/utilities/test_gen_pykml.py | 120 ++++--- 25 files changed, 715 insertions(+), 348 deletions(-) create mode 100644 src/examples/data_conversion/eqs7day-M2.5.txt diff --git a/setup.py b/setup.py index 99e8d5f..fec95e7 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ except ImportError: from distutils.core import setup -version = '0.1.3' +version = '0.2.0' setup( name='pykml', @@ -21,7 +21,7 @@ ], }, install_requires=[ - 'lxml>=2.2.6', + 'lxml>=3.3.6', ], tests_require=['nose'], description="Python KML library", diff --git a/src/examples/KmlReference/altitudemode_reference.py b/src/examples/KmlReference/altitudemode_reference.py index e923676..f5cf553 100644 --- a/src/examples/KmlReference/altitudemode_reference.py +++ b/src/examples/KmlReference/altitudemode_reference.py @@ -36,11 +36,11 @@ ) ) -print etree.tostring(doc, pretty_print=True) +print(etree.tostring(doc, pretty_print=True).decode()) # output a KML file (named based on the Python script) -outfile = file(__file__.rstrip('.py')+'.kml','w') -outfile.write(etree.tostring(doc, pretty_print=True)) +with open(__file__.rstrip('.py')+'.kml','w') as outfile: + outfile.write(etree.tostring(doc, pretty_print=True).decode()) assert Schema('kml22gx.xsd').validate(doc) diff --git a/src/examples/KmlReference/animatedupdate_example.py b/src/examples/KmlReference/animatedupdate_example.py index 6ed2431..204feec 100644 --- a/src/examples/KmlReference/animatedupdate_example.py +++ b/src/examples/KmlReference/animatedupdate_example.py @@ -71,12 +71,12 @@ ) ) -print etree.tostring(doc, pretty_print=True) +print(etree.tostring(doc, pretty_print=True).decode()) # output a KML file (named based on the Python script) -outfile = file(__file__.rstrip('.py')+'.kml','w') -outfile.write(etree.tostring(doc, pretty_print=True)) + +with open(__file__.rstrip('.py')+'.kml','w') as outfile: + outfile.write(etree.tostring(doc, pretty_print=True).decode()) schema = Schema('kml22gx.xsd') -import ipdb; ipdb.set_trace() schema.validate(doc) diff --git a/src/examples/Tours/circle_around_landmarks.py b/src/examples/Tours/circle_around_landmarks.py index fd8a54b..9db296e 100644 --- a/src/examples/Tours/circle_around_landmarks.py +++ b/src/examples/Tours/circle_around_landmarks.py @@ -194,8 +194,4 @@ # check that the KML document is valid using the Google Extension XML Schema assert(Schema("kml22gx.xsd").validate(tour_doc)) -print etree.tostring(tour_doc, pretty_print=True) - -# output a KML file (named based on the Python script) -outfile = file(__file__.rstrip('.py')+'.kml','w') -outfile.write(etree.tostring(tour_doc, pretty_print=True)) +print(etree.tostring(tour_doc, pretty_print=True).decode()) diff --git a/src/examples/Tours/example_spline_camera.py b/src/examples/Tours/example_spline_camera.py index f05173b..f41bdec 100644 --- a/src/examples/Tours/example_spline_camera.py +++ b/src/examples/Tours/example_spline_camera.py @@ -158,8 +158,8 @@ def interpolate_location_series( ): '''Estimate location data structures based on interpolation''' nKnownPositions = len(known_positions) - x = range(nKnownPositions) - x_new = [1.0*i*(nKnownPositions-1)/number_of_positions for i in range(number_of_positions)] + x = list(range(nKnownPositions)) + x_new = [(1.0*i*(nKnownPositions-1))/number_of_positions for i in range(number_of_positions)] # interpolate locations # create an interpolation object @@ -301,7 +301,7 @@ def main(): GX.Tour(playlist), ) - print etree.tostring(fld, pretty_print=True) + print(etree.tostring(fld, pretty_print=True).decode()) if __name__=='__main__': diff --git a/src/examples/Tours/working_files/tour_from_linestring.py b/src/examples/Tours/working_files/tour_from_linestring.py index 6f6d206..afb256b 100644 --- a/src/examples/Tours/working_files/tour_from_linestring.py +++ b/src/examples/Tours/working_files/tour_from_linestring.py @@ -46,8 +46,8 @@ tour_doc[gxns+"Tour"].Playlist.append(flyto) assert Schema('kml22gx.xsd').validate(tour_doc) -print etree.tostring(tour_doc, pretty_print=True) +print(etree.tostring(tour_doc, pretty_print=True).decode()) # output a KML file (named based on the Python script) -outfile = file(__file__.rstrip('.py')+'.kml','w') -outfile.write(etree.tostring(tour_doc, pretty_print=True)) +with open(__file__.rstrip('.py')+'.kml','wb') as outfile: + outfile.write(etree.tostring(tour_doc, pretty_print=True)) diff --git a/src/examples/data_conversion/eqs7day-M2.5.txt b/src/examples/data_conversion/eqs7day-M2.5.txt new file mode 100644 index 0000000..7f48885 --- /dev/null +++ b/src/examples/data_conversion/eqs7day-M2.5.txt @@ -0,0 +1,333 @@ +Src,Eqid,Version,Datetime,Lat,Lon,Magnitude,Depth,NST,Region +us,c000f3m0,6,"Thursday, February 7, 2013 22:48:00 UTC",29.2528,142.0034,4.8,33.30,46,"Izu Islands, Japan region" +us,c000f3l3,6,"Thursday, February 7, 2013 21:56:24 UTC",-10.8926,165.6023,4.8,10.00,23,"Santa Cruz Islands" +us,c000f3kk,8,"Thursday, February 7, 2013 21:40:56 UTC",-10.9014,165.7376,5.1,25.50,64,"Santa Cruz Islands" +us,c000f3k8,4,"Thursday, February 7, 2013 21:38:25 UTC",-4.3774,142.9916,5.1,97.80,126,"New Guinea, Papua New Guinea" +us,c000f3jb,7,"Thursday, February 7, 2013 20:51:52 UTC",-10.8904,165.0677,4.9,10.00,34,"Santa Cruz Islands" +us,c000f3iy,7,"Thursday, February 7, 2013 20:45:18 UTC",-10.9088,165.7732,5.0,10.00,38,"Santa Cruz Islands" +us,c000f3im,5,"Thursday, February 7, 2013 20:41:37 UTC",-0.3891,124.3559,4.7,48.00,35,"Molucca Sea" +us,c000f3i3,7,"Thursday, February 7, 2013 20:20:06 UTC",-10.8555,165.7064,5.2,10.00,208,"Santa Cruz Islands" +uu,60012622,8,"Thursday, February 7, 2013 20:02:21 UTC",37.7883,-113.1242,3.5,2.10,23,"Utah" +us,c000f3hb,9,"Thursday, February 7, 2013 19:48:19 UTC",-10.8719,165.7172,5.5,10.20,237,"Santa Cruz Islands" +us,c000f3h3,6,"Thursday, February 7, 2013 19:43:12 UTC",-11.0228,165.6294,4.9,10.00,21,"Santa Cruz Islands" +uu,60012602,4,"Thursday, February 7, 2013 19:29:55 UTC",37.8040,-113.1058,3.1,2.40,24,"Utah" +us,c000f3gf,6,"Thursday, February 7, 2013 19:25:15 UTC",-10.9828,165.6772,5.0,9.90,28,"Santa Cruz Islands" +us,c000f3fx,A,"Thursday, February 7, 2013 18:59:16 UTC",-11.0010,165.6582,6.6,10.00,356,"Santa Cruz Islands" +us,c000f3es,4,"Thursday, February 7, 2013 17:59:00 UTC",-10.9392,165.5208,4.8,10.00,28,"Santa Cruz Islands" +pr,13038004,0,"Thursday, February 7, 2013 17:58:48 UTC",18.8400,-67.2502,2.9,11.00,17,"Puerto Rico region" +us,c000f3f4,2,"Thursday, February 7, 2013 17:49:46 UTC",-11.2378,165.9213,5.1,14.20,41,"Santa Cruz Islands" +pr,13038005,0,"Thursday, February 7, 2013 17:21:47 UTC",18.4883,-65.2873,2.6,102.00, 7,"Puerto Rico region" +us,c000f3c5,5,"Thursday, February 7, 2013 15:37:28 UTC",-21.0867,-67.4252,4.3,173.20,17,"Potosi, Bolivia" +us,c000f3bw,7,"Thursday, February 7, 2013 15:22:39 UTC",-5.6218,103.2605,4.7,63.30,80,"southern Sumatra, Indonesia" +us,c000f3bj,6,"Thursday, February 7, 2013 15:05:11 UTC",-11.0103,165.5869,5.0,35.00,96,"Santa Cruz Islands" +nc,71933130,5,"Thursday, February 7, 2013 15:04:39 UTC",37.4060,-118.6000,3.0,12.00,44,"Central California" +us,c000f37s,6,"Thursday, February 7, 2013 14:05:56 UTC",-11.0284,164.8161,5.0,10.10,154,"Santa Cruz Islands region" +us,c000f36f,8,"Thursday, February 7, 2013 13:46:36 UTC",-10.8257,165.6754,4.8,10.00,34,"Santa Cruz Islands" +us,c000f37u,5,"Thursday, February 7, 2013 13:23:18 UTC",-10.7679,165.4337,4.8,16.20,43,"Santa Cruz Islands" +us,c000f357,7,"Thursday, February 7, 2013 12:36:49 UTC",-10.8226,165.1734,5.1,10.20,158,"Santa Cruz Islands" +us,c000f34k,4,"Thursday, February 7, 2013 11:30:16 UTC",-8.6870,168.2685,4.9,15.20,85,"Santa Cruz Islands region" +ak,10652163,2,"Thursday, February 7, 2013 11:16:31 UTC",55.9614,-135.2848,3.5,10.00,18,"off the coast of Southeastern Alaska" +us,c000f33p,7,"Thursday, February 7, 2013 10:23:29 UTC",-10.6720,164.8745,4.8,21.30,45,"Santa Cruz Islands region" +pr,13038002,0,"Thursday, February 7, 2013 10:14:30 UTC",18.7940,-64.4465,3.2,53.00,18,"Virgin Islands region" +us,c000f33h,6,"Thursday, February 7, 2013 09:50:08 UTC",-11.0482,164.8198,4.7,10.00,78,"Santa Cruz Islands region" +pr,13038003,0,"Thursday, February 7, 2013 09:40:38 UTC",18.5946,-65.1986,2.6,78.00, 4,"Puerto Rico region" +ak,10652144,1,"Thursday, February 7, 2013 09:39:04 UTC",66.0747,-148.2291,3.1,0.10,23,"northern Alaska" +us,c000f33e,4,"Thursday, February 7, 2013 09:36:54 UTC",-6.6073,-74.2908,4.5,163.10,170,"northern Peru" +us,c000f32s,4,"Thursday, February 7, 2013 08:20:42 UTC",-10.6902,164.5970,4.7,10.20,61,"Santa Cruz Islands region" +us,c000f329,8,"Thursday, February 7, 2013 08:03:41 UTC",-11.0249,164.7498,6.1,10.00,259,"Santa Cruz Islands region" +us,c000f32b,5,"Thursday, February 7, 2013 08:03:30 UTC",0.2447,98.4976,4.9,35.20,48,"Nias region, Indonesia" +us,c000f323,6,"Thursday, February 7, 2013 07:38:18 UTC",-33.6530,77.5848,4.8,10.00,29,"Mid-Indian Ridge" +us,c000f31w,9,"Thursday, February 7, 2013 07:19:51 UTC",-15.5859,-173.1416,5.1,10.00,330,"Tonga" +us,c000f31u,8,"Thursday, February 7, 2013 07:11:19 UTC",-10.9718,165.4921,5.3,10.00,224,"Santa Cruz Islands" +pr,13038001,0,"Thursday, February 7, 2013 06:40:01 UTC",18.7285,-64.2799,2.9,41.00, 6,"Virgin Islands region" +us,c000f30l,7,"Thursday, February 7, 2013 05:27:40 UTC",-21.1997,-176.5650,4.5,229.70,42,"Fiji region" +pr,13038000,0,"Thursday, February 7, 2013 05:20:25 UTC",17.1096,-68.4903,3.7,9.00,15,"Dominican Republic region" +us,c000f306,4,"Thursday, February 7, 2013 03:52:56 UTC",-11.6689,165.0499,5.0,35.00,33,"Santa Cruz Islands" +ak,10652037,1,"Thursday, February 7, 2013 03:21:37 UTC",60.2454,-152.1069,2.5,79.00,30,"Southern Alaska" +us,c000f2zp,6,"Thursday, February 7, 2013 02:59:59 UTC",-11.4297,165.2040,4.9,35.00,90,"Santa Cruz Islands" +us,c000f2ze,6,"Thursday, February 7, 2013 02:56:29 UTC",-10.7355,165.4421,4.9,27.20,128,"Santa Cruz Islands" +us,c000f2zc,5,"Thursday, February 7, 2013 02:46:08 UTC",-10.7669,165.2654,4.8,24.60,54,"Santa Cruz Islands" +us,c000f2zq,3,"Thursday, February 7, 2013 02:42:29 UTC",-11.7530,164.9502,4.9,26.60,111,"Santa Cruz Islands region" +us,c000f2z4,5,"Thursday, February 7, 2013 02:17:24 UTC",-10.6360,164.8235,5.2,52.00,37,"Santa Cruz Islands region" +ak,10651728,1,"Thursday, February 7, 2013 01:09:13 UTC",64.0548,-148.9331,2.6,12.40,23,"Central Alaska" +us,c000f2w6,4,"Thursday, February 7, 2013 01:00:48 UTC",-11.8187,164.8241,5.2,34.20,124,"Santa Cruz Islands region" +us,c000f2x3,3,"Thursday, February 7, 2013 00:56:47 UTC",-11.6668,164.7825,5.1,35.10,75,"Santa Cruz Islands region" +us,c000f2vc,7,"Thursday, February 7, 2013 00:41:31 UTC",1.4251,98.9348,5.1,82.80,64,"northern Sumatra, Indonesia" +us,c000f2ul,8,"Thursday, February 7, 2013 00:30:11 UTC",-11.6644,164.9605,6.2,9.80,243,"Santa Cruz Islands region" +ak,10651692,2,"Thursday, February 7, 2013 00:28:31 UTC",52.8649,-173.6003,2.8,162.90,16,"Andreanof Islands, Aleutian Islands, Alaska" +us,c000f2u2,4,"Thursday, February 7, 2013 00:16:27 UTC",-10.8264,164.8772,4.8,24.70,30,"Santa Cruz Islands region" +us,c000f2u6,4,"Wednesday, February 6, 2013 23:49:35 UTC",-11.7702,164.9420,5.2,10.50,156,"Santa Cruz Islands region" +us,c000f2t0,6,"Wednesday, February 6, 2013 23:39:00 UTC",-11.7665,164.7872,5.0,10.50,105,"Santa Cruz Islands region" +us,a000g2qw,9,"Wednesday, February 6, 2013 23:30:27 UTC",-10.7753,165.0334,5.0,10.20,30,"Santa Cruz Islands" +us,c000f2sb,9,"Wednesday, February 6, 2013 23:23:52 UTC",-10.8612,165.3045,4.8,9.40,28,"Santa Cruz Islands" +us,c000f2qd,3,"Wednesday, February 6, 2013 22:24:26 UTC",-10.9567,165.4408,5.0,10.00,41,"Santa Cruz Islands" +us,c000f2pu,6,"Wednesday, February 6, 2013 22:20:18 UTC",-11.0906,165.6663,5.5,9.90,180,"Santa Cruz Islands" +us,c000f2p0,6,"Wednesday, February 6, 2013 22:12:18 UTC",-1.4833,100.3221,5.5,11.30,153,"southern Sumatra, Indonesia" +us,c000f2qj,5,"Wednesday, February 6, 2013 22:07:39 UTC",-12.1541,165.9952,4.9,10.00,22,"Santa Cruz Islands" +us,c000f2mw,5,"Wednesday, February 6, 2013 21:37:36 UTC",-11.1909,165.7415,4.9,10.30,66,"Santa Cruz Islands" +us,c000f2kw,7,"Wednesday, February 6, 2013 20:42:31 UTC",-23.2246,170.8554,5.1,10.20,61,"southeast of the Loyalty Islands" +us,c000f2kf,5,"Wednesday, February 6, 2013 20:18:40 UTC",46.5060,-27.3727,5.0,14.10,201,"northern Mid-Atlantic Ridge" +nc,71932655,3,"Wednesday, February 6, 2013 19:49:46 UTC",37.3857,-118.6765,2.6,14.20,52,"Central California" +us,c000f2iq,6,"Wednesday, February 6, 2013 19:01:49 UTC",34.3205,80.4633,4.9,35.10,100,"western Xizang" +uu,60012507,4,"Wednesday, February 6, 2013 18:47:01 UTC",37.7835,-113.1282,2.7,7.50,21,"Utah" +us,c000f2hu,8,"Wednesday, February 6, 2013 18:24:57 UTC",36.6169,71.0637,4.1,211.60,18,"Hindu Kush region, Afghanistan" +us,c000f2ht,4,"Wednesday, February 6, 2013 18:17:33 UTC",-11.0696,165.0121,4.9,10.00,27,"Santa Cruz Islands" +us,c000f2ha,6,"Wednesday, February 6, 2013 18:03:20 UTC",-11.1782,165.6276,5.0,10.10,71,"Santa Cruz Islands" +us,c000f2gj,6,"Wednesday, February 6, 2013 17:19:31 UTC",-11.6450,165.0366,5.0,10.10,103,"Santa Cruz Islands" +pr,13037006,0,"Wednesday, February 6, 2013 17:07:15 UTC",19.5480,-64.2500,3.0,65.00, 4,"Virgin Islands region" +us,c000f2g3,7,"Wednesday, February 6, 2013 17:04:08 UTC",-10.6932,164.8863,5.0,10.00,88,"Santa Cruz Islands region" +us,2013lhc8,5,"Wednesday, February 6, 2013 16:39:30 UTC",-10.6779,164.8121,5.0,10.00,37,"Santa Cruz Islands region" +us,c000f2fg,7,"Wednesday, February 6, 2013 16:35:53 UTC",-11.2953,165.6319,5.0,10.10,65,"Santa Cruz Islands" +us,2013lhc3,6,"Wednesday, February 6, 2013 16:10:14 UTC",30.8791,50.0596,4.3,35.00,31,"southern Iran" +nc,71932550,5,"Wednesday, February 6, 2013 16:05:49 UTC",36.5915,-121.0515,2.7,8.00,72,"Central California" +us,c000f2eh,8,"Wednesday, February 6, 2013 15:54:14 UTC",-10.9314,165.4275,5.3,10.10,96,"Santa Cruz Islands" +us,c000f2ed,5,"Wednesday, February 6, 2013 15:30:25 UTC",-10.8116,164.4872,5.0,10.00,75,"Santa Cruz Islands region" +us,2013lhc1,6,"Wednesday, February 6, 2013 14:24:04 UTC",-11.2521,165.1164,5.1,10.00,106,"Santa Cruz Islands" +us,c000f2dm,7,"Wednesday, February 6, 2013 14:20:57 UTC",-10.9474,165.4419,5.3,10.00,181,"Santa Cruz Islands" +pr,13037005,0,"Wednesday, February 6, 2013 14:18:29 UTC",18.6811,-65.0030,2.5,56.00, 6,"Virgin Islands region" +us,2013lhcy,5,"Wednesday, February 6, 2013 14:03:50 UTC",-11.3454,165.0694,5.0,10.00,85,"Santa Cruz Islands" +us,c000f2d8,B,"Wednesday, February 6, 2013 13:54:53 UTC",-10.7976,166.4922,6.0,10.10,329,"Santa Cruz Islands" +us,c000f2db,7,"Wednesday, February 6, 2013 13:50:32 UTC",-10.5330,166.3853,5.3,10.00,106,"Santa Cruz Islands" +us,2013lhcv,6,"Wednesday, February 6, 2013 13:37:05 UTC",-11.0929,165.0820,4.9,10.00,34,"Santa Cruz Islands" +us,c000f2cb,7,"Wednesday, February 6, 2013 12:58:46 UTC",-11.2620,165.7756,4.9,10.00,53,"Santa Cruz Islands" +us,c000f2bn,7,"Wednesday, February 6, 2013 12:44:29 UTC",-11.5825,165.4990,5.5,9.80,239,"Santa Cruz Islands" +us,c000f2cd,3,"Wednesday, February 6, 2013 12:31:55 UTC",-1.0409,146.9225,4.9,34.50,67,"Admiralty Islands region, Papua New Guinea" +nc,71932465,3,"Wednesday, February 6, 2013 12:28:51 UTC",40.1672,-121.1212,2.6,0.00,52,"Northern California" +us,c000f2c8,4,"Wednesday, February 6, 2013 12:04:40 UTC",-10.7915,165.9433,4.9,10.10,23,"Santa Cruz Islands" +us,c000f2ap,6,"Wednesday, February 6, 2013 11:53:54 UTC",-11.2545,165.7341,5.9,9.90,258,"Santa Cruz Islands" +us,c000f2aa,7,"Wednesday, February 6, 2013 11:24:02 UTC",-10.7979,164.5798,5.1,9.90,106,"Santa Cruz Islands region" +pr,13037004,0,"Wednesday, February 6, 2013 11:05:13 UTC",19.5540,-64.6368,3.3,39.00, 5,"Virgin Islands region" +us,c000f2a4,8,"Wednesday, February 6, 2013 11:03:45 UTC",-10.7296,165.1375,5.6,9.80,281,"Santa Cruz Islands" +us,c000f29g,6,"Wednesday, February 6, 2013 10:33:17 UTC",-10.6358,164.8081,5.7,9.90,241,"Santa Cruz Islands region" +us,c000f2a5,5,"Wednesday, February 6, 2013 10:27:27 UTC",-10.8406,164.7207,4.9,10.00,41,"Santa Cruz Islands region" +us,c000f299,7,"Wednesday, February 6, 2013 10:20:34 UTC",-10.8699,165.2724,5.5,10.00,239,"Santa Cruz Islands" +us,c000f295,6,"Wednesday, February 6, 2013 10:12:30 UTC",-11.1151,165.3794,5.3,10.00,191,"Santa Cruz Islands" +us,c000f28x,6,"Wednesday, February 6, 2013 10:00:15 UTC",-12.0657,165.7949,4.9,10.00,38,"Santa Cruz Islands" +us,c000f280,B,"Wednesday, February 6, 2013 09:24:00 UTC",-10.7176,164.2281,5.2,9.60,135,"Santa Cruz Islands region" +us,c000f27f,8,"Wednesday, February 6, 2013 08:45:04 UTC",-11.6702,165.4684,5.0,10.30,88,"Santa Cruz Islands" +us,c000f27i,4,"Wednesday, February 6, 2013 08:42:27 UTC",-10.9978,165.5009,4.7,10.00,63,"Santa Cruz Islands" +us,c000f26z,5,"Wednesday, February 6, 2013 08:27:04 UTC",-10.7824,165.5308,4.7,9.90,59,"Santa Cruz Islands" +us,c000f26n,6,"Wednesday, February 6, 2013 08:04:35 UTC",-15.9880,-172.2229,5.0,34.00,221,"Samoa Islands region" +us,c000f265,5,"Wednesday, February 6, 2013 07:59:53 UTC",53.6700,-163.2042,4.4,22.20,94,"Unimak Island region, Alaska" +us,c000f269,5,"Wednesday, February 6, 2013 07:57:52 UTC",-11.2867,165.4922,4.9,9.90,62,"Santa Cruz Islands" +us,c000f25x,6,"Wednesday, February 6, 2013 07:42:46 UTC",-11.0007,165.4760,4.8,10.10,66,"Santa Cruz Islands" +us,c000f25k,4,"Wednesday, February 6, 2013 07:35:57 UTC",-10.7439,164.8621,4.7,10.00,34,"Santa Cruz Islands region" +us,c000f25e,3,"Wednesday, February 6, 2013 07:29:30 UTC",-11.5466,165.1588,4.8,10.00,70,"Santa Cruz Islands" +us,c000f255,4,"Wednesday, February 6, 2013 07:23:12 UTC",-10.9010,165.3559,5.0,10.10,120,"Santa Cruz Islands" +us,c000f24t,A,"Wednesday, February 6, 2013 07:13:48 UTC",-10.6371,165.3050,5.3,10.10,212,"Santa Cruz Islands" +us,c000f246,7,"Wednesday, February 6, 2013 06:53:20 UTC",-10.6348,164.9673,5.6,10.00,281,"Santa Cruz Islands region" +us,c000f23y,6,"Wednesday, February 6, 2013 06:35:19 UTC",-10.7840,164.5123,6.3,10.10,284,"Santa Cruz Islands region" +us,c000f23d,7,"Wednesday, February 6, 2013 06:09:37 UTC",-11.0714,164.8114,5.2,10.00,145,"Santa Cruz Islands region" +us,c000f236,8,"Wednesday, February 6, 2013 06:02:36 UTC",-10.7797,164.5710,5.2,10.00,122,"Santa Cruz Islands region" +us,c000f230,9,"Wednesday, February 6, 2013 05:58:41 UTC",-10.7997,165.2312,4.9,10.10,104,"Santa Cruz Islands" +us,c000f22s,9,"Wednesday, February 6, 2013 05:48:54 UTC",-11.0656,164.7565,5.2,10.30,52,"Santa Cruz Islands region" +us,c000f22z,4,"Wednesday, February 6, 2013 05:48:16 UTC",-10.6939,165.6002,4.8,10.10,63,"Santa Cruz Islands" +us,c000f223,6,"Wednesday, February 6, 2013 05:35:33 UTC",-10.7448,165.3262,5.0,15.00,95,"Santa Cruz Islands" +us,c000f21t,9,"Wednesday, February 6, 2013 05:30:19 UTC",-10.6822,164.2724,5.1,9.80,72,"Santa Cruz Islands region" +us,c000f21m,9,"Wednesday, February 6, 2013 05:24:30 UTC",-11.4326,165.3674,5.1,15.10,126,"Santa Cruz Islands" +us,c000f21c,6,"Wednesday, February 6, 2013 05:16:27 UTC",-10.4257,166.4981,5.3,11.90,129,"Santa Cruz Islands" +us,c000f21a,6,"Wednesday, February 6, 2013 05:13:48 UTC",-10.6202,166.2982,5.2,15.10,138,"Santa Cruz Islands" +us,c000f20v,6,"Wednesday, February 6, 2013 05:04:04 UTC",-11.0295,165.4740,4.9,10.00,77,"Santa Cruz Islands" +us,c000f20q,8,"Wednesday, February 6, 2013 05:01:51 UTC",-11.4077,165.0570,5.2,9.90,157,"Santa Cruz Islands" +us,c000f20m,6,"Wednesday, February 6, 2013 04:56:18 UTC",-11.3019,165.1304,5.0,16.00,84,"Santa Cruz Islands" +pr,13037002,0,"Wednesday, February 6, 2013 04:55:36 UTC",19.5900,-64.7894,3.3,7.00,11,"Virgin Islands region" +hv,60463956,5,"Wednesday, February 6, 2013 04:44:52 UTC",19.3537,-155.8155,3.1,28.40,90,"Island of Hawaii, Hawaii" +us,c000f1zq,6,"Wednesday, February 6, 2013 04:34:50 UTC",-11.3965,164.8467,5.1,35.20,79,"Santa Cruz Islands region" +us,c000f1z1,6,"Wednesday, February 6, 2013 04:20:54 UTC",-10.9100,165.5711,5.2,34.90,129,"Santa Cruz Islands" +us,c000f20j,5,"Wednesday, February 6, 2013 04:20:04 UTC",-10.8833,165.4045,5.0,10.10,76,"Santa Cruz Islands" +us,c000f1ys,6,"Wednesday, February 6, 2013 04:16:29 UTC",-11.0917,164.9040,5.0,10.70,32,"Santa Cruz Islands region" +pr,13037003,0,"Wednesday, February 6, 2013 04:05:58 UTC",18.9873,-64.2033,3.0,50.00, 6,"Virgin Islands region" +nc,71932305,5,"Wednesday, February 6, 2013 04:05:30 UTC",38.8298,-122.8327,2.8,0.70,77,"Northern California" +us,c000f1xv,6,"Wednesday, February 6, 2013 03:49:46 UTC",-10.8932,165.4735,5.6,18.30,287,"Santa Cruz Islands" +us,c000f1xr,9,"Wednesday, February 6, 2013 03:45:10 UTC",-10.6689,165.3117,5.3,33.40,204,"Santa Cruz Islands" +us,c000f1xl,6,"Wednesday, February 6, 2013 03:38:55 UTC",-10.8900,165.2685,5.2,12.10,149,"Santa Cruz Islands" +us,c000f1xa,6,"Wednesday, February 6, 2013 03:28:54 UTC",-11.0526,165.4465,5.3,22.80,136,"Santa Cruz Islands" +us,c000f1xc,5,"Wednesday, February 6, 2013 03:25:18 UTC",-11.1298,165.8065,5.1,9.90,79,"Santa Cruz Islands" +us,c000f1x5,7,"Wednesday, February 6, 2013 03:19:05 UTC",-10.8964,165.2159,5.3,14.90,137,"Santa Cruz Islands" +us,c000f1wr,9,"Wednesday, February 6, 2013 03:11:52 UTC",-10.9355,165.2921,5.2,36.80,93,"Santa Cruz Islands" +us,c000f1we,7,"Wednesday, February 6, 2013 03:06:34 UTC",-11.5131,165.3255,5.1,10.00,106,"Santa Cruz Islands" +us,c000f1xk,6,"Wednesday, February 6, 2013 03:01:03 UTC",-11.0321,165.1059,5.6,20.40,161,"Santa Cruz Islands" +us,c000f1vz,C,"Wednesday, February 6, 2013 02:58:22 UTC",-10.6632,165.1277,5.5,16.90,214,"Santa Cruz Islands" +us,c000f1w3,5,"Wednesday, February 6, 2013 02:57:44 UTC",-10.7546,165.0264,5.1,38.10,137,"Santa Cruz Islands" +us,c000f1vp,5,"Wednesday, February 6, 2013 02:44:26 UTC",-11.2951,165.1106,4.9,38.40,67,"Santa Cruz Islands" +us,c000f1vd,7,"Wednesday, February 6, 2013 02:30:49 UTC",-10.8221,164.9802,5.6,32.50,150,"Santa Cruz Islands region" +hv,60463916,1,"Wednesday, February 6, 2013 02:27:19 UTC",19.2080,-155.5362,2.6,37.20,37,"Island of Hawaii, Hawaii" +us,c000f1uy,6,"Wednesday, February 6, 2013 02:23:11 UTC",-10.9626,165.4018,5.3,28.30,213,"Santa Cruz Islands" +us,c000f1uu,6,"Wednesday, February 6, 2013 02:18:14 UTC",-11.4680,165.6138,5.2,34.40,134,"Santa Cruz Islands" +us,c000f1u2,8,"Wednesday, February 6, 2013 02:06:21 UTC",-10.5968,165.3629,5.2,10.00,96,"Santa Cruz Islands" +us,c000f1ts,A,"Wednesday, February 6, 2013 01:54:15 UTC",-10.4786,165.7721,7.0,9.80,430,"Santa Cruz Islands" +us,c000f1tm,5,"Wednesday, February 6, 2013 01:48:42 UTC",-11.6277,165.9368,5.7,10.00,75,"Santa Cruz Islands" +us,c000f1tb,5,"Wednesday, February 6, 2013 01:33:37 UTC",-10.9219,165.0854,5.6,10.00,62,"Santa Cruz Islands" +us,c000f1se,8,"Wednesday, February 6, 2013 01:23:19 UTC",-11.2325,164.9211,6.4,10.10,350,"Santa Cruz Islands region" +us,c000f1st,5,"Wednesday, February 6, 2013 01:22:12 UTC",-11.3657,165.7679,5.6,10.10,133,"Santa Cruz Islands" +us,c000f1s0,B,"Wednesday, February 6, 2013 01:12:27 UTC",-10.7377,165.1378,8.0,28.70,347,"Santa Cruz Islands" +us,c000f1rw,3,"Wednesday, February 6, 2013 01:00:47 UTC",-4.3520,134.7097,4.6,32.80,18,"near the south coast of Papua, Indonesia" +us,c000f1rp,A,"Wednesday, February 6, 2013 00:46:01 UTC",-10.8706,165.0286,5.3,9.50,110,"Santa Cruz Islands" +pr,13037000,0,"Wednesday, February 6, 2013 00:11:09 UTC",19.0275,-64.7429,2.7,44.00, 6,"Virgin Islands region" +us,c000f1r5,6,"Wednesday, February 6, 2013 00:07:22 UTC",-10.8577,165.2060,6.3,10.00,199,"Santa Cruz Islands" +us,2013lgaz,6,"Tuesday, February 5, 2013 22:03:50 UTC",40.4227,-125.3185,3.5,2.50,13,"offshore Northern California" +us,c000f1kg,9,"Tuesday, February 5, 2013 20:15:10 UTC",-23.6087,-66.7196,4.7,204.90,25,"Jujuy, Argentina" +ak,10650863,2,"Tuesday, February 5, 2013 19:49:16 UTC",52.2213,-168.2007,2.5,39.10,14,"Fox Islands, Aleutian Islands, Alaska" +us,c000f1jz,6,"Tuesday, February 5, 2013 19:39:39 UTC",-10.7531,164.9855,5.1,46.00,145,"Santa Cruz Islands region" +pr,13036003,0,"Tuesday, February 5, 2013 19:11:12 UTC",19.2483,-66.2475,3.3,66.00,12,"Puerto Rico region" +us,c000f1jd,5,"Tuesday, February 5, 2013 19:09:37 UTC",-62.3050,155.0730,5.0,32.80,54,"Balleny Islands region" +pr,13036004,0,"Tuesday, February 5, 2013 18:40:34 UTC",19.7210,-68.5426,3.6,41.00, 9,"Dominican Republic region" +us,c000f1hr,9,"Tuesday, February 5, 2013 18:18:31 UTC",36.4828,70.5766,4.8,214.90,174,"Hindu Kush region, Afghanistan" +us,c000f1g1,4,"Tuesday, February 5, 2013 17:30:49 UTC",-22.6817,-68.9683,4.4,84.10,27,"Antofagasta, Chile" +ak,10650790,1,"Tuesday, February 5, 2013 17:10:30 UTC",59.3207,-152.6572,2.7,49.70,15,"Southern Alaska" +us,2013lgal,4,"Tuesday, February 5, 2013 16:38:01 UTC",55.4425,-35.0325,4.9,5.80,179,"Reykjanes Ridge" +us,c000f1e6,8,"Tuesday, February 5, 2013 16:15:31 UTC",28.8017,128.5949,5.0,57.30,125,"Ryukyu Islands, Japan" +us,c000f1e5,6,"Tuesday, February 5, 2013 15:40:08 UTC",-56.1381,-25.2307,5.0,48.90,24,"South Sandwich Islands region" +ak,10650739,1,"Tuesday, February 5, 2013 15:27:27 UTC",59.7747,-153.2343,2.6,134.80,26,"Southern Alaska" +ci,15281561,2,"Tuesday, February 5, 2013 14:42:01 UTC",34.0705,-117.2372,2.7,14.40,208,"Greater Los Angeles area, California" +us,2013lgah,5,"Tuesday, February 5, 2013 13:31:03 UTC",38.7007,142.0003,4.8,51.40,84,"near the east coast of Honshu, Japan" +ak,10650705,1,"Tuesday, February 5, 2013 13:24:31 UTC",63.3609,-150.7955,2.9,11.20,38,"Central Alaska" +us,2013lgag,4,"Tuesday, February 5, 2013 13:13:48 UTC",38.9157,99.9137,4.1,6.30,22,"northern Qinghai, China" +us,c000f1c3,5,"Tuesday, February 5, 2013 12:43:20 UTC",33.1074,140.5789,4.4,79.20,40,"Izu Islands, Japan region" +pr,13036002,0,"Tuesday, February 5, 2013 12:16:41 UTC",19.3033,-68.6122,3.3,90.00, 6,"Dominican Republic region" +nn,00401855,9,"Tuesday, February 5, 2013 10:24:41 UTC",38.0033,-115.4532,3.3,4.00,23,"Nevada" +ci,15281481,2,"Tuesday, February 5, 2013 08:58:22 UTC",35.0722,-118.9660,2.5,12.40,85,"Central California" +us,c000f1ag,5,"Tuesday, February 5, 2013 08:55:29 UTC",12.1408,-88.5476,4.3,35.00,34,"off the coast of El Salvador" +ak,10650646,2,"Tuesday, February 5, 2013 07:55:09 UTC",51.5826,-178.4418,2.8,4.80,20,"Andreanof Islands, Aleutian Islands, Alaska" +ak,10650635,2,"Tuesday, February 5, 2013 06:25:49 UTC",53.1764,-161.2328,2.9,25.70,14,"south of Alaska" +ci,15281473,2,"Tuesday, February 5, 2013 06:07:50 UTC",32.1615,-115.2112,3.1,18.70,23,"Baja California, Mexico" +pr,13036001,0,"Tuesday, February 5, 2013 05:04:49 UTC",19.0084,-64.2054,3.1,56.00, 8,"Virgin Islands region" +pr,13036000,0,"Tuesday, February 5, 2013 04:52:56 UTC",18.8932,-64.2115,3.2,53.00,15,"Virgin Islands region" +nc,71935341,3,"Tuesday, February 5, 2013 04:27:33 UTC",36.0025,-120.5623,2.5,4.80,96,"Central California" +us,c000f18y,6,"Tuesday, February 5, 2013 03:57:30 UTC",14.0356,92.9496,4.9,28.70,76,"Andaman Islands, India region" +ak,10650584,1,"Tuesday, February 5, 2013 03:30:56 UTC",59.0472,-150.0685,2.5,5.00,12,"Kenai Peninsula, Alaska" +us,c000f18r,5,"Tuesday, February 5, 2013 03:24:52 UTC",45.5192,151.2865,5.0,46.90,326,"Kuril Islands" +nc,71935291,3,"Tuesday, February 5, 2013 02:08:36 UTC",36.9712,-121.6142,2.5,2.70,84,"Northern California" +ak,10650544,2,"Tuesday, February 5, 2013 01:33:26 UTC",51.8788,-174.0367,3.4,37.30,21,"Andreanof Islands, Aleutian Islands, Alaska" +pr,13035005,0,"Monday, February 4, 2013 21:15:06 UTC",18.8694,-64.3210,3.1,39.00, 9,"Virgin Islands region" +pr,13035004,0,"Monday, February 4, 2013 21:04:51 UTC",18.9120,-64.3292,2.5,39.00, 5,"Virgin Islands region" +pr,13035003,0,"Monday, February 4, 2013 20:56:03 UTC",18.8299,-64.2650,3.0,43.00, 7,"Virgin Islands region" +nn,00401743,9,"Monday, February 4, 2013 18:49:47 UTC",38.1227,-115.0367,2.6,13.70, 5,"Nevada" +nc,71935021,5,"Monday, February 4, 2013 18:30:51 UTC",38.7892,-122.7425,2.9,1.90,77,"Northern California" +us,c000f0zs,7,"Monday, February 4, 2013 17:47:49 UTC",37.5266,70.1759,4.7,14.00,52,"Hindu Kush region, Afghanistan" +ak,10650324,1,"Monday, February 4, 2013 17:06:37 UTC",60.6818,-152.4054,2.6,91.30,34,"Southern Alaska" +us,2013lfat,3,"Monday, February 4, 2013 15:27:14 UTC",32.8999,94.8966,4.1,27.50,20,"Xizang-Qinghai border region" +us,2013lfaq,5,"Monday, February 4, 2013 14:33:02 UTC",-11.0081,165.4433,4.7,10.00,29,"Santa Cruz Islands" +ak,10650278,2,"Monday, February 4, 2013 13:51:14 UTC",49.9368,179.1687,3.1,49.90,10,"south of the Aleutian Islands" +us,2013lfap,6,"Monday, February 4, 2013 13:35:29 UTC",37.5340,82.4263,4.7,21.70,72,"southern Xinjiang, China" +us,c000f0wi,8,"Monday, February 4, 2013 12:04:57 UTC",32.8530,94.7124,4.7,35.00,103,"Xizang-Qinghai border region" +us,c000f0wk,4,"Monday, February 4, 2013 11:48:42 UTC",-33.9987,-14.7126,4.6,10.10,25,"southern Mid-Atlantic Ridge" +us,c000f0vg,4,"Monday, February 4, 2013 09:33:17 UTC",0.6300,126.2420,4.7,14.70,44,"Molucca Sea" +us,c000f0v0,5,"Monday, February 4, 2013 08:38:06 UTC",36.5617,70.8146,4.3,204.30,26,"Hindu Kush region, Afghanistan" +us,c000f0uu,5,"Monday, February 4, 2013 08:08:30 UTC",19.0239,121.0521,4.6,48.90,37,"Babuyan Islands region, Philippines" +us,c000f0ut,5,"Monday, February 4, 2013 07:56:53 UTC",34.8916,24.1916,4.7,10.00,102,"Crete, Greece" +us,c000f0uj,7,"Monday, February 4, 2013 07:16:09 UTC",16.2219,120.5795,4.6,54.90,14,"Luzon, Philippines" +us,c000f0tj,9,"Monday, February 4, 2013 05:39:06 UTC",16.8834,-96.7509,4.0,35.00,40,"Oaxaca, Mexico" +ak,10650203,1,"Monday, February 4, 2013 05:25:34 UTC",62.3251,-151.3673,3.1,81.60,39,"Central Alaska" +us,c000f0t9,6,"Monday, February 4, 2013 05:10:32 UTC",15.3195,-94.0306,4.3,72.80,120,"offshore Chiapas, Mexico" +us,c000f0sw,7,"Monday, February 4, 2013 04:29:46 UTC",43.6808,16.3903,4.5,10.10,35,"Croatia" +us,c000f0sp,6,"Monday, February 4, 2013 04:00:54 UTC",30.3340,130.9954,4.7,54.30,18,"Kyushu, Japan" +pr,13035001,0,"Monday, February 4, 2013 03:50:16 UTC",18.6970,-64.3087,2.7,73.00, 3,"Virgin Islands region" +us,c000f0sa,3,"Monday, February 4, 2013 03:49:27 UTC",-4.9707,133.9097,4.6,21.80,27,"near the south coast of Papua, Indonesia" +uw,60504521,1,"Monday, February 4, 2013 03:46:17 UTC",48.9357,-119.5805,2.5,1.20, 9,"Washington" +ak,10650156,2,"Monday, February 4, 2013 03:31:00 UTC",51.4374,-177.2211,2.5,37.60,15,"Andreanof Islands, Aleutian Islands, Alaska" +ak,10650161,2,"Monday, February 4, 2013 01:54:44 UTC",51.5747,-176.7491,2.6,49.50,15,"Andreanof Islands, Aleutian Islands, Alaska" +pr,13035002,0,"Monday, February 4, 2013 01:38:57 UTC",18.8850,-64.9170,2.9,55.00, 5,"Virgin Islands region" +us,c000f0r7,5,"Monday, February 4, 2013 01:20:21 UTC",-5.5474,130.8369,4.7,58.70,22,"Banda Sea" +us,c000f0ps,7,"Sunday, February 3, 2013 23:04:18 UTC",29.3302,141.8019,5.1,48.80,267,"Izu Islands, Japan region" +us,c000f0pp,8,"Sunday, February 3, 2013 22:56:11 UTC",29.3124,142.0140,5.3,34.80,259,"Izu Islands, Japan region" +ci,15281081,2,"Sunday, February 3, 2013 22:14:26 UTC",35.8050,-118.5040,2.7,4.50,62,"Central California" +ak,10650076,1,"Sunday, February 3, 2013 22:01:44 UTC",61.6729,-150.5438,3.1,59.80,56,"Southern Alaska" +ak,10650064,1,"Sunday, February 3, 2013 21:37:55 UTC",62.9931,-150.7086,3.5,166.90,12,"Central Alaska" +us,c000f0np,5,"Sunday, February 3, 2013 20:54:43 UTC",-32.3765,-71.5977,4.7,37.90,32,"offshore Valparaiso, Chile" +ak,10650060,2,"Sunday, February 3, 2013 20:30:44 UTC",67.7331,-167.1644,3.6,24.20,15,"Bering Strait" +us,c000f0mh,4,"Sunday, February 3, 2013 17:46:59 UTC",27.6917,56.4974,4.5,45.10,31,"southern Iran" +nc,71934461,5,"Sunday, February 3, 2013 16:51:46 UTC",37.3477,-121.7088,2.5,8.60,91,"Northern California" +us,2013lear,3,"Sunday, February 3, 2013 14:23:02 UTC",-11.0025,165.4439,4.6,10.00,18,"Santa Cruz Islands" +us,c000f0ku,5,"Sunday, February 3, 2013 11:36:39 UTC",-5.0038,153.2180,5.0,10.00,64,"New Ireland region, Papua New Guinea" +us,c000f0kj,A,"Sunday, February 3, 2013 11:14:56 UTC",-5.0741,153.0690,5.4,23.20,193,"New Ireland region, Papua New Guinea" +us,c000f0kd,5,"Sunday, February 3, 2013 11:10:31 UTC",36.4962,70.7940,4.0,177.70,39,"Hindu Kush region, Afghanistan" +us,c000f0ke,6,"Sunday, February 3, 2013 11:08:10 UTC",-5.0725,153.1490,4.8,11.50,52,"New Ireland region, Papua New Guinea" +us,c000f0k9,8,"Sunday, February 3, 2013 10:22:40 UTC",-10.5488,166.5661,4.7,35.50,104,"Santa Cruz Islands" +us,c000f0k5,8,"Sunday, February 3, 2013 10:12:07 UTC",-5.4343,154.2528,4.6,138.80,103,"Bougainville region, Papua New Guinea" +ak,10649927,1,"Sunday, February 3, 2013 07:51:29 UTC",62.9473,-150.7181,2.9,125.40,55,"Central Alaska" +ak,10649916,1,"Sunday, February 3, 2013 07:13:33 UTC",61.0513,-150.8920,2.6,49.80,42,"Southern Alaska" +us,c000f0fi,7,"Sunday, February 3, 2013 06:20:51 UTC",-6.5806,130.1281,4.6,150.80,33,"Banda Sea" +us,c000f0es,4,"Sunday, February 3, 2013 05:22:12 UTC",-35.6005,-72.7669,4.4,37.00,21,"offshore Maule, Chile" +ak,10649868,2,"Sunday, February 3, 2013 05:13:41 UTC",62.8642,-150.7072,3.9,93.80,77,"Central Alaska" +us,c000f0cw,5,"Sunday, February 3, 2013 05:01:07 UTC",64.9516,-122.9657,4.0,10.00,54,"Northwest Territories, Canada" +us,c000f0ch,7,"Sunday, February 3, 2013 03:57:32 UTC",-10.8758,165.3571,5.1,10.00,58,"Santa Cruz Islands" +ak,10649823,2,"Sunday, February 3, 2013 03:27:36 UTC",63.0802,-151.5871,3.3,8.90,30,"Central Alaska" +us,c000f0bw,8,"Sunday, February 3, 2013 03:20:29 UTC",-29.7239,-178.8898,4.7,197.50,56,"Kermadec Islands, New Zealand" +us,c000f0bs,6,"Sunday, February 3, 2013 03:08:23 UTC",-21.4337,-178.7097,4.6,578.20,61,"Fiji region" +us,c000f0bj,6,"Sunday, February 3, 2013 02:29:13 UTC",-10.9632,165.3327,5.1,9.90,38,"Santa Cruz Islands" +us,c000f0bf,3,"Sunday, February 3, 2013 02:00:57 UTC",17.2567,147.2107,4.8,69.50,27,"Mariana Islands region" +ak,10649796,1,"Sunday, February 3, 2013 01:57:20 UTC",62.0870,-148.1612,2.7,10.90,49,"Central Alaska" +pr,13034000,0,"Sunday, February 3, 2013 01:51:59 UTC",18.4696,-67.5585,2.7,81.00, 4,"Mona Passage, Puerto Rico" +us,c000f0a0,4,"Saturday, February 2, 2013 22:36:01 UTC",-10.7100,166.5497,4.6,10.30,61,"Santa Cruz Islands" +us,c000f09b,5,"Saturday, February 2, 2013 22:31:58 UTC",-11.3221,165.1132,4.7,10.00,21,"Santa Cruz Islands" +us,c000f07p,6,"Saturday, February 2, 2013 21:20:35 UTC",-11.1323,165.3223,5.1,10.00,144,"Santa Cruz Islands" +us,c000f07a,6,"Saturday, February 2, 2013 21:00:23 UTC",-61.3223,154.1036,4.8,10.00,39,"Balleny Islands region" +us,c000f078,6,"Saturday, February 2, 2013 20:46:30 UTC",-10.3659,166.4568,4.8,10.40,84,"Santa Cruz Islands" +us,c000f06q,8,"Saturday, February 2, 2013 20:16:07 UTC",-31.1283,-71.3749,4.6,48.60,34,"Coquimbo, Chile" +us,c000f06g,3,"Saturday, February 2, 2013 19:24:34 UTC",-11.2194,165.2014,5.1,29.50,77,"Santa Cruz Islands" +us,c000f05y,B,"Saturday, February 2, 2013 18:58:06 UTC",-10.9218,165.2461,6.0,7.50,315,"Santa Cruz Islands" +us,c000f05u,A,"Saturday, February 2, 2013 18:54:31 UTC",-10.9703,165.3326,5.2,31.10,113,"Santa Cruz Islands" +us,c000f056,A,"Saturday, February 2, 2013 18:31:38 UTC",29.4141,141.9384,5.5,50.80,190,"Izu Islands, Japan region" +pr,13033003,0,"Saturday, February 2, 2013 18:16:51 UTC",19.8878,-67.5970,3.1,56.00,10,"Puerto Rico region" +ak,10652410,2,"Saturday, February 2, 2013 17:54:58 UTC",56.0740,-135.7272,2.5,20.00, 5,"Southeastern Alaska" +ak,10652408,2,"Saturday, February 2, 2013 17:39:02 UTC",56.1223,-135.7292,2.7,20.00, 5,"Southeastern Alaska" +ak,10649439,2,"Saturday, February 2, 2013 15:49:48 UTC",51.4978,-178.1699,3.6,18.50,16,"Andreanof Islands, Aleutian Islands, Alaska" +us,c000f03a,7,"Saturday, February 2, 2013 14:17:34 UTC",42.8116,143.0784,6.9,103.10,583,"Hokkaido, Japan region" +us,c000f02n,9,"Saturday, February 2, 2013 13:35:35 UTC",46.5089,14.6419,4.5,10.00,70,"Austria" +pr,13033002,0,"Saturday, February 2, 2013 13:29:13 UTC",18.5221,-63.9562,2.6,26.00, 6,"Virgin Islands region" +nc,71933876,3,"Saturday, February 2, 2013 12:00:12 UTC",36.4553,-120.4745,2.8,16.80,131,"Central California" +us,c000f01s,6,"Saturday, February 2, 2013 11:54:04 UTC",-9.7285,112.9597,4.5,35.10,36,"south of Java, Indonesia" +us,c000f01m,8,"Saturday, February 2, 2013 11:33:53 UTC",34.2611,24.9827,4.8,9.40,129,"Crete, Greece" +ak,10649377,2,"Saturday, February 2, 2013 11:22:21 UTC",51.4654,-178.1307,3.5,13.10,19,"Andreanof Islands, Aleutian Islands, Alaska" +nc,71933851,5,"Saturday, February 2, 2013 10:50:04 UTC",36.4673,-120.4888,2.9,12.40,174,"Central California" +ak,10649355,2,"Saturday, February 2, 2013 10:07:20 UTC",60.0980,-153.1693,2.6,130.20,38,"Southern Alaska" +us,c000f005,4,"Saturday, February 2, 2013 07:21:20 UTC",-6.5494,130.0167,4.5,145.00,52,"Banda Sea" +se,020213a,C,"Saturday, February 2, 2013 06:47:03 UTC",34.9633,-84.9325,2.5,9.70,18,"Georgia, USA" +ak,10649289,3,"Saturday, February 2, 2013 06:39:20 UTC",60.0732,-152.5530,3.5,91.00,66,"Southern Alaska" +us,c000ezzr,8,"Saturday, February 2, 2013 06:26:31 UTC",30.8769,142.6756,4.8,32.20,299,"Izu Islands, Japan region" +ak,10649279,2,"Saturday, February 2, 2013 05:34:18 UTC",51.3373,-174.1129,3.1,47.20,17,"Andreanof Islands, Aleutian Islands, Alaska" +ak,10649275,2,"Saturday, February 2, 2013 05:14:34 UTC",52.2312,-176.0831,2.6,122.70,17,"Andreanof Islands, Aleutian Islands, Alaska" +us,c000ezzh,8,"Saturday, February 2, 2013 05:10:01 UTC",10.7267,-62.2780,4.4,89.60,130,"offshore Sucre, Venezuela" +ak,10652372,2,"Saturday, February 2, 2013 04:45:34 UTC",55.9679,-135.2825,2.6,20.00, 6,"off the coast of Southeastern Alaska" +us,c000ezyt,7,"Saturday, February 2, 2013 04:16:20 UTC",-11.0856,165.1736,5.6,28.60,68,"Santa Cruz Islands" +us,c000f00n,4,"Saturday, February 2, 2013 03:48:06 UTC",-32.5616,-71.6039,4.0,30.20,12,"offshore Valparaiso, Chile" +us,c000ezyg,7,"Saturday, February 2, 2013 03:44:34 UTC",34.9903,-97.4664,2.8,13.80,19,"Oklahoma" +us,c000ezyd,7,"Saturday, February 2, 2013 03:39:51 UTC",-10.8641,165.3471,4.9,19.80,114,"Santa Cruz Islands" +us,c000ezya,7,"Saturday, February 2, 2013 03:39:51 UTC",23.7353,121.9889,5.1,22.50,73,"Taiwan" +ak,10649223,2,"Saturday, February 2, 2013 02:43:05 UTC",62.1734,-150.7210,2.6,68.60,50,"Central Alaska" +us,c000ezxv,8,"Saturday, February 2, 2013 01:20:41 UTC",-10.8275,165.2375,4.9,35.20,94,"Santa Cruz Islands" +us,c000ezxz,4,"Saturday, February 2, 2013 01:19:36 UTC",-6.9599,105.4014,5.1,38.70,127,"Sunda Strait, Indonesia" +us,c000ezxt,7,"Saturday, February 2, 2013 01:15:49 UTC",-11.1458,165.3868,5.0,26.90,112,"Santa Cruz Islands" +us,c000ezxg,6,"Friday, February 1, 2013 23:16:04 UTC",13.7867,144.5918,4.4,153.90,31,"Guam region" +us,c000ezvd,6,"Friday, February 1, 2013 22:26:30 UTC",-11.1483,165.3388,4.9,9.80,26,"Santa Cruz Islands" +us,c000ezw4,E,"Friday, February 1, 2013 22:18:35 UTC",-11.0635,165.3264,6.4,22.00,133,"Santa Cruz Islands" +us,c000ezv6,E,"Friday, February 1, 2013 22:16:36 UTC",-10.9263,165.4500,6.3,19.90,288,"Santa Cruz Islands" +ak,10648915,3,"Friday, February 1, 2013 21:03:50 UTC",65.5230,-144.4622,4.3,14.20,72,"northern Alaska" +nc,71933366,1,"Friday, February 1, 2013 20:47:40 UTC",36.7890,-122.0813,2.6,4.40,54,"offshore Central California" +us,c000ezq1,7,"Friday, February 1, 2013 18:23:06 UTC",42.8682,142.7919,4.6,131.00,206,"Hokkaido, Japan region" +us,c000ezps,5,"Friday, February 1, 2013 18:04:10 UTC",-6.8434,129.5571,4.4,156.10,27,"Banda Sea" +us,c000ezp6,5,"Friday, February 1, 2013 17:21:23 UTC",-24.0765,-66.9065,4.7,179.50,43,"Salta, Argentina" +us,c000ezp4,7,"Friday, February 1, 2013 17:08:26 UTC",-0.1816,123.0677,4.9,124.90,132,"Sulawesi, Indonesia" +ak,10648704,2,"Friday, February 1, 2013 16:31:09 UTC",54.7698,-161.4977,2.6,34.60,16,"Alaska Peninsula" +hv,60461836,3,"Friday, February 1, 2013 14:08:21 UTC",19.8007,-156.1565,2.6,36.00,25,"Hawaii region, Hawaii" +us,c000ezlw,8,"Friday, February 1, 2013 14:06:48 UTC",35.5505,139.9580,4.8,72.00,41,"near the south coast of Honshu, Japan" +nc,71933006,5,"Friday, February 1, 2013 13:28:15 UTC",35.6665,-121.0730,3.1,6.80,96,"Central California" +ak,10648641,2,"Friday, February 1, 2013 10:57:01 UTC",51.3647,-178.9239,2.7,23.50,17,"Andreanof Islands, Aleutian Islands, Alaska" +us,c000ezl2,6,"Friday, February 1, 2013 10:55:26 UTC",38.4965,142.3438,4.4,50.70,27,"near the east coast of Honshu, Japan" +us,c000ezkv,6,"Friday, February 1, 2013 10:39:46 UTC",-26.5598,-178.9872,4.7,368.10,185,"south of the Fiji Islands" +ak,10648627,3,"Friday, February 1, 2013 10:22:20 UTC",67.7755,-143.6838,3.5,10.00,39,"northern Alaska" +ci,15279801,2,"Friday, February 1, 2013 10:06:45 UTC",31.8680,-116.1980,2.5,8.20,20,"Baja California, Mexico" +us,c000ezjt,7,"Friday, February 1, 2013 07:39:46 UTC",48.2846,154.6969,4.7,36.00,181,"Kuril Islands" +ak,10648568,3,"Friday, February 1, 2013 07:20:24 UTC",60.0188,-153.0751,2.8,1.80,41,"Southern Alaska" +ak,10648551,2,"Friday, February 1, 2013 06:47:57 UTC",59.1821,-142.8097,2.9,16.80,50,"Gulf of Alaska" +us,c000ezj6,8,"Friday, February 1, 2013 06:32:36 UTC",47.4805,81.1063,4.5,16.20,90,"eastern Kazakhstan" +pr,13032000,0,"Friday, February 1, 2013 05:44:28 UTC",18.1840,-67.4032,2.8,9.00,16,"Mona Passage, Puerto Rico" +us,c000ezil,A,"Friday, February 1, 2013 05:36:40 UTC",-11.0900,165.5377,6.0,9.40,278,"Santa Cruz Islands" +ak,10648484,2,"Friday, February 1, 2013 03:33:25 UTC",60.0090,-153.0308,2.5,2.30,33,"Southern Alaska" +us,c000ezhu,7,"Friday, February 1, 2013 02:17:27 UTC",-6.9508,147.6674,5.9,34.80,124,"eastern New Guinea region, Papua New Guinea" +us,c000ezhs,7,"Friday, February 1, 2013 01:49:13 UTC",-10.9845,165.4756,4.9,29.80,128,"Santa Cruz Islands" +ak,10651747,2,"Friday, February 1, 2013 01:39:28 UTC",55.4334,-134.9107,2.5,10.00, 5,"Southeastern Alaska" +ak,10651743,2,"Friday, February 1, 2013 01:04:51 UTC",55.5801,-135.0018,2.5,10.00, 5,"off the coast of Southeastern Alaska" +us,c000ezhk,6,"Friday, February 1, 2013 00:42:59 UTC",-11.0555,165.4805,4.8,9.90,99,"Santa Cruz Islands" +us,c000ezhb,4,"Friday, February 1, 2013 00:18:08 UTC",-11.0338,165.3336,5.1,10.70,32,"Santa Cruz Islands" diff --git a/src/examples/data_conversion/example_csv_to_kml.py b/src/examples/data_conversion/example_csv_to_kml.py index 35c59e6..e1bb67c 100644 --- a/src/examples/data_conversion/example_csv_to_kml.py +++ b/src/examples/data_conversion/example_csv_to_kml.py @@ -5,7 +5,6 @@ ''' import csv -import urllib2 from datetime import datetime from lxml import etree from pykml.factory import KML_ElementMaker as KML @@ -13,7 +12,7 @@ def makeExtendedDataElements(datadict): '''Converts a dictionary to ExtendedData/Data elements''' edata = KML.ExtendedData() - for key, value in datadict.iteritems(): + for key, value in datadict.items(): edata.append(KML.Data(KML.value(value), name=key + "_")) return edata @@ -49,7 +48,7 @@ def makeExtendedDataElements(datadict): KML.Style( KML.IconStyle( KML.color(color), - KML.scale(threshold/2), + KML.scale(int(threshold/2)), KML.Icon( KML.href("http://maps.google.com/mapfiles/kml/shapes/earthquake.png"), ), @@ -63,9 +62,9 @@ def makeExtendedDataElements(datadict): doc.append(KML.Folder()) # read in a csv file, and create a placemark for each record -url="http://earthquake.usgs.gov/earthquakes/catalogs/eqs7day-M2.5.txt" -fileobject = urllib2.urlopen(url) -for row in csv.DictReader(fileobject): +#url="http://earthquake.usgs.gov/earthquakes/catalogs/eqs7day-M2.5.txt" +with open('eqs7day-M2.5.txt', 'r') as fd: + for row in csv.DictReader(fd): timestamp = datetime.strptime(row["Datetime"], "%A, %B %d, %Y %H:%M:%S %Z") pm = KML.Placemark( KML.name("Magnitude={0}".format(row['Magnitude'])), @@ -89,4 +88,4 @@ def makeExtendedDataElements(datadict): schema_gx = Schema("kml22gx.xsd") schema_gx.assertValid(doc) -print etree.tostring(doc, pretty_print=True) +print(etree.tostring(doc, pretty_print=True).decode()) diff --git a/src/examples/misc/base_jump/virtual_base_jump.py b/src/examples/misc/base_jump/virtual_base_jump.py index d47401b..2ef0386 100644 --- a/src/examples/misc/base_jump/virtual_base_jump.py +++ b/src/examples/misc/base_jump/virtual_base_jump.py @@ -1,4 +1,5 @@ #!/usr/bin/python +from __future__ import division # example virtual base jump import math @@ -67,10 +68,10 @@ def drange(start, stop, step): tstep = 0.1 for t in drange(0,15,tstep): pm = kml.Placemark( - kml.name(str(t)), + kml.name("{name:.1f}".format(name=t)), kml.Point( kml.altitudeMode("absolute"), - kml.coordinates("{lon},{lat},{alt}".format( + kml.coordinates("{lon:.8f},{lat:.8f},{alt:.8f}".format( lon=loc0['longitude'] + vx*t, lat=loc0['latitude'] + vy*t, alt=loc0['altitude'] + vz*t + 0.5*g*t**2, @@ -96,8 +97,8 @@ def drange(start, stop, step): assert Schema('kml22gx.xsd').validate(tour_doc) -print etree.tostring(tour_doc, pretty_print=True) +print(etree.tostring(tour_doc, pretty_print=True).decode()) # output a KML file (named based on the Python script) -outfile = file(__file__.rstrip('.py')+'.kml','w') -outfile.write(etree.tostring(tour_doc, pretty_print=True)) \ No newline at end of file +with open(__file__.rstrip('.py')+'.kml','wb') as outfile: + outfile.write(etree.tostring(tour_doc, pretty_print=True)) diff --git a/src/examples/misc/hello_world/hello_world_1_simple_placemark.py b/src/examples/misc/hello_world/hello_world_1_simple_placemark.py index e25f78e..c4cf80b 100644 --- a/src/examples/misc/hello_world/hello_world_1_simple_placemark.py +++ b/src/examples/misc/hello_world/hello_world_1_simple_placemark.py @@ -11,5 +11,4 @@ ), ), ) -print etree.tostring(etree.ElementTree(doc),pretty_print=True) - +print(etree.tostring(etree.ElementTree(doc),pretty_print=True).decode()) diff --git a/src/examples/misc/hello_world/hello_world_2_spiral_words.py b/src/examples/misc/hello_world/hello_world_2_spiral_words.py index e054493..2891df6 100644 --- a/src/examples/misc/hello_world/hello_world_2_spiral_words.py +++ b/src/examples/misc/hello_world/hello_world_2_spiral_words.py @@ -24,4 +24,4 @@ ) ) -print etree.tostring(etree.ElementTree(kmlobj),pretty_print=True) +print(etree.tostring(etree.ElementTree(kmlobj),pretty_print=True).decode()) diff --git a/src/examples/misc/hello_world/hello_world_3_spiral_characters.py b/src/examples/misc/hello_world/hello_world_3_spiral_characters.py index 0cf8914..32a8920 100644 --- a/src/examples/misc/hello_world/hello_world_3_spiral_characters.py +++ b/src/examples/misc/hello_world/hello_world_3_spiral_characters.py @@ -28,4 +28,4 @@ ) ) -print etree.tostring(etree.ElementTree(kmlobj),pretty_print=True) +print(etree.tostring(etree.ElementTree(kmlobj),pretty_print=True).decode()) diff --git a/src/examples/misc/hello_world/hello_world_4_gateway_arch.py b/src/examples/misc/hello_world/hello_world_4_gateway_arch.py index 57da1b0..922366e 100644 --- a/src/examples/misc/hello_world/hello_world_4_gateway_arch.py +++ b/src/examples/misc/hello_world/hello_world_4_gateway_arch.py @@ -40,4 +40,4 @@ ) ) -print etree.tostring(etree.ElementTree(kmlobj),pretty_print=True) +print(etree.tostring(etree.ElementTree(kmlobj),pretty_print=True).decode()) diff --git a/src/examples/misc/hello_world/hello_world_5_globe_scale.py b/src/examples/misc/hello_world/hello_world_5_globe_scale.py index 5f11808..2de9dac 100644 --- a/src/examples/misc/hello_world/hello_world_5_globe_scale.py +++ b/src/examples/misc/hello_world/hello_world_5_globe_scale.py @@ -34,4 +34,4 @@ ), ) ) -print etree.tostring(etree.ElementTree(kmlobj),pretty_print=True) +print(etree.tostring(etree.ElementTree(kmlobj),pretty_print=True).decode()) diff --git a/src/examples/misc/pyephem/pyephem_example.py b/src/examples/misc/pyephem/pyephem_example.py index 0e85143..ad5a541 100644 --- a/src/examples/misc/pyephem/pyephem_example.py +++ b/src/examples/misc/pyephem/pyephem_example.py @@ -7,6 +7,7 @@ Example usage: python pyephem_example.py > test.kml ''' +from __future__ import division from datetime import datetime, timedelta from math import pi, degrees, radians @@ -99,7 +100,7 @@ def calculate_geographic_offset(azimuth_angle,altitude_angle, distance): KML.Point( KML.extrude(True), KML.altitudeMode('relativeToGround'), - KML.coordinates("{0},{1},{2}".format(longitude,latitude,height)), + KML.coordinates("{0:.8f},{1:.8f},{2:.8f}".format(longitude,latitude,height)), ), ) doc.Document.append(pm_observer) @@ -133,7 +134,7 @@ def calculate_geographic_offset(azimuth_angle,altitude_angle, distance): ), KML.Point( KML.altitudeMode("relativeToGround"), - KML.coordinates("{lon},{lat},{alt}".format( + KML.coordinates("{lon:.8f},{lat:.8f},{alt:.8f}".format( lon = longitude + degrees(delta_lon_rad), lat = latitude + degrees(delta_lat_rad), alt = height + delta_alt, @@ -185,6 +186,6 @@ def calculate_geographic_offset(azimuth_angle,altitude_angle, distance): ) ) -print etree.tostring(doc, pretty_print=True) +print(etree.tostring(doc, pretty_print=True).decode()) diff --git a/src/pykml/factory.py b/src/pykml/factory.py index a035618..330c12e 100644 --- a/src/pykml/factory.py +++ b/src/pykml/factory.py @@ -1,7 +1,7 @@ '''pyKML Factory Module -The pykml.factory module provides objects and functions that can be used to -create KML documents element-by-element. +The pykml.factory module provides objects and functions that can be used to +create KML documents element-by-element. The factory module leverages `lxml's ElementMaker factory`_ objects to create KML objects with the appropriate namespace prefixes. @@ -11,6 +11,7 @@ from lxml import etree, objectify + nsmap={ None: "http://www.opengis.net/kml/2.2", 'atom': "http://www.w3.org/2005/Atom", @@ -38,14 +39,14 @@ def get_factory_object_name(namespace): "Returns the correct factory object for a given namespace" - + factory_map = { 'http://www.opengis.net/kml/2.2': 'KML', 'http://www.w3.org/2005/Atom': 'ATOM', 'http://www.google.com/kml/ext/2.2': 'GX' } if namespace: - if factory_map.has_key(namespace): + if namespace in factory_map: factory_object_name = factory_map[namespace] else: factory_object_name = None @@ -56,23 +57,28 @@ def get_factory_object_name(namespace): def write_python_script_for_kml_document(doc): "Generates a python script that will construct a given KML document" - import StringIO + try: # Python2 support + import io + import StringIO + output = StringIO.StringIO() + except ImportError: # Python3 support + import io + output = io.StringIO() from pykml.helpers import separate_namespace - - output = StringIO.StringIO() + indent_size = 2 - + # add the etree package so that comments can be handled output.write('from lxml import etree\n') - + # add the namespace declaration section output.write('from pykml.factory import KML_ElementMaker as KML\n') output.write('from pykml.factory import ATOM_ElementMaker as ATOM\n') output.write('from pykml.factory import GX_ElementMaker as GX\n') output.write('\n') - + level = 0 - xml = StringIO.StringIO(etree.tostring(doc)) + xml = io.BytesIO(etree.tostring(doc)) context = etree.iterparse(xml, events=("start", "end", "comment")) output.write('doc = ') last_action = None @@ -153,7 +159,7 @@ def write_python_script_for_kml_document(doc): elif action in ('end'): level -= 1 if last_action == 'start': - output.pos -= 1 + output.seek(output.tell()-1) indent = '' else: indent = ' ' * level * indent_size @@ -161,12 +167,12 @@ def write_python_script_for_kml_document(doc): output.write('{0} {1}="{2}",\n'.format(indent,att,val)) output.write('{0}),\n'.format(indent)) last_action = action - + # remove the last comma - output.pos -= 2 + output.seek(output.tell()-2) output.truncate() output.write('\n') - + for entry in previous_list: output.write('doc.addprevious({entry})\n'.format( entry=entry @@ -175,20 +181,23 @@ def write_python_script_for_kml_document(doc): output.write('doc.addnext({entry})\n'.format( entry=entry )) - + # add python code to print out the KML document - output.write('print etree.tostring(etree.ElementTree(doc),pretty_print=True)\n') - + output.write('print(etree.tostring(etree.ElementTree(doc),pretty_print=True).decode())\n') + contents = output.getvalue() output.close() return contents def kml2pykml(): "Parse a KML file and generates a pyKML script" - import urllib2 + try: # Python2 support + import urllib2 + except ImportError: # Python3 support + import urllib.request as urllib2 from pykml.parser import parse from optparse import OptionParser - + parser = OptionParser( usage="usage: %prog FILENAME_or_URL", version="%prog 0.1", @@ -213,4 +222,4 @@ def kml2pykml(): pass #variable was not defined else: f.close - print write_python_script_for_kml_document(doc) \ No newline at end of file + print(write_python_script_for_kml_document(doc)) diff --git a/src/pykml/helpers.py b/src/pykml/helpers.py index 89f9b53..abf4d44 100644 --- a/src/pykml/helpers.py +++ b/src/pykml/helpers.py @@ -1,6 +1,6 @@ """pyKML Helpers Module -The pykml.helpers module contains 'helper' functions that operate on pyKML +The pykml.helpers module contains 'helper' functions that operate on pyKML document objects for accomplishing common tasks. """ @@ -20,10 +20,10 @@ def separate_namespace(qname): def set_max_decimal_places(doc, max_decimals): """Sets the maximum number of decimal places used by KML elements - + This method facilitates reducing the file size of a KML document. """ - + def replace_delimited_string_member( delimited_str, separator, @@ -33,8 +33,8 @@ def replace_delimited_string_member( values = delimited_str.split(separator) values[index_no] = str(round(float(values[index_no]), decimal_places)) return separator.join(values) - - if max_decimals.has_key('longitude'): + + if 'longitude' in max_decimals: data_type = 'longitude' index_no = 0 # longitude is in the first position # modify @@ -65,8 +65,8 @@ def replace_delimited_string_member( decimal_places=max_decimals[data_type] ) ) - - if max_decimals.has_key('latitude'): + + if 'latitude' in max_decimals: data_type = 'latitude' index_no = 1 # latitude is in the second position # modify elements @@ -98,7 +98,7 @@ def replace_delimited_string_member( ) ) - if max_decimals.has_key('altitude'): + if 'altitude' in max_decimals: data_type = 'altitude' index_no = 2 # altitude is in the third position # modify elements @@ -129,16 +129,16 @@ def replace_delimited_string_member( decimal_places=max_decimals[data_type] ) ) - - if max_decimals.has_key('heading'): + + if 'heading' in max_decimals: for el in doc.findall(".//{http://www.opengis.net/kml/2.2}heading"): new_val = round(float(el.text), max_decimals['heading']) el.getparent().heading = K.heading(new_val) - if max_decimals.has_key('tilt'): + if 'tilt' in max_decimals: for el in doc.findall(".//{http://www.opengis.net/kml/2.2}tilt"): new_val = round(float(el.text), max_decimals['tilt']) el.getparent().tilt = K.tilt(new_val) - if max_decimals.has_key('range'): + if 'range' in max_decimals: for el in doc.findall(".//{http://www.opengis.net/kml/2.2}range"): new_val = round(float(el.text), max_decimals['range']) el.getparent().range = K.range(new_val) diff --git a/src/pykml/parser.py b/src/pykml/parser.py index e1c6099..f4b35bb 100644 --- a/src/pykml/parser.py +++ b/src/pykml/parser.py @@ -1,11 +1,14 @@ '''pyKML Parser Module -The pykml.parser module provides functions that can be used to parse KML +The pykml.parser module provides functions that can be used to parse KML from a file or remote URL. ''' import sys import os -import urllib2 +try: # Python2 support + import urllib2 +except ImportError: # Python3 support + import urllib.request as urllib2 from lxml import etree, objectify OGCKML_SCHEMA = 'http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd' @@ -23,17 +26,17 @@ def __init__(self, schema): # try to open a remote URL f = urllib2.urlopen(schema) self.schema = etree.XMLSchema(file=f) - + def validate(self, doc): """Validates a KML document - - This method eturns a boolean value indicating whether the KML document + + This method eturns a boolean value indicating whether the KML document is valid when compared to the XML Schema.""" return self.schema.validate(doc) - + def assertValid(self, doc): """Asserts that a KML document is valide - + The method generates a validation error if the document is not valid when compared to the XML Schema. """ @@ -41,24 +44,24 @@ def assertValid(self, doc): def fromstring(text, schema=None): """Parses a KML text string - - This function parses a KML text string and optionally validates it against + + This function parses a KML text string and optionally validates it against a provided schema object""" if schema: - parser = objectify.makeparser(schema = schema.schema) + parser = objectify.makeparser(schema=schema.schema) return objectify.fromstring(text, parser=parser) else: return objectify.fromstring(text) def parse(fileobject, schema=None): """Parses a file object - - This function parses a KML file object, and optionally validates it against + + This function parses a KML file object, and optionally validates it against a provided schema. """ if schema: # with validation - parser = objectify.makeparser(schema = schema.schema, strip_cdata=False) + parser = objectify.makeparser(schema=schema.schema, strip_cdata=False) return objectify.parse(fileobject, parser=parser) else: # without validation @@ -68,12 +71,12 @@ def parse(fileobject, schema=None): def validate_kml(): """Validate a KML file - + Example: validate_kml test.kml """ from pykml.parser import parse from optparse import OptionParser - + parser = OptionParser( usage="usage: %prog FILENAME_or_URL", version="%prog 0.1", @@ -85,7 +88,7 @@ def validate_kml(): parser.error("wrong number of arguments") else: uri = args[0] - + try: # try to open as a file fileobject = open(uri) @@ -96,16 +99,16 @@ def validate_kml(): raise ValueError('Unable to load URI {0}'.format(uri)) except: raise - + doc = parse(fileobject, schema=None) - + if options.schema_uri: schema = Schema(options.schema_uri) else: # by default, use the OGC base schema sys.stdout.write("Validating against the default schema: {0}\n".format(OGCKML_SCHEMA)) schema = Schema(OGCKML_SCHEMA) - + sys.stdout.write("Validating document...\n") if schema.validate(doc): sys.stdout.write("Congratulations! The file is valid.\n") @@ -119,4 +122,3 @@ def validate_kml(): pass #variable was not defined else: fileobject.close - \ No newline at end of file diff --git a/src/pykml/test/test_factory.py b/src/pykml/test/test_factory.py index 06ce711..ebd85ab 100644 --- a/src/pykml/test/test_factory.py +++ b/src/pykml/test/test_factory.py @@ -25,11 +25,11 @@ def compare_etree(tree1, tree2): return True class KmlFactoryTestCase(unittest.TestCase): - + def test_get_factory_object_name(self): "Tests obtaining a factory object" from pykml.factory import get_factory_object_name - + self.assertEqual( get_factory_object_name('http://www.opengis.net/kml/2.2'), 'KML' @@ -39,19 +39,20 @@ def test_get_factory_object_name(self): 'ATOM' ) self.assertEqual(get_factory_object_name(None), 'KML') - + def test_trivial_kml_document(self): """Tests the creation of a trivial OGC KML document.""" doc = KML.kml() schema = Schema("ogckml22.xsd") self.assertTrue(schema.validate(doc)) - self.assertEquals( - etree.tostring(doc), - '' ) - + def test_basic_kml_document_2(self): """Tests the creation of a basic OGC KML document.""" doc = KML.kml( @@ -69,11 +70,12 @@ def test_basic_kml_document_2(self): self.assertTrue(Schema("ogckml22.xsd").validate(doc)) # validate against a remote schema self.assertTrue(Schema("http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd").validate(doc)) - - self.assertEquals( - etree.tostring(doc), - '' '' 'KmlFile' @@ -86,7 +88,7 @@ def test_basic_kml_document_2(self): '' '' ) - + def test_basic_kml_document(self): """Tests the creation of a basic KML with Google Extensions .""" doc = KML.kml( @@ -115,10 +117,11 @@ def test_basic_kml_document(self): ) ) self.assertTrue(Schema("kml22gx.xsd").validate(doc)) - self.assertEquals( - etree.tostring(doc), - '' '' '' @@ -145,7 +148,7 @@ def test_basic_kml_document(self): '' '' ) - + def test_kml_document_with_atom_element(self): """Tests the creation of a KML document with an ATOM element.""" doc = KML.kml( @@ -163,10 +166,11 @@ def test_kml_document_with_atom_element(self): ) ) self.assertTrue(Schema("kml22gx.xsd").validate(doc)) - self.assertEquals( - etree.tostring(doc), - '' '' '' @@ -187,23 +191,23 @@ def test_kml_document_with_cdata_description(self): """Tests the creation of a KML document with a CDATA element.""" from pykml.factory import KML_ElementMaker as KML from lxml import etree - + doc = KML.description( '

CDATA Tags are useful!

' ) - self.assertEquals( - etree.tostring(doc), + self.assertEqual( + etree.tostring(doc).decode(), '' '<h1>CDATA Tags are useful!</h1>' '' ) - + def test_kml_document_with_cdata_description_2(self): """Tests the creation of a KML document with a CDATA element.""" - + from pykml.factory import KML_ElementMaker as KML from pykml.factory import ATOM_ElementMaker as ATOM from pykml.factory import GX_ElementMaker as GX @@ -224,10 +228,11 @@ def test_kml_document_with_cdata_description_2(self): ), ), ) - self.assertEquals( - etree.tostring(doc), - '' '' '' @@ -248,11 +253,11 @@ def test_kml_document_with_cdata_description_2(self): class GeneratePythonScriptTestCase(unittest.TestCase): - + def test_write_python_script_for_kml_document(self): """Tests the creation of a trivial OGC KML document.""" from pykml.factory import write_python_script_for_kml_document - + doc = KML.kml( KML.Document( ATOM.author( @@ -268,7 +273,7 @@ def test_write_python_script_for_kml_document(self): ) ) script = write_python_script_for_kml_document(doc) - self.assertEquals( + self.assertEqual( script, 'from lxml import etree\n' 'from pykml.factory import KML_ElementMaker as KML\n' @@ -290,13 +295,13 @@ def test_write_python_script_for_kml_document(self): ' ),\n' ' ),\n' ')\n' - 'print etree.tostring(etree.ElementTree(doc),pretty_print=True)\n' + 'print(etree.tostring(etree.ElementTree(doc),pretty_print=True).decode())\n' ) def test_write_python_script_for_multiline_coordinate_string(self): """Tests the creation of a trivial OGC KML document.""" from pykml.factory import write_python_script_for_kml_document - + test_datafile = path.join( path.dirname(__file__), 'testfiles', @@ -305,7 +310,7 @@ def test_write_python_script_for_multiline_coordinate_string(self): with open(test_datafile) as f: doc = parse(f, schema=None) script = write_python_script_for_kml_document(doc) - self.assertEquals( + self.assertEqual( script, 'from lxml import etree\n' 'from pykml.factory import KML_ElementMaker as KML\n' @@ -337,7 +342,7 @@ def test_write_python_script_for_multiline_coordinate_string(self): ' ),\n' ' ),\n' ')\n' -'print etree.tostring(etree.ElementTree(doc),pretty_print=True)\n' +'print(etree.tostring(etree.ElementTree(doc),pretty_print=True).decode())\n' ) @@ -347,7 +352,7 @@ def test_write_python_script_for_kml_document_with_cdata(self): import tempfile from pykml.parser import parse from pykml.factory import write_python_script_for_kml_document - + test_datafile = path.join( path.dirname(__file__), 'testfiles', @@ -358,7 +363,7 @@ def test_write_python_script_for_kml_document_with_cdata(self): with open(test_datafile) as f: doc = parse(f, schema=schema) script = write_python_script_for_kml_document(doc) - self.assertEquals( + self.assertEqual( script, 'from lxml import etree\n' 'from pykml.factory import KML_ElementMaker as KML\n' @@ -381,14 +386,14 @@ def test_write_python_script_for_kml_document_with_cdata(self): ' ),\n' ' ),\n' ')\n' - 'print etree.tostring(etree.ElementTree(doc),pretty_print=True)\n' + 'print(etree.tostring(etree.ElementTree(doc),pretty_print=True).decode())\n' ) # create a temporary python file handle, tfile = tempfile.mkstemp(suffix='.py') - #print tfile + #print(tfile) with open(tfile, 'w') as f: f.write(script) - + # execute the temporary python file to create a KML file import subprocess current_env = os.environ.copy() @@ -403,19 +408,19 @@ def test_write_python_script_for_kml_document_with_cdata(self): env=current_env ) self.assertEqual(exit_code, 0) - + # parse and validate the KML generated by the temporary script doc2 = parse(temp_kml_file, schema=schema) # test that the root element is as expected self.assertEqual(doc2.docinfo.root_name, 'kml') - + def test_write_python_script_for_kml_document_with_namespaces(self): """Tests the creation of an OGC KML document with several namespaces""" import os import tempfile from pykml.parser import parse from pykml.factory import write_python_script_for_kml_document - + test_datafile = path.join( path.dirname(__file__), 'testfiles', @@ -425,13 +430,13 @@ def test_write_python_script_for_kml_document_with_namespaces(self): with open(test_datafile) as f: doc = parse(f, schema=schema) script = write_python_script_for_kml_document(doc) - + # create a temporary python file handle, tfile = tempfile.mkstemp(suffix='.py') - #print tfile #uncomment to print the temporary filename + #print(tfile) #uncomment to print the temporary filename with open(tfile, 'w') as f: f.write(script) - + # execute the temporary python file to create a KML file # set the PYTHONPATH variable so that it references the root # of the pyKML library @@ -441,23 +446,23 @@ def test_write_python_script_for_kml_document_with_namespaces(self): os.path.join(path.dirname(__file__),'../..') ) handle, temp_kml_file = tempfile.mkstemp(suffix='.kml') - #print temp_kml_file + #print(temp_kml_file) with open(temp_kml_file, 'w') as f: exit_code = subprocess.call(["python",tfile], stdout=f, env=current_env) self.assertEqual(exit_code, 0) - + # parse and validate the KML generated by the temporary script doc2 = parse(temp_kml_file, schema=schema) # test that the root element is as expected self.assertEqual(doc2.docinfo.root_name, 'kml') - + def test_write_python_script_for_kml_document_with_comments(self): """Tests the creation of an OGC KML document with several comments""" import os import tempfile from pykml.parser import parse from pykml.factory import write_python_script_for_kml_document - + test_datafile = path.join( path.dirname(__file__), 'testfiles', @@ -467,13 +472,13 @@ def test_write_python_script_for_kml_document_with_comments(self): with open(test_datafile) as f: doc = parse(f, schema=schema) script = write_python_script_for_kml_document(doc) - + # create a temporary python file handle, tfile = tempfile.mkstemp(suffix='.py') - #print tfile # Useful for debugging + #print(tfile) # Useful for debugging with open(tfile, 'w') as f: f.write(script) - + # execute the temporary python file to create a KML file import subprocess current_env = os.environ.copy() @@ -481,11 +486,11 @@ def test_write_python_script_for_kml_document_with_comments(self): os.path.join(path.dirname(__file__),'../..') ) handle, temp_kml_file = tempfile.mkstemp(suffix='.kml') - #print temp_kml_file # Useful for debugging + #print(temp_kml_file) # Useful for debugging with open(temp_kml_file, 'w') as f: exit_code = subprocess.call(["python",tfile], stdout=f, env=current_env) self.assertEqual(exit_code, 0) - + # parse and validate the KML generated by the temporary script doc2 = parse(temp_kml_file, schema=schema) # test that the root element is as expected @@ -495,4 +500,4 @@ def test_write_python_script_for_kml_document_with_comments(self): self.assertTrue(compare_etree(doc.getroot(), doc2.getroot())) if __name__ == '__main__': - unittest.main() \ No newline at end of file + unittest.main() diff --git a/src/pykml/test/test_helpers.py b/src/pykml/test/test_helpers.py index 3c479b9..195cd3b 100644 --- a/src/pykml/test/test_helpers.py +++ b/src/pykml/test/test_helpers.py @@ -6,24 +6,24 @@ from pykml.parser import fromstring class KmlHelpersTestCase(unittest.TestCase): - + def test_separate_namespace(self): """Tests the function that separates namespaces from qualified names""" from pykml.helpers import separate_namespace - + namespace, element_name = separate_namespace('{garden}eggplant') self.assertEqual(namespace, 'garden') self.assertEqual(element_name, 'eggplant') - + namespace, element_name = separate_namespace('eggplant') self.assertEqual(namespace, None) self.assertEqual(element_name, 'eggplant') - + def test_set_max_decimal_places(self): """Tests setting the number of decimal places in a document""" - + from pykml.helpers import set_max_decimal_places - + test_kml = ( '' '' '' ) - doc = fromstring(test_kml, schema=Schema("ogckml22.xsd")) + doc = fromstring(test_kml.encode(), schema=Schema("ogckml22.xsd")) set_max_decimal_places( - doc, + doc, max_decimals={ 'longitude': 6, 'latitude': 5, @@ -84,41 +84,41 @@ def test_set_max_decimal_places(self): #'range': 0, # range values will not be changed } ) - + longitude_list = doc.findall(".//{http://www.opengis.net/kml/2.2}longitude") - self.assertAlmostEquals(longitude_list[0], -105.638133) - + self.assertAlmostEqual(longitude_list[0], -105.638133) + latitude_list = doc.findall(".//{http://www.opengis.net/kml/2.2}latitude") - self.assertAlmostEquals(latitude_list[0], 40.25542) - + self.assertAlmostEqual(latitude_list[0], 40.25542) + altitude_list = doc.findall(".//{http://www.opengis.net/kml/2.2}altitude") - self.assertAlmostEquals(altitude_list[0], 0.12) - + self.assertAlmostEqual(altitude_list[0], 0.12) + heading_list = doc.findall(".//{http://www.opengis.net/kml/2.2}heading") - self.assertAlmostEquals(heading_list[0], -75.3) - + self.assertAlmostEqual(heading_list[0], -75.3) + tilt_list = doc.findall(".//{http://www.opengis.net/kml/2.2}tilt") - self.assertAlmostEquals(tilt_list[0], 23.0) - + self.assertAlmostEqual(tilt_list[0], 23.0) + # Note that the range value was not changed range_list = doc.findall(".//{http://www.opengis.net/kml/2.2}range") - self.assertAlmostEquals(range_list[0], 234.1234567890) - + self.assertAlmostEqual(range_list[0], 234.1234567890) + coords_list = doc.findall(".//{http://www.opengis.net/kml/2.2}coordinates") - self.assertEquals( + self.assertEqual( coords_list[0], "-105.638133,40.25542,3826.12" ) - self.assertEquals( - coords_list[1], + self.assertEqual( + coords_list[1], '-105.64009,40.25778,0.0 ' '-105.639708,40.25681,0.0 ' '-105.638919,40.25607,0.0 ' '-105.638534,40.2556,0.0' ) #import ipdb; ipdb.set_trace() - self.assertEquals( - coords_list[2], + self.assertEqual( + coords_list[2], '-105.641157,40.26643,0.0 ' '-105.642471,40.26601,0.0 ' '-105.642801,40.26549,0.0 ' @@ -133,9 +133,9 @@ def test_set_max_decimal_places(self): def test_set_max_decimal_places_track(self): """Tests setting the number of decimal places for track data""" - + from pykml.helpers import set_max_decimal_places - + test_kml = ( '' '' '' ) - doc = fromstring(test_kml, schema=Schema("kml22gx.xsd")) + doc = fromstring(test_kml.encode(), schema=Schema("kml22gx.xsd")) set_max_decimal_places( - doc, + doc, max_decimals={ 'longitude': 3, 'latitude': 2, 'altitude': 1, } ) - + coords_list = doc.findall(".//{http://www.google.com/kml/ext/2.2}coord") #import ipdb; ipdb.set_trace() - self.assertEquals( - coords_list[0], + self.assertEqual( + coords_list[0], '-122.111 37.11 151.3' - ) \ No newline at end of file + ) + + +if __name__ == '__main__': + unittest.main() diff --git a/src/pykml/test/test_parser.py b/src/pykml/test/test_parser.py index 95536d8..a36fae4 100644 --- a/src/pykml/test/test_parser.py +++ b/src/pykml/test/test_parser.py @@ -1,7 +1,16 @@ import unittest from os import path -import urllib2 -from StringIO import StringIO +try: # Python2 support + import urllib2 + URLError = urllib2.URLError +except ImportError: # Python3 support + import urllib.request as urllib2 + from urllib.error import URLError +try: # Python2 support + from StringIO import StringIO +except ImportError: # Python3 support + from io import StringIO + from lxml import etree from pykml.parser import Schema from pykml.parser import fromstring @@ -9,7 +18,7 @@ class ValidatorTestCase(unittest.TestCase): - + def test_initialize_schema(self): """Tests the creation Schema instance""" schema = Schema("ogckml22.xsd") @@ -22,15 +31,15 @@ def test_initialize_schema_remote_url(self): class ParseKmlOgcTestCase(unittest.TestCase): "A collection of tests related to parsing KML OGC documents" - + def test_fromstring_kml_document(self): "Tests the parsing of an valid KML string" test_kml = '' tree = fromstring(test_kml, schema=Schema("ogckml22.xsd")) - self.assertEquals(etree.tostring(tree), test_kml) + self.assertEqual(etree.tostring(tree).decode(), test_kml) tree = fromstring(test_kml) - self.assertEquals(etree.tostring(tree), test_kml) - + self.assertEqual(etree.tostring(tree).decode(), test_kml) + def test_fromstring_invalid_kml_document(self): "Tests the parsing of an invalid KML string" test_kml = '' @@ -41,17 +50,17 @@ def test_fromstring_invalid_kml_document(self): self.assertTrue(True) except: self.assertTrue(False) - + def test_parse_kml_document(self): "Tests the parsing of an valid KML file object" test_kml = '' fileobject = StringIO(test_kml) schema = Schema("ogckml22.xsd") tree = parse(fileobject, schema=schema) - self.assertEquals(etree.tostring(tree), test_kml) + self.assertEqual(etree.tostring(tree).decode(), test_kml) tree = parse(fileobject, schema=schema) - self.assertEquals(etree.tostring(tree), test_kml) - + self.assertEqual(etree.tostring(tree).decode(), test_kml) + def test_parse_invalid_kml_document(self): "Tests the parsing of an invalid KML document" fileobject = StringIO('') @@ -62,7 +71,7 @@ def test_parse_invalid_kml_document(self): self.assertTrue(True) except: self.assertTrue(False) - + def test_parse_kml_url(self): "Tests the parsing of a KML URL" url = 'http://code.google.com/apis/kml/documentation/KML_Samples.kml' @@ -72,15 +81,15 @@ def test_parse_kml_url(self): try: fileobject = urllib2.urlopen(url) tree = parse(fileobject, schema=Schema("ogckml22.xsd")) - self.assertEquals( - etree.tostring(tree)[:78], + self.assertEqual( + etree.tostring(tree)[:78].decode(), '' '' 'KML Samples' ) - except urllib2.URLError: - print 'Unable to access the URL. Skipping test...' - + except URLError: + print('Unable to access the URL. Skipping test...') + def test_parse_kml_file_with_cdata(self): "Tests the parsing of a local KML file, with a CDATA description string" test_datafile = path.join( @@ -91,8 +100,8 @@ def test_parse_kml_file_with_cdata(self): # parse with validation with open(test_datafile) as f: doc = parse(f, schema=Schema('ogckml22.xsd')) - self.assertEquals( - etree.tostring(doc), + self.assertEqual( + etree.tostring(doc).decode(), '' '' '' @@ -115,8 +124,8 @@ def test_parse_kml_file_with_cdata(self): # parse without validation with open(test_datafile) as f: doc2 = parse(f) - self.assertEquals( - etree.tostring(doc2), + self.assertEqual( + etree.tostring(doc2).decode(), '' '' '' @@ -136,7 +145,7 @@ def test_parse_kml_file_with_cdata(self): '' '' ) - + def test_parse_invalid_ogc_kml_document(self): """Tests the parsing of an invalid KML document. Note that this KML document uses elements that are not in the OGC KML spec. @@ -146,8 +155,8 @@ def test_parse_invalid_ogc_kml_document(self): fileobject = urllib2.urlopen(url) tree = parse(fileobject, schema=Schema("ogckml22.xsd")) self.assertTrue(False) - except urllib2.URLError: - print 'Unable to access the URL. Skipping test...' + except URLError: + print('Unable to access the URL. Skipping test...') except etree.XMLSyntaxError: self.assertTrue(True) except: @@ -156,24 +165,24 @@ def test_parse_invalid_ogc_kml_document(self): class ParseKmlGxTestCase(unittest.TestCase): "A collection of tests related to parsing KML Google Extension documents" - + def test_parse_kml_url(self): "Tests the parsing of a KML URL" url = 'http://code.google.com/apis/kml/documentation/kmlfiles/altitudemode_reference.kml' try: fileobject = urllib2.urlopen(url) tree = parse(fileobject, schema=Schema('kml22gx.xsd')) - self.assertEquals( - etree.tostring(tree)[:185], + self.assertEqual( + etree.tostring(tree)[:185].decode(), '' '' '' 'gx:altitudeMode Example' ) - except urllib2.URLError: - print 'Unable to access the URL. Skipping test...' - + except URLError: + print('Unable to access the URL. Skipping test...') + def test_parse_kml_file(self): "Tests the parsing of a local KML file, with validation" test_datafile = path.join( @@ -191,22 +200,22 @@ def test_parse_kml_file(self): with open(test_datafile) as f: doc = parse(f, schema=Schema('http://code.google.com/apis/kml/schema/kml22gx.xsd')) self.assertTrue(True) - + def test_parse_kml_url_2(self): "Tests the parsing of a KML URL" url = 'http://code.google.com/apis/kml/documentation/kmlfiles/animatedupdate_example.kml' try: fileobject = urllib2.urlopen(url) tree = parse(fileobject, schema=Schema('kml22gx.xsd')) - self.assertEquals( - etree.tostring(tree)[:137], + self.assertEqual( + etree.tostring(tree)[:137].decode(), '' '' 'gx:AnimatedUpdate example' ) - except urllib2.URLError: - print 'Unable to access the URL. Skipping test...' + except URLError: + print('Unable to access the URL. Skipping test...') if __name__ == '__main__': unittest.main() diff --git a/src/pykml/test/test_util.py b/src/pykml/test/test_util.py index 1b075f9..a1cafa8 100644 --- a/src/pykml/test/test_util.py +++ b/src/pykml/test/test_util.py @@ -6,11 +6,11 @@ from pykml.factory import KML_ElementMaker as KML class KmlUtilTestCase(unittest.TestCase): - + def test_count_elements(self): """Tests the counting of elements in a KML document.""" from pykml.util import count_elements - + test_datafile = path.join( path.dirname(__file__), 'testfiles', @@ -19,23 +19,23 @@ def test_count_elements(self): with open(test_datafile) as f: doc = parse(f, schema=Schema('kml22gx.xsd')) summary = count_elements(doc) - - self.assertTrue(summary.has_key('http://www.opengis.net/kml/2.2')) + + self.assertTrue('http://www.opengis.net/kml/2.2' in summary) self.assertEqual(4, summary['http://www.opengis.net/kml/2.2']['Placemark'] ) - self.assertTrue(summary.has_key('http://www.google.com/kml/ext/2.2')) + self.assertTrue('http://www.google.com/kml/ext/2.2' in summary) self.assertEqual(5, summary['http://www.google.com/kml/ext/2.2']['FlyTo'] ) self.assertEqual(2, summary['http://www.google.com/kml/ext/2.2']['Wait'] ) - + def test_wrap_angle180(self): """Tests the wrap_angle180 utility function.""" from pykml.util import wrap_angle180 - + self.assertEqual(wrap_angle180(0), 0) self.assertEqual(wrap_angle180(180), -180) self.assertEqual(wrap_angle180(361), 1) @@ -45,7 +45,7 @@ def test_wrap_angle180(self): def test_to_wkt_list_simple_polygon(self): """Tests the to_wkt_list function for a polygon with inner rings.""" from pykml.util import to_wkt_list - + # create a polygon poly = KML.Polygon( KML.extrude('1'), @@ -62,12 +62,12 @@ def test_to_wkt_list_simple_polygon(self): ), ), ) - + poly_wkt_list = to_wkt_list(poly) - + self.assertEqual(len(poly_wkt_list), 1) self.assertEqual( - poly_wkt_list[0], + poly_wkt_list[0], ('POLYGON ((-122.366278 37.818844 30, ' '-122.365248 37.819267 30, ' '-122.365640 37.819861 30, ' @@ -75,11 +75,11 @@ def test_to_wkt_list_simple_polygon(self): '-122.366278 37.818844 30))') ) - + def test_to_wkt_list_complex_polygon(self): """Tests the to_wkt_list function for a polygon with inner rings.""" from pykml.util import to_wkt_list - + # create a polygon poly = KML.Polygon( KML.extrude('1'), @@ -116,12 +116,12 @@ def test_to_wkt_list_complex_polygon(self): ), ), ) - + poly_wkt_list = to_wkt_list(poly) - + self.assertEqual(len(poly_wkt_list), 1) self.assertEqual( - poly_wkt_list[0], + poly_wkt_list[0], ('POLYGON ((-122.366278 37.818844 30, ' '-122.365248 37.819267 30, ' '-122.365640 37.819861 30, ' @@ -136,11 +136,11 @@ def test_to_wkt_list_complex_polygon(self): '-122.366488 37.819402 30, ' '-122.366212 37.818977 30))') ) - + def test_getXmlWithCDATA(self): '''tests the format_as_cdata function''' from pykml.util import format_xml_with_cdata - + kmlobj = KML.kml( KML.Document( KML.Placemark( @@ -154,10 +154,11 @@ def test_getXmlWithCDATA(self): ) ) self.assertEqual( - etree.tostring(format_xml_with_cdata(kmlobj)), - '' + etree.tostring(format_xml_with_cdata(kmlobj)).decode(), + '' '' '' 'foobar' @@ -170,29 +171,29 @@ def test_getXmlWithCDATA(self): '' '' ) - + def test_convert_csv_to_kml(self): """Tests the convert_csv_to_kml function""" import tempfile from pykml.util import convert_csv_to_kml from pykml.util import format_xml_with_cdata - + # create a CSV file for testing - csvfile = tempfile.TemporaryFile() + csvfile = tempfile.TemporaryFile(mode='w+') csvfile.write('name,snippet,lat,lon\n') csvfile.write('first,The first one,45.0,-90.0\n') csvfile.write('second,The second one,46.0,-89.0\n') csvfile.write('third,"The third one (with quotes)",45.0,-88.0\n') csvfile.seek(0) - + kmldoc = convert_csv_to_kml(csvfile) - csvfile.close() - + self.assertEqual( - etree.tostring(format_xml_with_cdata(kmldoc)), - '' '' '' @@ -234,19 +235,19 @@ def test_convert_csv_to_kml(self): '' '' ) - + def test_convert_csv_to_kml_missing_coordinate_fields(self): """Tests the convert_csv_to_kml function""" import tempfile from pykml.util import convert_csv_to_kml - + # create a CSV file for testing - csvfile = tempfile.TemporaryFile() + csvfile = tempfile.TemporaryFile(mode='w+') csvfile.write('name,snippet,y,x\n') csvfile.write('first,The first one,45.0,-90.0\n') csvfile.write('second,The second one,46.0,-89.0\n') csvfile.seek(0) - + try: convert_csv_to_kml(csvfile) except KeyError: @@ -260,3 +261,7 @@ def test_clean_xml_string(self): from pykml.util import clean_xml_string self.assertEqual(clean_xml_string('\xce'),'') #self.assertEqual(clean_xml_string('Grande-\xcele'),'Grande-le') + + +if __name__ == '__main__': + unittest.main() diff --git a/src/pykml/util.py b/src/pykml/util.py index dda16b7..ecbde70 100644 --- a/src/pykml/util.py +++ b/src/pykml/util.py @@ -1,6 +1,6 @@ """ pyKML Utility Module -The pykml.utility module provides utility functions that operate on KML +The pykml.utility module provides utility functions that operate on KML documents """ import re @@ -11,17 +11,17 @@ def clean_xml_string(input_string): return ''.join(c for c in input_string if ascii.isascii(c)) def format_xml_with_cdata( - obj, + obj, cdata_elements = ['description', 'text', 'linkDescription', 'displayName'] ): from lxml import etree # Convert Objectify document to lxml.etree (is there a better way?) root = etree.fromstring(etree.tostring(etree.ElementTree(obj))) - + #Create an xpath expression to search for all desired cdata elements - xpath = '|'.join(map(lambda tag: '//kml:' + tag, cdata_elements)) - + xpath = '|'.join(['//kml:' + tag for tag in cdata_elements]) + results = root.xpath( xpath, namespaces = {'kml': 'http://www.opengis.net/kml/2.2'} @@ -39,9 +39,9 @@ def count_elements(doc): except: namespace = None element_name = el.tag - if not summary.has_key(namespace): + if namespace not in summary: summary[namespace] = {} - if not summary[namespace].has_key(element_name): + if element_name not in summary[namespace]: summary[namespace][element_name] = 1 else: summary[namespace][element_name] += 1 @@ -58,7 +58,7 @@ def wrap_angle180(angle): def to_wkt_list(doc): '''converts all geometries to Well Know Text format''' from lxml import etree - + def ring_coords_to_wkt(ring): '''converts LinearRing coordinates to WKT style coordinates''' return( @@ -66,7 +66,7 @@ def ring_coords_to_wkt(ring): ring.coordinates.text.strip() ).replace(' ','@@').replace(',',' ').replace('@@',', ') ) - + ring_wkt_list = [] context = etree.iterwalk( doc, @@ -77,7 +77,7 @@ def ring_coords_to_wkt(ring): '{http://www.opengis.net/kml/2.2}MultiPolygon']: #print("%s: %s" % (action, elem.tag)) if elem.tag == '{http://www.opengis.net/kml/2.2}Polygon': - + # outer boundary ringlist = [ '({0})'.format( @@ -90,7 +90,7 @@ def ring_coords_to_wkt(ring): ring_coords_to_wkt(obj.LinearRing) ) ) - + wkt = 'POLYGON ({rings})'.format(rings=', '.join(ringlist)) ring_wkt_list.append(wkt) return(ring_wkt_list) @@ -106,20 +106,25 @@ def convert_csv_to_kml( snippet_field='snippet', ): '''Reads a CSV document from a file-like object and converts it to KML''' - + import csv #import urllib2 from pykml.factory import KML_ElementMaker as KML - + def iteritems(d): + try: + return d.iteritems() + except AttributeError: + return d.items() + # create a basic KML document kmldoc = KML.kml(KML.Document( KML.Folder( KML.name("KmlFile")) ) ) - + csvdoc = csv.DictReader(fileObj) - + # if field is not found, check for other common field names if latitude_field not in csvdoc.fieldnames: match_field = None @@ -192,30 +197,30 @@ def convert_csv_to_kml( raise KeyError( 'Longitude field ({0}) was not found in the CSV file ' 'column names {1}'.format(longitude_field,csvdoc.fieldnames) - ) + ) for row in csvdoc: pm = KML.Placemark() - if row.has_key(name_field): + if name_field in row: pm.append( KML.name(clean_xml_string(row[name_field])) ) - if row.has_key(snippet_field): + if snippet_field in row: pm.append( KML.Snippet(clean_xml_string(row[snippet_field]),maxLines="2") ) - if row.has_key(description_field): + if description_field in row: pm.append( KML.description(clean_xml_string(row[description_field])) ) else: desc = '>sys.stderr, err.msg - print >>sys.stderr, "for help use --help" + sys.stderr.write(err.msg) + sys.stderr.write("for help use --help") return 2 if __name__ == "__main__": sys.exit(main()) - - diff --git a/src/utilities/test_gen_pykml.py b/src/utilities/test_gen_pykml.py index 4da17c3..30b912e 100644 --- a/src/utilities/test_gen_pykml.py +++ b/src/utilities/test_gen_pykml.py @@ -1,6 +1,6 @@ -from pykml.kml_gx.factory import KML_ElementMaker as KML -from pykml.kml_gx.factory import ATOM_ElementMaker as ATOM -from pykml.kml_gx.factory import GX_ElementMaker as GX +from pykml.factory import KML_ElementMaker as KML +from pykml.factory import ATOM_ElementMaker as ATOM +from pykml.factory import GX_ElementMaker as GX doc = KML.kml( KML.Document( @@ -98,17 +98,17 @@ id="transYellowPoly", ), KML.Style( KML.BalloonStyle( - KML.text(" + KML.text(""" $[name]

$[description] - "), + """), ), id="noDrivingDirections", ), KML.Folder( KML.name("Placemarks"), - KML.description("These are just some of the different kinds of placemarks with - which you can mark your favorite places"), + KML.description("These are just some of the different kinds of placemarks with" + "which you can mark your favorite places"), KML.LookAt( KML.longitude("-122.0839597145766"), KML.latitude("37.42222904525232"), @@ -119,8 +119,8 @@ ), KML.Placemark( KML.name("Simple placemark"), - KML.description("Attached to the ground. Intelligently places itself at the - height of the underlying terrain."), + KML.description("Attached to the ground. Intelligently places itself at the" + "height of the underlying terrain."), KML.Point( KML.coordinates("-122.0822035425683,37.42228990140251,0"), ), @@ -146,8 +146,7 @@ KML.Placemark( KML.name("Extruded placemark"), KML.visibility("0"), - KML.description("Tethered to the ground by a customizable - "tail""), + KML.description("Tethered to the ground by a customizable 'tail'"), KML.LookAt( KML.longitude("-122.0845787421525"), KML.latitude("37.42215078737763"), @@ -167,8 +166,8 @@ KML.Folder( KML.name("Styles and Markup"), KML.visibility("0"), - KML.description("With KML it is easy to create rich, descriptive markup to - annotate and enrich your placemarks"), + KML.description("With KML it is easy to create rich, descriptive markup to" + "annotate and enrich your placemarks"), KML.LookAt( KML.longitude("-122.0845787422371"), KML.latitude("37.42215078726837"), @@ -181,8 +180,7 @@ KML.Document( KML.name("Highlighted Icon"), KML.visibility("0"), - KML.description("Place your mouse over the icon to see it display the new - icon"), + KML.description("Place your mouse over the icon to see it display the new icon"), KML.LookAt( KML.longitude("-122.0856552124024"), KML.latitude("37.4224281311035"), @@ -227,7 +225,7 @@ KML.Placemark( KML.name("Descriptive HTML"), KML.visibility("0"), - KML.description("Click on the blue link!

+ KML.description("""Click on the blue link!

Placemark descriptions can be enriched by using many standard HTML tags.
For example:
@@ -325,7 +323,7 @@
abcde

-[Did you notice that double-clicking on the placemark doesn't cause the viewer to take you anywhere? This is because it is possible to directly author a "placeless placemark". If you look at the code for this example, you will see that it has neither a point coordinate nor a LookAt element.]"), +[Did you notice that double-clicking on the placemark doesn't cause the viewer to take you anywhere? This is because it is possible to directly author a "placeless placemark". If you look at the code for this example, you will see that it has neither a point coordinate nor a LookAt element.]"""), ), ), KML.Folder( @@ -359,13 +357,13 @@ KML.Folder( KML.name("Screen Overlays"), KML.visibility("0"), - KML.description("Screen overlays have to be authored directly in KML. These - examples illustrate absolute and dynamic positioning in screen space."), + KML.description("Screen overlays have to be authored directly in KML. These" + " examples illustrate absolute and dynamic positioning in screen space."), KML.ScreenOverlay( KML.name("Simple crosshairs"), KML.visibility("0"), - KML.description("This screen overlay uses fractional positioning to put the - image in the exact center of the screen"), + KML.description("This screen overlay uses fractional positioning to put the" + " image in the exact center of the screen"), KML.Icon( KML.href("http://code.google.com/apis/kml/documentation/crosshairs.png"), ), @@ -444,9 +442,9 @@ KML.Folder( KML.name("Paths"), KML.visibility("0"), - KML.description("Examples of paths. Note that the tessellate tag is by default - set to 0. If you want to create tessellated lines, they must be authored - (or edited) directly in KML."), + KML.description("Examples of paths. Note that the tessellate tag is by default" + "set to 0. If you want to create tessellated lines, they must be authored" + "(or edited) directly in KML."), KML.Placemark( KML.name("Tessellated"), KML.visibility("0"), @@ -461,8 +459,8 @@ ), KML.LineString( KML.tessellate("1"), - KML.coordinates(" -112.0814237830345,36.10677870477137,0 - -112.0870267752693,36.0905099328766,0 "), + KML.coordinates(""" -112.0814237830345,36.10677870477137,0 + -112.0870267752693,36.0905099328766,0 """), ), ), KML.Placemark( @@ -479,8 +477,8 @@ ), KML.LineString( KML.tessellate("0"), - KML.coordinates(" -112.080622229595,36.10673460007995,0 - -112.085242575315,36.09049598612422,0 "), + KML.coordinates(""" -112.080622229595,36.10673460007995,0 + -112.085242575315,36.09049598612422,0 """), ), ), KML.Placemark( @@ -499,7 +497,7 @@ KML.LineString( KML.tessellate("1"), KML.altitudeMode("absolute"), - KML.coordinates(" -112.265654928602,36.09447672602546,2357 + KML.coordinates(""" -112.265654928602,36.09447672602546,2357 -112.2660384528238,36.09342608838671,2357 -112.2668139013453,36.09251058776881,2357 -112.2677826834445,36.09189827357996,2357 @@ -509,7 +507,7 @@ -112.2690144567276,36.08850916060472,2357 -112.2681528815339,36.08753813597956,2357 -112.2670588176031,36.08682685262568,2357 - -112.2657374587321,36.08646312301303,2357 "), + -112.2657374587321,36.08646312301303,2357 """), ), ), KML.Placemark( @@ -529,7 +527,7 @@ KML.extrude("1"), KML.tessellate("1"), KML.altitudeMode("absolute"), - KML.coordinates(" -112.2550785337791,36.07954952145647,2357 + KML.coordinates(""" -112.2550785337791,36.07954952145647,2357 -112.2549277039738,36.08117083492122,2357 -112.2552505069063,36.08260761307279,2357 -112.2564540158376,36.08395660588506,2357 @@ -539,7 +537,7 @@ -112.262073428656,36.08626019085147,2357 -112.2633204928495,36.08621519860091,2357 -112.2644963846444,36.08627897945274,2357 - -112.2656969554589,36.08649599090644,2357 "), + -112.2656969554589,36.08649599090644,2357 """), ), ), KML.Placemark( @@ -558,7 +556,7 @@ KML.LineString( KML.tessellate("1"), KML.altitudeMode("relativeToGround"), - KML.coordinates(" -112.2532845153347,36.09886943729116,645 + KML.coordinates(""" -112.2532845153347,36.09886943729116,645 -112.2540466121145,36.09919570465255,645 -112.254734666947,36.09984998366178,645 -112.255493345654,36.10051310621746,645 @@ -568,7 +566,7 @@ -112.2584106072308,36.10229131995655,645 -112.2596588987972,36.10240001286358,645 -112.2610581199487,36.10213176873407,645 - -112.2626285262793,36.10157011437219,645 "), + -112.2626285262793,36.10157011437219,645 """), ), ), KML.Placemark( @@ -588,7 +586,7 @@ KML.extrude("1"), KML.tessellate("1"), KML.altitudeMode("relativeToGround"), - KML.coordinates(" -112.2656634181359,36.09445214722695,630 + KML.coordinates(""" -112.2656634181359,36.09445214722695,630 -112.2652238941097,36.09520916122063,630 -112.2645079986395,36.09580763864907,630 -112.2638827428817,36.09628572284063,630 @@ -598,7 +596,7 @@ -112.264327720538,36.09880337400301,630 -112.2642436562271,36.09963644790288,630 -112.2639148687042,36.10055381117246,630 - -112.2626894973474,36.10149062823369,630 "), + -112.2626894973474,36.10149062823369,630 """), ), ), ), @@ -609,8 +607,8 @@ KML.Folder( KML.name("Google Campus"), KML.visibility("0"), - KML.description("A collection showing how easy it is to create 3-dimensional - buildings"), + KML.description("A collection showing how easy it is to create 3-dimensional" + "buildings"), KML.LookAt( KML.longitude("-122.084120030116"), KML.latitude("37.42174011925477"), @@ -628,7 +626,7 @@ KML.altitudeMode("relativeToGround"), KML.outerBoundaryIs( KML.LinearRing( - KML.coordinates(" -122.0848938459612,37.42257124044786,17 + KML.coordinates(""" -122.0848938459612,37.42257124044786,17 -122.0849580979198,37.42211922626856,17 -122.0847469573047,37.42207183952619,17 -122.0845725380962,37.42209006729676,17 @@ -649,7 +647,7 @@ -122.0845036949503,37.4226514386435,17 -122.0848020460801,37.42261133916315,17 -122.0847882750515,37.42256395055121,17 - -122.0848938459612,37.42257124044786,17 "), + -122.0848938459612,37.42257124044786,17 """), ), ), ), @@ -663,7 +661,7 @@ KML.altitudeMode("relativeToGround"), KML.outerBoundaryIs( KML.LinearRing( - KML.coordinates(" -122.0857412771483,37.42227033155257,17 + KML.coordinates(""" -122.0857412771483,37.42227033155257,17 -122.0858169768481,37.42231408832346,17 -122.085852582875,37.42230337469744,17 -122.0858799945639,37.42225686138789,17 @@ -681,7 +679,7 @@ -122.0856769818632,37.42281815323651,17 -122.0860162273783,37.42244918858722,17 -122.0857260327004,37.42229239604253,17 - -122.0857412771483,37.42227033155257,17 "), + -122.0857412771483,37.42227033155257,17 """), ), ), ), @@ -695,7 +693,7 @@ KML.altitudeMode("relativeToGround"), KML.outerBoundaryIs( KML.LinearRing( - KML.coordinates(" -122.0857862287242,37.42136208886969,25 + KML.coordinates(""" -122.0857862287242,37.42136208886969,25 -122.0857312990603,37.42136935989481,25 -122.0857312992918,37.42140934910903,25 -122.0856077073679,37.42138390166565,25 @@ -718,7 +716,7 @@ -122.0858640462341,37.42147115002957,25 -122.0858548911215,37.42140571326184,25 -122.0858091162768,37.4214057134039,25 - -122.0857862287242,37.42136208886969,25 "), + -122.0857862287242,37.42136208886969,25 """), ), ), ), @@ -732,7 +730,7 @@ KML.altitudeMode("relativeToGround"), KML.outerBoundaryIs( KML.LinearRing( - KML.coordinates(" -122.0844371128284,37.42177253003091,19 + KML.coordinates(""" -122.0844371128284,37.42177253003091,19 -122.0845118855746,37.42191111542896,19 -122.0850470999805,37.42178755121535,19 -122.0850719913391,37.42143663023161,19 @@ -756,7 +754,7 @@ -122.0841447047739,37.42167881534569,19 -122.084144704223,37.42181720660197,19 -122.0842503333074,37.4218170700446,19 - -122.0844371128284,37.42177253003091,19 "), + -122.0844371128284,37.42177253003091,19 """), ), ), ), @@ -779,22 +777,22 @@ KML.altitudeMode("relativeToGround"), KML.outerBoundaryIs( KML.LinearRing( - KML.coordinates(" -77.05788457660967,38.87253259892824,100 + KML.coordinates(""" -77.05788457660967,38.87253259892824,100 -77.05465973756702,38.87291016281703,100 -77.05315536854791,38.87053267794386,100 -77.05552622493516,38.868757801256,100 -77.05844056290393,38.86996206506943,100 - -77.05788457660967,38.87253259892824,100 "), + -77.05788457660967,38.87253259892824,100 """), ), ), KML.innerBoundaryIs( KML.LinearRing( - KML.coordinates(" -77.05668055019126,38.87154239798456,100 + KML.coordinates(""" -77.05668055019126,38.87154239798456,100 -77.05542625960818,38.87167890344077,100 -77.05485125901024,38.87076535397792,100 -77.05577677433152,38.87008686581446,100 -77.05691162017543,38.87054446963351,100 - -77.05668055019126,38.87154239798456,100 "), + -77.05668055019126,38.87154239798456,100 """), ), ), ), @@ -803,9 +801,9 @@ KML.Folder( KML.name("Absolute and Relative"), KML.visibility("0"), - KML.description("Four structures whose roofs meet exactly. Turn on/off - terrain to see the difference between relative and absolute - positioning."), + KML.description("Four structures whose roofs meet exactly. Turn on/off" + "terrain to see the difference between relative and absolute" + "positioning."), KML.LookAt( KML.longitude("-112.3348969157552"), KML.latitude("36.14845533214919"), @@ -823,11 +821,11 @@ KML.altitudeMode("absolute"), KML.outerBoundaryIs( KML.LinearRing( - KML.coordinates(" -112.3372510731295,36.14888505105317,1784 + KML.coordinates(""" -112.3372510731295,36.14888505105317,1784 -112.3356128688403,36.14781540589019,1784 -112.3368169371048,36.14658677734382,1784 -112.3384408457543,36.14762778914076,1784 - -112.3372510731295,36.14888505105317,1784 "), + -112.3372510731295,36.14888505105317,1784 """), ), ), ), @@ -842,11 +840,11 @@ KML.altitudeMode("absolute"), KML.outerBoundaryIs( KML.LinearRing( - KML.coordinates(" -112.3396586818843,36.14637618647505,1784 + KML.coordinates(""" -112.3396586818843,36.14637618647505,1784 -112.3380597654315,36.14531751871353,1784 -112.3368254237788,36.14659596244607,1784 -112.3384555043203,36.14762621763982,1784 - -112.3396586818843,36.14637618647505,1784 "), + -112.3396586818843,36.14637618647505,1784 """), ), ), ), @@ -868,7 +866,7 @@ KML.altitudeMode("relativeToGround"), KML.outerBoundaryIs( KML.LinearRing( - KML.coordinates(" -112.3349463145932,36.14988705767721,100 + KML.coordinates(""" -112.3349463145932,36.14988705767721,100 -112.3354019540677,36.14941108398372,100 -112.3344428289146,36.14878490381308,100 -112.3331289492913,36.14780840132443,100 @@ -876,7 +874,7 @@ -112.331131440106,36.1474173426228,100 -112.332616324338,36.14845453364654,100 -112.3339876620524,36.14926570522069,100 - -112.3349463145932,36.14988705767721,100 "), + -112.3349463145932,36.14988705767721,100 """), ), ), ), @@ -899,7 +897,7 @@ KML.altitudeMode("relativeToGround"), KML.outerBoundaryIs( KML.LinearRing( - KML.coordinates(" -112.3348783983763,36.1514008468736,100 + KML.coordinates(""" -112.3348783983763,36.1514008468736,100 -112.3372535345629,36.14888517553886,100 -112.3356068927954,36.14781612679284,100 -112.3350034807972,36.14846469024177,100 @@ -907,7 +905,7 @@ -112.3345888301373,36.15026229372507,100 -112.3337937856278,36.14978096026463,100 -112.3331798208424,36.1504472788618,100 - -112.3348783983763,36.1514008468736,100 "), + -112.3348783983763,36.1514008468736,100 """), ), ), ), From bb631d8a3c36f81437fe12a9456311250e07a60e Mon Sep 17 00:00:00 2001 From: Serge Barbosa <30304613+sbdt-google@users.noreply.github.com> Date: Fri, 3 May 2019 11:28:10 -0700 Subject: [PATCH 2/2] Update example_csv_to_kml.py --- src/examples/data_conversion/example_csv_to_kml.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/examples/data_conversion/example_csv_to_kml.py b/src/examples/data_conversion/example_csv_to_kml.py index e1bb67c..08dc436 100644 --- a/src/examples/data_conversion/example_csv_to_kml.py +++ b/src/examples/data_conversion/example_csv_to_kml.py @@ -48,7 +48,7 @@ def makeExtendedDataElements(datadict): KML.Style( KML.IconStyle( KML.color(color), - KML.scale(int(threshold/2)), + KML.scale(threshold/2.), KML.Icon( KML.href("http://maps.google.com/mapfiles/kml/shapes/earthquake.png"), ),