Skip to content

Instantly share code, notes, and snippets.

@tohka
tohka / numdot
Last active December 23, 2015 19:39
#!/usr/local/bin/ruby
# CodeIQ のナムドット問題
# https://codeiq.jp/ace/yuki_hiroshi/q468
# 12345 => 00000
# 1234.5 => 00001
# 1235.4 => 00010
@tohka
tohka / index.html
Last active November 4, 2016 07:48
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title></title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.26.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.26.0/mapbox-gl.css' rel='stylesheet' />
<link href='https://www.mapbox.com/base/latest/base.css' rel='stylesheet' />
<style>
def transformLayer(layer = None, crs = None, addToCanvas = False):
"""
QGIS 3.x で、参照系を変換した一時レイヤを作成する。
Parameters
----------
layer : None, str or QgsVectorLayer, default None
変換もとのレイヤ。 None だとアクティブレイヤが選択される。
文字列を指定すると、レイヤ名あるいはソース名で検索し
最初にみつかったレイヤが選択される。
<?php
$x = (string)filter_input(INPUT_GET, 'x');
$y = (string)filter_input(INPUT_GET, 'y');
$z = (string)filter_input(INPUT_GET, 'z');
$text = '';
$pattern = '/^\d+$/';
if(preg_match($pattern, $x) > 0 && preg_match($pattern, $y) > 0 &&
preg_match($pattern, $z) > 0){
$text = $z . '/' . $x . '/' . $y;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/usr/bin/ruby
def read_data(io, type, bo, label = '')
data = nil
bytes = nil
value = nil
if type == :int
data = io.read(4)
@tohka
tohka / getFeatureAttribute.py
Last active February 2, 2020 13:22
getFeatureAttribute
from qgis.core import *
from qgis.gui import *
"""
使い方:
getFeatureAttribute(対象レイヤID, 空間関係, 取得したい属性名)
例:
getFeatureAttribute('ポリゴンレイヤ_7dff1692_ba18_4bd1_bf46_63785338b050' , 'intersects', 'name')
@tohka
tohka / layer_spec.json
Last active May 13, 2020 04:49
基盤地図情報の PackDLMap.zip を全ファイル展開し、種別ごとにマージするやつ
{
"common_fields" : [
["gml_id", "String"],
["fid", "String"],
["lfSpanFr", "Date"],
["lfSpanTo", "Date"],
["devDate", "Date"],
["orgGILvl", "String"],
["orgMDId", "String"],
["vis", "String"]
#!/usr/bin/ruby
class NumberPlace
def initialize(ary=nil)
init(ary)
end
def init(ary=nil)
@cells = Array.new(81) do
[1, 2, 3, 4, 5, 6, 7, 8, 9]
@tohka
tohka / zukaku.rb
Created June 24, 2020 15:51
図郭コードから座標値を取得する
# 図郭コードから [xmin, ymin, xmax, ymax] を求める
# 図郭コードは平面直角座標系の系を除外したコードとする
# 例) 09LD352 → LD352
def zukaku(code, output_wkt=false)
level = nil
if code =~ /^[A-T][A-H]$/
level = 50000
elsif code =~ /^[A-T][A-H]\d\d$/
level = 5000
elsif code =~ /^[A-T][A-H]\d\d[1-4]$/