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::TextChampType,
|
||||
Types::GeoAreas::ParcelleCadastraleType,
|
||||
Types::GeoAreas::QuartierPrioritaireType,
|
||||
Types::GeoAreas::SelectionUtilisateurType,
|
||||
Types::PersonneMoraleType,
|
||||
Types::PersonnePhysiqueType
|
||||
|
|
|
@ -809,11 +809,6 @@ enum GeoAreaSource {
|
|||
"""
|
||||
cadastre
|
||||
|
||||
"""
|
||||
Quartier prioritaire
|
||||
"""
|
||||
quartier_prioritaire
|
||||
|
||||
"""
|
||||
Sélection utilisateur
|
||||
"""
|
||||
|
@ -1101,15 +1096,6 @@ type Profile {
|
|||
id: ID!
|
||||
}
|
||||
|
||||
type QuartierPrioritaire implements GeoArea {
|
||||
code: String!
|
||||
commune: String!
|
||||
geometry: GeoJSON!
|
||||
id: ID!
|
||||
nom: String!
|
||||
source: GeoAreaSource!
|
||||
}
|
||||
|
||||
type Query {
|
||||
"""
|
||||
Informations concernant une démarche.
|
||||
|
|
|
@ -4,13 +4,11 @@ module Types
|
|||
|
||||
class GeoAreaSource < Types::BaseEnum
|
||||
GeoArea.sources.each do |symbol_name, string_name|
|
||||
if string_name != "parcelle_agricole"
|
||||
value(string_name,
|
||||
I18n.t(symbol_name, scope: [:activerecord, :attributes, :geo_area, :source]),
|
||||
value: symbol_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
global_id_field :id
|
||||
field :source, GeoAreaSource, null: false
|
||||
|
@ -21,8 +19,6 @@ module Types
|
|||
case object.source
|
||||
when GeoArea.sources.fetch(:cadastre)
|
||||
Types::GeoAreas::ParcelleCadastraleType
|
||||
when GeoArea.sources.fetch(:quartier_prioritaire)
|
||||
Types::GeoAreas::QuartierPrioritaireType
|
||||
when GeoArea.sources.fetch(:selection_utilisateur)
|
||||
Types::GeoAreas::SelectionUtilisateurType
|
||||
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 tag.sup("2")
|
||||
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)
|
||||
if geo_area.polygon?
|
||||
if geo_area.area.present?
|
||||
|
|
|
@ -27,34 +27,18 @@ class Champs::CarteChamp < Champ
|
|||
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
|
||||
geo_areas.filter do |area|
|
||||
area.source == GeoArea.sources.fetch(:selection_utilisateur)
|
||||
end
|
||||
end
|
||||
|
||||
def layer_enabled?(layer)
|
||||
type_de_champ.options[layer] && type_de_champ.options[layer] != '0'
|
||||
end
|
||||
|
||||
def cadastres?
|
||||
type_de_champ&.cadastres && type_de_champ.cadastres != '0'
|
||||
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'
|
||||
layer_enabled?(:cadastres)
|
||||
end
|
||||
|
||||
def mnhn?
|
||||
|
|
|
@ -35,16 +35,12 @@ class GeoArea < ApplicationRecord
|
|||
]
|
||||
|
||||
enum source: {
|
||||
quartier_prioritaire: 'quartier_prioritaire',
|
||||
cadastre: 'cadastre',
|
||||
parcelle_agricole: 'parcelle_agricole',
|
||||
selection_utilisateur: '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 :parcelles_agricoles, -> { where(source: sources.fetch(:parcelle_agricole)) }
|
||||
|
||||
def to_feature
|
||||
{
|
||||
|
|
|
@ -56,7 +56,7 @@ class TypeDeChamp < ApplicationRecord
|
|||
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
|
||||
|
||||
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 :revisions, through: :revision_types_de_champ
|
||||
|
||||
|
|
|
@ -11,15 +11,6 @@ class GeoAreaSerializer < ActiveModel::Serializer
|
|||
attribute :code_com, 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
|
||||
object.safe_geometry
|
||||
end
|
||||
|
@ -27,12 +18,4 @@ class GeoAreaSerializer < ActiveModel::Serializer
|
|||
def include_cadastre?
|
||||
object.source == GeoArea.sources.fetch(:cadastre)
|
||||
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
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
class ModuleApiCartoSerializer < ActiveModel::Serializer
|
||||
attributes :use_api_carto,
|
||||
:quartiers_prioritaires,
|
||||
:cadastre
|
||||
attributes :use_api_carto, :cadastre
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue