lib/aipp/regions/LF/helpers/common.rb in aipp-0.2.2 vs lib/aipp/regions/LF/helpers/common.rb in aipp-0.2.3
- old
+ new
@@ -13,14 +13,14 @@
'franco-suisse' => 'FRANCE_SWITZERLAND',
'franco-luxembourgeoise' => 'FRANCE_LUXEMBOURG',
'franco-belge' => 'BELGIUM_FRANCE',
'germano-suisse' => 'GERMANY_SWITZERLAND',
'hispano-andorrane' => 'ANDORRA_SPAIN',
- 'la côte atlantique française' => 'FRANCE_ATLANTIC_COAST', # TODO: handle internally
- 'côte méditérrannéenne' => 'FRANCE_MEDITERRANEAN_COAST', # TODO: handle internally
- 'limite des eaux territoriales atlantique françaises' => 'FRANCE_ATLANTIC_TERRITORIAL_SEA', # TODO: handle internally
- 'parc national des écrins' => 'FRANCE_ECRINS_NATIONAL_PARK' # TODO: handle internally
+ 'la côte atlantique française' => 'FRANCE_ATLANTIC_COAST',
+ 'côte méditérrannéenne' => 'FRANCE_MEDITERRANEAN_COAST',
+ 'limite des eaux territoriales atlantique françaises' => 'FRANCE_ATLANTIC_TERRITORIAL_SEA',
+ 'parc national des écrins' => 'FRANCE_ECRINS_NATIONAL_PARK'
}.freeze
# Intersection points between three countries
INTERSECTIONS = {
'FRANCE_SPAIN|ANDORRA_SPAIN' => AIXM.xy(lat: 42.502720, long: 1.725965),
@@ -125,16 +125,15 @@
end
end
def layer_from(text_for_limits, text_for_class=nil)
above, below = text_for_limits.gsub(/ /, '').split(/\n+/).select(&:blank_to_nil).split { |e| e.match? '---+' }
- above.reverse!
AIXM.layer(
class: text_for_class,
vertical_limits: AIXM.vertical_limits(
- max_z: z_from(above[1]),
upper_z: z_from(above[0]),
+ max_z: z_from(above[1]),
lower_z: z_from(below[0]),
min_z: z_from(below[1])
)
)
end
@@ -156,29 +155,40 @@
radius: AIXM.d($1.to_f, $2)
)
when /end|(\S+) , (\S+)/
geometry << AIXM.point(xy: buffer[:xy]) if buffer.has_key?(:xy)
buffer[:xy] = AIXM.xy(lat: $1, long: $2) if $1
+ if border = buffer.delete(:border)
+ from = border.nearest(xy: geometry.segments.last.xy)
+ to = border.nearest(xy: buffer[:xy], geometry_index: from.geometry_index)
+ geometry.concat border.segment(from_position: from, to_position: to).map(&:to_point)
+ end
when /^frontière ([\w-]+)/i, /^(\D[^(]+)/i
border_name = BORDERS.fetch($1.downcase.strip)
- buffer[:xy] ||= INTERSECTIONS.fetch("#{buffer[:border_name]}|#{border_name}")
- buffer[:border_name] = border_name
- if border_name == 'FRANCE_SPAIN' # specify which part of this split border
- border_name += buffer[:xy].lat < 42.55 ? '_EAST' : '_WEST'
+ if borders.has_key? border_name # border from GeoJSON
+ buffer[:border] = borders[border_name]
+ else # named border
+ buffer[:xy] ||= INTERSECTIONS.fetch("#{buffer[:border_name]}|#{border_name}")
+ buffer[:border_name] = border_name
+ if border_name == 'FRANCE_SPAIN' # specify which part of this split border
+ border_name += buffer[:xy].lat < 42.55 ? '_EAST' : '_WEST'
+ end
+ geometry << AIXM.border(
+ xy: buffer.delete(:xy),
+ name: border_name
+ )
end
- geometry << AIXM.border(
- xy: buffer.delete(:xy),
- name: border_name
- )
else
fail "geometry `#{element}' not recognized"
end
end
end
end
- def timetable_from(text)
- AIXM::H24 if text.gsub(/\W/, '') == 'H24'
+ def timetable_from!(text)
+ if text.gsub!(/^\s*#{AIXM::H_RE}\s*$/, '')
+ AIXM.timetable(code: Regexp.last_match&.to_s&.strip)
+ end
end
end
end
end