Remove legacy geo sources
This commit is contained in:
parent
5abb07420b
commit
cad8ee31d8
10 changed files with 10 additions and 81 deletions
|
@ -51,7 +51,6 @@ class Api::V2::Schema < GraphQL::Schema
|
||||||
Types::Champs::SiretChampType,
|
Types::Champs::SiretChampType,
|
||||||
Types::Champs::TextChampType,
|
Types::Champs::TextChampType,
|
||||||
Types::GeoAreas::ParcelleCadastraleType,
|
Types::GeoAreas::ParcelleCadastraleType,
|
||||||
Types::GeoAreas::QuartierPrioritaireType,
|
|
||||||
Types::GeoAreas::SelectionUtilisateurType,
|
Types::GeoAreas::SelectionUtilisateurType,
|
||||||
Types::PersonneMoraleType,
|
Types::PersonneMoraleType,
|
||||||
Types::PersonnePhysiqueType
|
Types::PersonnePhysiqueType
|
||||||
|
|
|
@ -809,11 +809,6 @@ enum GeoAreaSource {
|
||||||
"""
|
"""
|
||||||
cadastre
|
cadastre
|
||||||
|
|
||||||
"""
|
|
||||||
Quartier prioritaire
|
|
||||||
"""
|
|
||||||
quartier_prioritaire
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Sélection utilisateur
|
Sélection utilisateur
|
||||||
"""
|
"""
|
||||||
|
@ -1101,15 +1096,6 @@ type Profile {
|
||||||
id: ID!
|
id: ID!
|
||||||
}
|
}
|
||||||
|
|
||||||
type QuartierPrioritaire implements GeoArea {
|
|
||||||
code: String!
|
|
||||||
commune: String!
|
|
||||||
geometry: GeoJSON!
|
|
||||||
id: ID!
|
|
||||||
nom: String!
|
|
||||||
source: GeoAreaSource!
|
|
||||||
}
|
|
||||||
|
|
||||||
type Query {
|
type Query {
|
||||||
"""
|
"""
|
||||||
Informations concernant une démarche.
|
Informations concernant une démarche.
|
||||||
|
|
|
@ -4,13 +4,11 @@ module Types
|
||||||
|
|
||||||
class GeoAreaSource < Types::BaseEnum
|
class GeoAreaSource < Types::BaseEnum
|
||||||
GeoArea.sources.each do |symbol_name, string_name|
|
GeoArea.sources.each do |symbol_name, string_name|
|
||||||
if string_name != "parcelle_agricole"
|
|
||||||
value(string_name,
|
value(string_name,
|
||||||
I18n.t(symbol_name, scope: [:activerecord, :attributes, :geo_area, :source]),
|
I18n.t(symbol_name, scope: [:activerecord, :attributes, :geo_area, :source]),
|
||||||
value: symbol_name)
|
value: symbol_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
global_id_field :id
|
global_id_field :id
|
||||||
field :source, GeoAreaSource, null: false
|
field :source, GeoAreaSource, null: false
|
||||||
|
@ -21,8 +19,6 @@ module Types
|
||||||
case object.source
|
case object.source
|
||||||
when GeoArea.sources.fetch(:cadastre)
|
when GeoArea.sources.fetch(:cadastre)
|
||||||
Types::GeoAreas::ParcelleCadastraleType
|
Types::GeoAreas::ParcelleCadastraleType
|
||||||
when GeoArea.sources.fetch(:quartier_prioritaire)
|
|
||||||
Types::GeoAreas::QuartierPrioritaireType
|
|
||||||
when GeoArea.sources.fetch(:selection_utilisateur)
|
when GeoArea.sources.fetch(:selection_utilisateur)
|
||||||
Types::GeoAreas::SelectionUtilisateurType
|
Types::GeoAreas::SelectionUtilisateurType
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
module Types::GeoAreas
|
|
||||||
class QuartierPrioritaireType < Types::BaseObject
|
|
||||||
implements Types::GeoAreaType
|
|
||||||
|
|
||||||
field :code, String, null: false
|
|
||||||
field :nom, String, null: false
|
|
||||||
field :commune, String, null: false
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -39,10 +39,6 @@ module ChampHelper
|
||||||
concat "Parcelle n° #{geo_area.numero} - Feuille #{geo_area.code_arr} #{geo_area.section} #{geo_area.feuille} - #{geo_area.surface_parcelle.round} m"
|
concat "Parcelle n° #{geo_area.numero} - Feuille #{geo_area.code_arr} #{geo_area.section} #{geo_area.feuille} - #{geo_area.surface_parcelle.round} m"
|
||||||
concat tag.sup("2")
|
concat tag.sup("2")
|
||||||
end
|
end
|
||||||
when GeoArea.sources.fetch(:quartier_prioritaire)
|
|
||||||
"#{geo_area.commune} : #{geo_area.nom}"
|
|
||||||
when GeoArea.sources.fetch(:parcelle_agricole)
|
|
||||||
"Culture : #{geo_area.culture} - Surface : #{geo_area.surface} ha"
|
|
||||||
when GeoArea.sources.fetch(:selection_utilisateur)
|
when GeoArea.sources.fetch(:selection_utilisateur)
|
||||||
if geo_area.polygon?
|
if geo_area.polygon?
|
||||||
if geo_area.area.present?
|
if geo_area.area.present?
|
||||||
|
|
|
@ -27,34 +27,18 @@ class Champs::CarteChamp < Champ
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def quartiers_prioritaires
|
|
||||||
geo_areas.filter do |area|
|
|
||||||
area.source == GeoArea.sources.fetch(:quartier_prioritaire)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def parcelles_agricoles
|
|
||||||
geo_areas.filter do |area|
|
|
||||||
area.source == GeoArea.sources.fetch(:parcelle_agricole)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def selections_utilisateur
|
def selections_utilisateur
|
||||||
geo_areas.filter do |area|
|
geo_areas.filter do |area|
|
||||||
area.source == GeoArea.sources.fetch(:selection_utilisateur)
|
area.source == GeoArea.sources.fetch(:selection_utilisateur)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def layer_enabled?(layer)
|
||||||
|
type_de_champ.options[layer] && type_de_champ.options[layer] != '0'
|
||||||
|
end
|
||||||
|
|
||||||
def cadastres?
|
def cadastres?
|
||||||
type_de_champ&.cadastres && type_de_champ.cadastres != '0'
|
layer_enabled?(:cadastres)
|
||||||
end
|
|
||||||
|
|
||||||
def quartiers_prioritaires?
|
|
||||||
type_de_champ&.quartiers_prioritaires && type_de_champ.quartiers_prioritaires != '0'
|
|
||||||
end
|
|
||||||
|
|
||||||
def parcelles_agricoles?
|
|
||||||
type_de_champ&.parcelles_agricoles && type_de_champ.parcelles_agricoles != '0'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def mnhn?
|
def mnhn?
|
||||||
|
|
|
@ -35,16 +35,12 @@ class GeoArea < ApplicationRecord
|
||||||
]
|
]
|
||||||
|
|
||||||
enum source: {
|
enum source: {
|
||||||
quartier_prioritaire: 'quartier_prioritaire',
|
|
||||||
cadastre: 'cadastre',
|
cadastre: 'cadastre',
|
||||||
parcelle_agricole: 'parcelle_agricole',
|
|
||||||
selection_utilisateur: 'selection_utilisateur'
|
selection_utilisateur: 'selection_utilisateur'
|
||||||
}
|
}
|
||||||
|
|
||||||
scope :selections_utilisateur, -> { where(source: sources.fetch(:selection_utilisateur)) }
|
scope :selections_utilisateur, -> { where(source: sources.fetch(:selection_utilisateur)) }
|
||||||
scope :quartiers_prioritaires, -> { where(source: sources.fetch(:quartier_prioritaire)) }
|
|
||||||
scope :cadastres, -> { where(source: sources.fetch(:cadastre)) }
|
scope :cadastres, -> { where(source: sources.fetch(:cadastre)) }
|
||||||
scope :parcelles_agricoles, -> { where(source: sources.fetch(:parcelle_agricole)) }
|
|
||||||
|
|
||||||
def to_feature
|
def to_feature
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,7 +56,7 @@ class TypeDeChamp < ApplicationRecord
|
||||||
belongs_to :parent, class_name: 'TypeDeChamp', optional: true
|
belongs_to :parent, class_name: 'TypeDeChamp', optional: true
|
||||||
has_many :types_de_champ, -> { ordered }, foreign_key: :parent_id, class_name: 'TypeDeChamp', inverse_of: :parent, dependent: :destroy
|
has_many :types_de_champ, -> { ordered }, foreign_key: :parent_id, class_name: 'TypeDeChamp', inverse_of: :parent, dependent: :destroy
|
||||||
|
|
||||||
store_accessor :options, :cadastres, :quartiers_prioritaires, :parcelles_agricoles, :mnhn, :old_pj, :drop_down_options, :skip_pj_validation
|
store_accessor :options, :cadastres, :mnhn, :old_pj, :drop_down_options, :skip_pj_validation
|
||||||
has_many :revision_types_de_champ, class_name: 'ProcedureRevisionTypeDeChamp', dependent: :destroy, inverse_of: :type_de_champ
|
has_many :revision_types_de_champ, class_name: 'ProcedureRevisionTypeDeChamp', dependent: :destroy, inverse_of: :type_de_champ
|
||||||
has_many :revisions, through: :revision_types_de_champ
|
has_many :revisions, through: :revision_types_de_champ
|
||||||
|
|
||||||
|
|
|
@ -11,15 +11,6 @@ class GeoAreaSerializer < ActiveModel::Serializer
|
||||||
attribute :code_com, if: :include_cadastre?
|
attribute :code_com, if: :include_cadastre?
|
||||||
attribute :code_arr, if: :include_cadastre?
|
attribute :code_arr, if: :include_cadastre?
|
||||||
|
|
||||||
attribute :code, if: :include_quartier_prioritaire?
|
|
||||||
attribute :nom, if: :include_quartier_prioritaire?
|
|
||||||
attribute :commune, if: :include_quartier_prioritaire?
|
|
||||||
|
|
||||||
attribute :culture, if: :include_parcelle_agricole?
|
|
||||||
attribute :code_culture, if: :include_parcelle_agricole?
|
|
||||||
attribute :surface, if: :include_parcelle_agricole?
|
|
||||||
attribute :bio, if: :include_parcelle_agricole?
|
|
||||||
|
|
||||||
def geometry
|
def geometry
|
||||||
object.safe_geometry
|
object.safe_geometry
|
||||||
end
|
end
|
||||||
|
@ -27,12 +18,4 @@ class GeoAreaSerializer < ActiveModel::Serializer
|
||||||
def include_cadastre?
|
def include_cadastre?
|
||||||
object.source == GeoArea.sources.fetch(:cadastre)
|
object.source == GeoArea.sources.fetch(:cadastre)
|
||||||
end
|
end
|
||||||
|
|
||||||
def include_quartier_prioritaire?
|
|
||||||
object.source == GeoArea.sources.fetch(:quartier_prioritaire)
|
|
||||||
end
|
|
||||||
|
|
||||||
def include_parcelle_agricole?
|
|
||||||
object.source == GeoArea.sources.fetch(:parcelle_agricole)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
class ModuleApiCartoSerializer < ActiveModel::Serializer
|
class ModuleApiCartoSerializer < ActiveModel::Serializer
|
||||||
attributes :use_api_carto,
|
attributes :use_api_carto, :cadastre
|
||||||
:quartiers_prioritaires,
|
|
||||||
:cadastre
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue