module NSWTopo::Control

def get_features

def get_features
  scaled_params = SCALING_PARAMS.gsub(/\-?\d\.\d+/) { |number| "%.5g" % (number.to_f * 0.5 * @diameter) }
  scaled_params = YAML.load scaled_params
  scaled_params["control"]["symbol"] << { "circle" => { "r" => 0.07, "stroke-width" => 0.14, "fill" => "none" } } if @spot
  @params = scaled_params.deep_merge @params
  @params["labels"]["font-size"] = @font_size if @font_size
  @params["labels"]["fill"] = @params["stroke"] = @colour.to_s if @colour
  points, controls = GPS.load(@path).points, GeoJSON::Collection.new
  [["control",   /^(1?\d\d)W?$/ ],
   ["hashhouse", /^(HH)$/       ],
   ["anc",       /^(ANC)$/      ],
   ["waterdrop", /^1?\d\dW$|^W$/],
  ].each do |type, selector|
    points.each do |point|
      name = point["name"]
      next unless name =~ selector
      properties = [["category", [type, *$1]], ["label", $1]].select(&:last).to_h
      controls.add_point point.coordinates, properties
    end
  end
  controls
end

def to_s

def to_s
  counts = %w[control waterdrop hashhouse].filter_map do |category|
    waypoints = features.select do |feature|
      feature["category"].any? category
    end
    next if waypoints.empty?
    count = "%i %s%s" % [waypoints.length, category, waypoints.one? ? nil : ?s]
    next count unless "control" == category
    total = features.sum { |feature| feature["label"].to_i.floor(-1) }
    count << " (%i points)" % total
  end
  [@name, counts.join(", ")].join(": ")
end