Skip to content

Update Josm_FranceSpecificRules.py for add syntax check ref:FR:NAF #2524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions plugins/Josm_FranceSpecificRules.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def init(self, logger):
self.errors[9019005] = self.def_class(item = 9019, level = 3, tags = mapcss.list_('ref', 'highway'), title = mapcss.tr('validation rules Fantoir in France'))
self.errors[9019006] = self.def_class(item = 9019, level = 3, tags = [], title = mapcss.tr('{0} is not a valid SIREN number', mapcss._tag_uncapture(capture_tags, '{0.tag}')))
self.errors[9019007] = self.def_class(item = 9019, level = 3, tags = [], title = mapcss.tr('{0} is not a valid SIRET number', mapcss._tag_uncapture(capture_tags, '{0.tag}')))
self.errors[9019008] = self.def_class(item = 9019, level = 3, tags = [], title = mapcss.tr('{0} is not a valid code NAF/APE value, mapcss._tag_uncapture(capture_tags, '{0.tag}')))

self.re_045a0f34 = re.compile(r'(?i)co.?voiturage')
self.re_107d2c86 = re.compile(r'PT[1-9]{1}[0-9]*')
Expand Down Expand Up @@ -384,6 +385,18 @@ def node(self, data, tags):
# throwWarning:tr("{0} is not a valid SIRET number","{0.tag}")
err.append({'class': 9019007, 'subclass': 0, 'text': mapcss.tr('{0} is not a valid SIRET number', mapcss._tag_uncapture(capture_tags, '{0.tag}'))})

# *["ref:FR:NAF"]["ref:FR:NAF"!~/^([0-9]{2}\.[0-9]{2}[A-Z];)*[0-9]{2}\.[0-9]{2}[A-Z]$/][inside("FR")]
if ('ref:FR:NAF' in keys):
match = False
if not match:
capture_tags = {}
try: match = ((mapcss._tag_capture(capture_tags, 0, tags, 'ref:FR:NAF')) and (not mapcss.regexp_test(mapcss._value_const_capture(capture_tags, 1, self.<-----------remplace------------>, '^([0-9]{2}\.[0-9]{2}[A-Z];)*[0-9]{2}\.[0-9]{2}[A-Z]$'), mapcss._tag_capture(capture_tags, 1, tags, 'ref:FR:NAF'))) and (mapcss.inside(self.father.config.options, 'FR')))
except mapcss.RuleAbort: pass
if match:
# -osmoseItemClassLevel:"9019/9019008/3"
# throwWarning:tr("{0} is not a valid code NAF/APE value","{0.tag}")
err.append({'class': 9019008, 'subclass': 0, 'text': mapcss.tr('{0} is not a valid code NAF/APE value', mapcss._tag_uncapture(capture_tags, '{0.tag}'))})

return err

def way(self, data, tags, nds):
Expand Down Expand Up @@ -827,6 +840,18 @@ def way(self, data, tags, nds):
# throwWarning:tr("{0} is not a valid SIRET number","{0.tag}")
err.append({'class': 9019007, 'subclass': 0, 'text': mapcss.tr('{0} is not a valid SIRET number', mapcss._tag_uncapture(capture_tags, '{0.tag}'))})

# *["ref:FR:NAF"]["ref:FR:NAF"!~/^([0-9]{2}\.[0-9]{2}[A-Z];)*[0-9]{2}\.[0-9]{2}[A-Z]$/][inside("FR")]
if ('ref:FR:NAF' in keys):
match = False
if not match:
capture_tags = {}
try: match = ((mapcss._tag_capture(capture_tags, 0, tags, 'ref:FR:NAF')) and (not mapcss.regexp_test(mapcss._value_const_capture(capture_tags, 1, self.<-----------remplace------------>, '^([0-9]{2}\.[0-9]{2}[A-Z];)*[0-9]{2}\.[0-9]{2}[A-Z]$'), mapcss._tag_capture(capture_tags, 1, tags, 'ref:FR:NAF'))) and (mapcss.inside(self.father.config.options, 'FR')))
except mapcss.RuleAbort: pass
if match:
# -osmoseItemClassLevel:"9019/9019008/3"
# throwWarning:tr("{0} is not a valid code NAF/APE value","{0.tag}")
err.append({'class': 9019008, 'subclass': 0, 'text': mapcss.tr('{0} is not a valid code NAF/APE value', mapcss._tag_uncapture(capture_tags, '{0.tag}'))})

return err

def relation(self, data, tags, members):
Expand Down Expand Up @@ -1092,6 +1117,18 @@ def relation(self, data, tags, members):
# throwWarning:tr("{0} is not a valid SIRET number","{0.tag}")
err.append({'class': 9019007, 'subclass': 0, 'text': mapcss.tr('{0} is not a valid SIRET number', mapcss._tag_uncapture(capture_tags, '{0.tag}'))})

# *["ref:FR:NAF"]["ref:FR:NAF"!~/^([0-9]{2}\.[0-9]{2}[A-Z];)*[0-9]{2}\.[0-9]{2}[A-Z]$/][inside("FR")]
if ('ref:FR:NAF' in keys):
match = False
if not match:
capture_tags = {}
try: match = ((mapcss._tag_capture(capture_tags, 0, tags, 'ref:FR:NAF')) and (not mapcss.regexp_test(mapcss._value_const_capture(capture_tags, 1, self.<-----------remplace------------>, '^([0-9]{2}\.[0-9]{2}[A-Z];)*[0-9]{2}\.[0-9]{2}[A-Z]$'), mapcss._tag_capture(capture_tags, 1, tags, 'ref:FR:NAF'))) and (mapcss.inside(self.father.config.options, 'FR')))
except mapcss.RuleAbort: pass
if match:
# -osmoseItemClassLevel:"9019/9019008/3"
# throwWarning:tr("{0} is not a valid code NAF/APE value","{0.tag}")
err.append({'class': 9019008, 'subclass': 0, 'text': mapcss.tr('{0} is not a valid code NAF/APE value', mapcss._tag_uncapture(capture_tags, '{0.tag}'))})

return err


Expand Down