Skip to content

Commit

Permalink
Merge pull request #6 from MIERUNE/fix/qgsfield-type
Browse files Browse the repository at this point in the history
QgsFIeldに適切な type を与える
  • Loading branch information
ciscorn authored Mar 17, 2023
2 parents f7729bf + cbb27dd commit 4a92131
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions mojxml_plugin/algorithm.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pathlib import Path

from PyQt5.QtCore import QVariant
from qgis.core import QgsProcessingException # pyright: ignore
from qgis.core import (
QgsCoordinateReferenceSystem,
Expand All @@ -22,6 +23,12 @@
from .mojxml.process.executor import ThreadPoolExecutor
from .mojxml.schema import OGR_SCHEMA

_OGR_QT_TYPE_MAP = {
"str": QVariant.String,
"int": QVariant.Int,
"float": QVariant.Double,
}


class MOJXMLProcessingAlrogithm(QgsProcessingAlgorithm):
INPUT = "INPUT"
Expand Down Expand Up @@ -86,8 +93,8 @@ def processAlgorithm(self, parameters, context, feedback):
)

fields = QgsFields()
for name, type in OGR_SCHEMA["properties"].items():
fields.append(QgsField(name, typeName=type))
for name, ogr_type in OGR_SCHEMA["properties"].items():
fields.append(QgsField(name, type=_OGR_QT_TYPE_MAP[ogr_type]))

include_chikugai = self.parameterAsBoolean(parameters, self.CHIKUGAI, context)
include_arbitrary = self.parameterAsBoolean(parameters, self.ARBITRARY, context)
Expand Down

0 comments on commit 4a92131

Please sign in to comment.