diff options
Diffstat (limited to 'doc/import')
-rw-r--r-- | doc/import/ParserPotagers.rb | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/doc/import/ParserPotagers.rb b/doc/import/ParserPotagers.rb index 91f9300..0585b9e 100644 --- a/doc/import/ParserPotagers.rb +++ b/doc/import/ParserPotagers.rb @@ -10,7 +10,7 @@ class Parser @list_of_locations["features"] = [] end - def fuse_two_entries(entry_1, entry_2) + def fuse_two_entries(entry_1, entry_2) #Outputs a string that contains the value of the two entries, or only one if they repeat if entry_1 and entry_2 if entry_1 != entry_2 return entry_1 + " ou " + entry_2 @@ -26,7 +26,7 @@ class Parser end end - def reverse_endianness(string) + def reverse_endianness(string) #Reverse endianness of the received string, by chunk of two hexadecimal characters res = "" while string.length > 0 res += string[-2..-1] @@ -35,16 +35,16 @@ class Parser return res end - def cut_from_wkb(string) + def cut_from_wkb(string) #Removes data that stumped the Rgeo library res = string[0..6] + string[15..-1] return res end def reverse_polygon_endianness(string) res = "" - endian = string[0..1] + endian = string[0..1] #Reverse the endianness of the metadata of the polygon string = string[2..-1] - if endian == "01" #Reverse 4 bytes 3 times, then check 1 byte, then reverse 4 bytes 3 times, then reverse 8 bytes until the end of the string + if endian == "01" res += "00" for i in 0..3 res += reverse_endianness(string[0..7]) @@ -52,17 +52,17 @@ class Parser end end - while string != nil and string.length > 0 + while string != nil and string.length > 0 #Reverse Endianness of the coordinates of each point res += reverse_endianness(string[0..15]) string = string[16..-1] end - res = res[0..9] + res[18..-1] + res = res[0..9] + res[18..-1] #Removes data that stumped the RGeo library res[2] = "0" return res end def reverse_multipolygon_endianness(string) - res = "" + res = ""#Reverse the endianness of the metadata of the multipolygon res += "00" string = string[2..-1] for i in 0..2 @@ -79,7 +79,7 @@ class Parser res += reverse_endianness(string[0..7]) #Number_of_polygons stored here string = string[8..-1] - for i in 0..number_of_polygons-1 + for i in 0..number_of_polygons-1 #Reverse Endianness of the coordinates of each point number_of_duo_of_values = string[0..1].to_i(16) res += reverse_endianness(string[0..7]) #Number_of_duo_of_values stored here string = string[8..-1] @@ -90,12 +90,12 @@ class Parser string = string[16..-1] end end - res = res[0..9] + res[18..-1] + res = res[0..9] + res[18..-1] #Removes data that stumped the RGeo library res[2] = "0" return res end - def reverse_wkb_endianness(string) + def reverse_wkb_endianness(string) #Check if an element is a polygon or a multipolygon (might need different shapes in the future, like a point or a line if string[3] == "6" res = reverse_multipolygon_endianness(string) elsif string[3] == "3" @@ -133,7 +133,7 @@ class Parser new_item["properties"]["mail"] = fuse_two_entries(data[i]["email"], data[i]["email_2"]) #There is two fields for address, "rue_num" and "rue", sometimes a field is empty, so a string is constructed with nil as a parameter, to create "" and add to the address string new_item["properties"]["address"] = String(data[i]["rue"]) + " " + String(data[i]["rue_num"]) - new_item["properties"]["city"] = data[i]["n_commune"] #Or should it always be "brussels" + new_item["properties"]["city"] = data[i]["n_commune"] new_item["properties"]["postal_code"] = "" #No equivalent in potagers database new_item["properties"]["categories"] = [43] new_item["properties"]["source"] = data[i]["source"] |