LoginSignup
0
0

More than 5 years have passed since last update.

chi-bus.jpその後

Last updated at Posted at 2016-06-24
1 / 13

simplify-js


simplify-jsとは

いい感じに経度緯度配列を削減

デモ:
http://mourner.github.io/simplify-js/
GitHub:
https://github.com/mourner/simplify-js
Ruby移植:
https://github.com/odlp/simplify_rb


その他の移植

  • Python: omarestrella / simplify.py (by Omar Estrella)
  • PHP: AKeN / simplify-php (by Rotari Gheorghe)
  • PHP: andreychumak / simplify-php (by Andrey Chumak)
  • Java: ekeneijeoma / simplify-java (by Ekene Ijeoma)
  • Java: hgoebl / simplify-java (by Heinrich Göbl)
  • Processing: ekeneijeoma / simplify-processing (by Ekene Ijeoma)
  • AS3: fnicollet / simplify-as3 (by Fabien Nicollet)
  • Rust: calvinmetcalf / simplify-rs (by Calvin Metcalf)
  • Ruby: odlp / simplify_rb (by Oliver Peate)
  • Go: yrsh / simplify_go (by Anton Korotkikh)
  • C# (Portable): imshz / simplify-net (by Shees Ul-Hassan)
  • Swift: malcommac / SwiftSimplify (by Daniele Margutti)

元のコード

tracks: bus_route.bus_route_tracks.map do |track|
  track.coordinates.map.with_index do |coordinate, index|
    next if index != 0
      && index != track.coordinates.length - 1
      && index % bus_routes.length != 0
    { lat: coordinate[0], lng: coordinate[1] }
  end.compact
end

改善その1

tracks: bus_route.bus_route_tracks.map do |track|
  coordinates = track.coordinates.map { |coordinate| { x: coordinate[0], y: coordinate[1] } }
  SimplifyRb.simplify(coordinates, 0.0001).map do |coordinate|
    { lat: coordinate[:x], lng: coordinate[:y] }
  end.compact
end

改善その2

doc.css('Curve').each do |node|
  gml_id = node['id']
  coordinates = node.at('posList').text.strip.each_line.map { |line| { x: line.split[0].to_f, y: line.split[1].to_f } }
  simplified_coordinates = SimplifyRb.simplify(coordinates, 0.0001).map { |c| [c[:x], c[:y]] }
  bus_route_track = BusRouteTrack.create(gml_id: "#{xml_path}/#{gml_id}", coordinates: simplified_coordinates)
  bus_route_track_progress.increment
end

ベンチマーク

ApatchBenchがSNIに非対応のため測定してないため、以下はざっくり

美しさ: 圧倒的
応答速度: +50ms(JSON処理、削減ロジック)
通信量: たぶん1/30くらい(今まではバスルート数に比例して削減→simplify.jsは1本から適用)


WOVN.jp


WOVN.jpとは

たった1行のコードで、
あなたのウェブサイトをグローバルに。

デモ:
https://www.chi-bus.jp/

ちなみに「ウォーブン」と発音


埋め込みコード

<script src="//j.wovn.io/1" data-wovnio="key=xxxxx" async></script>

すごいところ

  • ほんとに1行
  • 対応ページの追加が簡単
  • 翻訳支援+自由な編集
  • 多言語対応
  • ライブ編集モード

作った人

  • ミニマル・テクノロジーズ
  • CEOは林鷹治氏
  • もともと林氏は、Stores.jpを運営するブラケットでグロースハッカー
  • ブラウザ上でA/Bテストが簡単にできるOptimizelyのサービスを使っていた
  • 独立系VCのIncubate Fundから450万円のシード投資
  • その後リクルートなどが出資
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0