<commit_before>{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ForeignFunctionInterface,  JavaScriptFFI, GHCForeignImportPrim, UnliftedFFITypes #-}
{-# LANGUAGE RecursiveDo #-}
-----------------------------------------------------------------------------
-- |
-- Module      :  Program.Model.City
-- Copyright   :  (c) <NAME>
-- License     :  MIT
--
-- Maintainer  :  <NAME> <<EMAIL>>
-- Stability   :  experimental
--
--
--
-----------------------------------------------------------------------------
module Program.Model.City
    ( City (..), buildCity, updateCity, isEmptyCity, emptyCity, clearCity
    , CitySettings (..), defaultCitySettings
    , CityObjectCollection ()
    , ClearingGeometry (..)
    , getObject, setObject
    -- | Load geometry
    , processScenario, scenarioViewScaling
    -- | Store geometry
    , storeCityAsIs, storeObjectsAsIs
    -- | reactive-banana
    , cityBehavior
    , CityUpdate (..)
    , GroundUpdated (..)
    , GroundUpdateRequest (..)
    , colorizeObjects
    ) where

import Control.Arrow ((***))
import JsHs.Types
import JsHs.WebGL
--import GHCJS.Marshal.Pure
import Data.Maybe (fromMaybe)

import qualified JsHs.Array as JS
import qualified JsHs.TypedArray as JSTA
import JsHs.JSString hiding (foldr1)
import Data.Geometry
import Data.Geometry.Structure.Feature
import qualified Data.Geometry.Transform as T
import qualified Data.Geometry.Structure.LineString as LS
import qualified Data.Geometry.Structure.PointSet as PS
--import Data.Geometry.Transform
--import Geometry.Structure

import Program.Model.CityObject
import Program.Model.CityGround
import Program.Model.WiredGeometry
import Program.Model.Camera
import Program.Settings
import Program.Types
import Program.VisualService

import Reactive.Banana.Combinators
--import Control.Monad.Fix (MonadFix)
import Control.Monad.Writer.Strict
--import JsHs.Debug
--import JsHs.Debug
--import Debug.Trace

-- | Map of all city objects (buildings, roads, etc).
data City = City
    { activeObjId        :: !Int
--    , activeObjSnapshot  :: !(Maybe LocatedCityObject)
    , objectsIn          :: !CityObjectCollection
    , cityTransform      :: !(GLfloat, Vector2 GLfloat)
    , ground             :: !CityGround
    , csettings          :: !CitySettings
    , clutter            :: !(LS.MultiLineString 3 GLfloat, WiredGeometry)
    , buildingColors     :: !(Maybe (PS.PointArray 4 GLfloat))
    --, drawTextures       :: !Bool
    , originLatLonAlt    :: !(Maybe (Vector 3 GLfloat))
    , srid               :: !(Maybe Int)
    , defaultBlockColor  :: !(Maybe (Vector4 GLfloat))
    , defaultStaticColor :: !(Maybe (Vector4 GLfloat))
    , defaultLineColor   :: !(Maybe (Vector4 GLfloat))
    }

data CitySettings = CitySettings
    { defHeight    :: !GLfloat
    , diagFunction :: Int -> GLfloat
    , groundDilate :: !GLfloat
    , evalCellSize :: !GLfloat
    , defElevation :: !GLfloat
    , defScale     :: !(Maybe GLfloat)
    }

-- | This indicates removal of all geometry from the city
data ClearingGeometry = ClearingGeometry

defaultCitySettings :: CitySettings
defaultCitySettings = CitySettings
    { defHeight    = 1.5
    , diagFunction = (*5) . sqrt . fromIntegral
    , groundDilate = 1
    , evalCellSize = 0.5
    , defElevation = 0.01
    , defScale     = Nothing
    }

emptyCity :: City
emptyCity = City
    { activeObjId = 0<commit_msg>Fix wrong variable name<commit_after>{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ForeignFunctionInterface,  JavaScriptFFI, GHCForeignImportPrim, UnliftedFFITypes #-}
{-# LANGUAGE RecursiveDo #-}
-----------------------------------------------------------------------------
-- |
-- Module      :  Program.Model.City
-- Copyright   :  (c) <NAME>
-- License     :  MIT
--
-- Maintainer  :  <NAME> <ch<EMAIL>>
-- Stability   :  experimental
--
--
--
-----------------------------------------------------------------------------
module Program.Model.City
    ( City (..), buildCity, updateCity, isEmptyCity, emptyCity, clearCity
    , CitySettings (..), defaultCitySettings
    , CityObjectCollection ()
    , ClearingGeometry (..)
    , getObject, setObject
    -- | Load geometry
    , processScenario, scenarioViewScaling
    -- | Store geometry
    , storeCityAsIs, storeObjectsAsIs
    -- | reactive-banana
    , cityBehavior
    , CityUpdate (..)
    , GroundUpdated (..)
    , GroundUpdateRequest (..)
    , colorizeObjects
    ) where

import Control.Arrow ((***))
import JsHs.Types
import JsHs.WebGL
--import GHCJS.Marshal.Pure
import Data.Maybe (fromMaybe)

import qualified JsHs.Array as JS
import qualified JsHs.TypedArray as JSTA
import JsHs.JSString hiding (foldr1)
import Data.Geometry
import Data.Geometry.Structure.Feature
import qualified Data.Geometry.Transform as T
import qualified Data.Geometry.Structure.LineString as LS
import qualified Data.Geometry.Structure.PointSet as PS
--import Data.Geometry.Transform
--import Geometry.Structure

import Program.Model.CityObject
import Program.Model.CityGround
import Program.Model.WiredGeometry
import Program.Model.Camera
import Program.Settings
import Program.Types
import Program.VisualService

import Reactive.Banana.Combinators
--import Control.Monad.Fix (MonadFix)
import Control.Monad.Writer.Strict
--import JsHs.Debug
--import JsHs.Debug
--import Debug.Trace

-- | Map of all city objects (buildings, roads, etc).
data City = City
    { activeObjId        :: !Int
--    , activeObjSnapshot  :: !(Maybe LocatedCityObject)
    , objectsIn          :: !CityObjectCollection
    , cityTransform      :: !(GLfloat, Vector2 GLfloat)
    , ground             :: !CityGround
    , csettings          :: !CitySettings
    , clutter            :: !(LS.MultiLineString 3 GLfloat, WiredGeometry)
    , buildingColors     :: !(Maybe (PS.PointArray 4 GLfloat))
    --, drawTextures       :: !Bool
    , originLonLatAlt    :: !(Maybe (Vector 3 GLfloat))
    , srid               :: !(Maybe Int)
    , defaultBlockColor  :: !(Maybe (Vector4 GLfloat))
    , defaultStaticColor :: !(Maybe (Vector4 GLfloat))
    , defaultLineColor   :: !(Maybe (Vector4 GLfloat))
    }

data CitySettings = CitySettings
    { defHeight    :: !GLfloat
    , diagFunction :: Int -> GLfloat
    , groundDilate :: !GLfloat
    , evalCellSize :: !GLfloat
    , defElevation :: !GLfloat
    , defScale     :: !(Maybe GLfloat)
    }

-- | This indicates removal of all geometry from the city
data ClearingGeometry = ClearingGeometry

defaultCitySettings :: CitySettings
defaultCitySettings = CitySettings
    { defHeight    = 1.5
    , diagFunction = (*5) . sqrt . fromIntegral
    , groundDilate = 1
    , evalCellSize = 0.5
    , defElevation = 0.01
    , defScale     = Nothing
    }

emptyCity :: City
emptyCity = City
    { activeObjId = 0
{'fraction_non_alphanumeric': 0.15336728919071874, 'fraction_numerical': 0.0050933786078098476, 'mean_word_length': 2.6103166496424923, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6580810', 'n_tokens_mistral': 2112, 'n_tokens_neox': 2073, 'n_words': 496}