Maptiler 道路にborderを設定
Maptilerでデフォルトで用意されているMAPのスタイルでは道路にBorderがなくボヤっとしている

スタイルの編集画面で確認してもLineにBorderなどは設定できない
首都高速にはBorderが設定されているのでそのスタイルを確認する

首都高速は前景ライン「bridge-motorway」と背景ライン「bridge-motorway-casing」から構成されている。
「bridge-motorway-casing」は「bridge-motorway」より太く、濃い色が設定されている
bridge-motorway

bridge-motorway-casing

Borderの作成
highway-minorをコピー

コピーしたレイヤのIDを変更

レイヤの幅と色を設定

以上
Maptilerでmierune地図をカスタマイズ
最初にMaptilerにアカウントを作成。
今回はMaptiler Cloudの「FLEX」プランのアカウントを契約。
Maptilerのサイトを開き、ログインする。
ページ左の「MAPS」を選択

Local mapsのJP MIERUNE Streetsを選択

「EDIT A COPY」ボタンを押して編集開始

スタイル編集画面になる

家屋図を黄色にして「SAVE」→「CLOSE」

「PUBLISH」ボタンをクリック

再度「PUBLISH」ボタンをクリック

QGISで表示

QToolbarの色を設定
QWidget上にQToolbarを配置するとQToolbarが黒く表示されることがある

色を設定するにはQToolbarのsetStyleSheetを使用
toolbar = QToolBar(親のWidget)
toolbar.setStyleSheet(“background-color: rgb(240, 240, 240)”)

git tag を追加
タグを追加
[code]
git tag -a タグ名 -m "コメント"
[/code]
タグをリモートリポジトリに反映
[code]
git push origin –tag
[/code]
タグの一覧
[code]
git tag
[/code]
git commit時のメッセージをVisualCodeで入力
予めVisualCodeをインストール
C:\Users\ユーザー名\.gitconfigを開いて以下を追加
[code]
[core]
quotepath = off
editor = "code –wait"
[/code]
git 取り消し
直近のcommitを取り消し
[code]
git reset –soft HEAD^
[/code]
※softをhardにすると作業ディレクトリの内容もロールバックされる
指定したコミットまでに戻す
[code]
git reset –soft ハッシュ値
[/code]
ハッシュ値はgit logで確認
resetをリモートリポジトリに反映
[code]
git push -f origin master
[/code]
作業ディレクトリの内容をローカルリポジトリに戻す
[code]
git checkout .
[/code]
QgsFillSymbol の outline_width の デフォルト単位
QgsFillSymbolはポリゴンレイヤのシンボルとして使用する
QgsFillSymbolのインスタンスは通常QgsFillSymbolクラスのstaticな関数createSimpleで作成
[code]
kvs = {}
# 内部色
kvs[‘color’] = ‘0,0,0,0’
# 線色
kvs[‘outline_color’] = ‘255,0,0,255’
# 線幅
kvs[‘outline_width’] = ‘1’
# インスタンス作成
fillSymbol= QgsFillSymbol.createSimple(kvs)
[/code]
QgsFillSymbolのデフォルトの線幅の単位はミリメートルのためピクセル値で幅を設定するには単位をピクセルに設定する
[code]
kvs[‘outline_width_unit’] = ‘1’
[/code]
単位の定数
[code]
enum RenderUnit
{
RenderMillimeters = 0, //!< Millimeters
RenderMapUnits, //!< Map units
RenderPixels, //!< Pixels
RenderPercentage, //!< Percentage of another measurement (e.g., canvas size, feature size)
RenderPoints, //!< Points (e.g., for font sizes)
RenderInches, //!< Inches
RenderUnknownUnit, //!< Mixed or unknown units
RenderMetersInMapUnits, //!< Meters value as Map units
};
[/code]
ちなみにQGISではdpi=96なので25.4mm=96pix、よって1pixは0.26mm
※outline_widthのデフォルト値はqgis.hのDEFAULT_LINE_WIDTHであり0.26
git commit 関連
commitの一覧表示
[code]
git log
[/code]
直近のcommitの内容表示
[code]
git log -1
[/code]
直近のcommitの対象ファイル一覧
[code]
git log -1 –name-only
[/code]
直近のcommitの取り消し 編集したファイルは変更しない
[code]
git reset –soft HEAD~
[/code]
[code]
HEAD~とHEAD^は同じ
[/code]
直近のcommitの取り消し 編集したファイルも元に戻す
[code]
git reset –hard HEAD~
[/code]
QgsTextAnnotationをadd
QgsTextAnnotationはQgsAnnotationから派生された地図上の注釈クラス
QgsMapToolAnnotationクラスのC++ソースを参考にPythonでQgsTextAnnotationをMapCanvas上に追加する

間違ったコード
[code]
txt = QTextDocument(‘HELLO\r\nHELLO’)
annotation = QgsTextAnnotation()
annotation.setDocument(txt)
mapPos = QgsPointXY(138.9776,35.6712)
annotation.setMapPosition(mapPos)
annotation.setMapPositionCrs(iface.mapCanvas().mapSettings().destinationCrs())
annotation.setRelativePosition(QPointF(0, 0))
#annotation.setFrameSize(QSize(100, 50))
annotation.setFrameSize(txt.size())
annotationManager = QgsProject.instance().annotationManager()
annotationManager.addAnnotation(annotation)
[/code]
※setMapPositionには緯度、経度をセットしているが必要があればMapCanvasのDestinationCrsの座標系に変換が行う。
全てのAnnotationはQgsAnnotationManagerのannotationsに入っている
[code]
annotations= QgsProject.instance().annotationManager().annotations()
for annotation in annotations :
print(annotation.document().toPlainText())
[/code]
座標を指定してMapCanvas上のAnnotationを照会するにはMapCanvasのitemsを使用する
[code]
items = iface.mapCanvas().items(QPoint(10,10))
for item in items :
if item.__class__.__name__ == ‘QgsMapToolAnnotation’ :
print(item.document().toPlainText())
[/code]
ところがここでitemsにQgsMapToolAnnotationが存在しない。
全てがQGraphicsItemになっている
どうやらPythonでQgsAnnotationをMapCanvasに追加するには「annotationManager.addAnnotation」ではなく
「QgsMapCanvasAnnotationItem」を使うみたい
正しいコード
[code]
txt = QTextDocument(‘HELLO\r\nHELLO’)
annotation = QgsTextAnnotation()
annotation.setDocument(txt)
mapPos = QgsPointXY(138.9776,35.6712)
annotation.setMapPosition(mapPos)
annotation.setMapPositionCrs(iface.mapCanvas().mapSettings().destinationCrs())
#annotation.setRelativePosition(QPointF(0, 0))
annotation.setFrameOffsetFromReferencePoint(QtCore.QPointF(30, 30))
#annotation.setFrameSize(QSize(100, 50))
annotation.setFrameSize(txt.size())
i = QgsMapCanvasAnnotationItem(annotation, iface.mapCanvas())
[/code]
setRelativePositionではなく、setFrameOffsetFromReferencePointを使用して吹き出しの位置を設定
参考
