mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-02 13:27:32 +08:00
[maps] extracting google maps version
It should not fail in case of lost connection or corrupted maps.xml file Fix #187
This commit is contained in:
+1
-1
@@ -16,7 +16,7 @@ $(DATADIR)/maps.google.com: $(DATADIR) FORCE
|
||||
$(PAPARAZZI_HOME)/conf/maps.xml: $(DATADIR)/maps.google.com
|
||||
$(Q)echo "<!DOCTYPE maps SYSTEM \"maps.dtd\">" > $(@)
|
||||
$(Q)echo "" >> $(@)
|
||||
$(Q)echo "<maps google_version=\""`grep -P "http://khm[0-9]+.google.com/kh/v=[0-9]+.x26" $(DATADIR)/maps.google.com | sed -E s#.*http://khm[0-9]+.google.com/kh/v=## | sed -E s#.x26.*##`"\"/>" >> $(@)
|
||||
$(Q)echo "<maps google_version=\""`grep -P "http://khm[0-9]+.google.com/kh/v=[0-9]+.x26" $(DATADIR)/maps.google.com | sed -E 's#.*http://khm[0-9]+.google.com/kh/v=##;s#.x26.*##'`"\"/>" >> $(@)
|
||||
$(Q)echo "" >> $(@)
|
||||
|
||||
FORCE:
|
||||
|
||||
@@ -23,16 +23,14 @@
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*)
|
||||
let google_ver = ref 0
|
||||
|
||||
let home = Env.paparazzi_home
|
||||
let (//) = Filename.concat
|
||||
let maps_xml_path = home // "conf" // "maps.xml"
|
||||
|
||||
let maps_xml = ExtXml.parse_file maps_xml_path
|
||||
let maps_xml_default = ExtXml.parse_file (maps_xml_path^".example")
|
||||
let gv = try Some (ExtXml.int_attrib maps_xml "google_version") with _ -> None
|
||||
let gv_default = try ExtXml.int_attrib maps_xml_default "google_version" with _ -> 0
|
||||
|
||||
let google_version = match gv with Some v -> v | None -> gv_default
|
||||
|
||||
let google_version = (
|
||||
if !google_ver == 0 then (
|
||||
google_ver := ExtXml.int_attrib maps_xml "google_version" );
|
||||
!google_ver
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user