@@ -3,37 +3,62 @@ module Main where
33import Prelude
44
55import Color as Color
6-
76import Control.Monad.Eff (Eff )
8- import Control.Monad.Eff.Ref (REF )
9- import Control.Monad.Eff.Random (RANDOM , random )
107import Control.Monad.Eff.Class (liftEff )
8+ import Control.Monad.Eff.Random (RANDOM , random )
9+ import Control.Monad.Eff.Ref (REF )
1110import Control.Monad.Maybe.Trans (MaybeT (..), runMaybeT )
12-
11+ import DOM (DOM )
12+ import DOM.Classy.ParentNode (class IsParentNode , querySelector )
13+ import DOM.HTML (window )
14+ import DOM.HTML.Window (document )
1315import Data.Array as A
1416import Data.Either (Either (..))
15- import Data.Traversable as F
1617import Data.Maybe (Maybe (..))
1718import Data.Newtype (wrap )
18- import Data.Path.Pathy (file , dir , (</>), rootDir , currentDir )
19- import Data.URI (URIRef )
20- import Data.URI as URI
21-
22- import DOM (DOM )
23- import DOM.HTML (window )
24- import DOM.Classy.ParentNode (class IsParentNode , querySelector )
25- import DOM.HTML.Window (document )
26-
19+ import Data.String.NonEmpty as NES
20+ import Data.These (These (..))
21+ import Data.Traversable as F
22+ import Data.Tuple (Tuple (..))
2723import Graphics.Canvas (CANVAS )
28-
24+ import HeatmapLayerData (heatmapLayerData )
25+ import Leaflet.Core (mkLeafURIRef )
2926import Leaflet.Core as LC
27+ import Leaflet.Core.Types (LeafURIRef )
3028import Leaflet.Plugin.Heatmap as LH
3129import Leaflet.Util ((×))
32-
33- import HeatmapLayerData (heatmapLayerData )
30+ import Partial.Unsafe (unsafePartial )
31+ import URI (Authority (..), Fragment , HierPath , HierarchicalPart (..), Host (..), Path (..), PathAbsolute (..), Port , Query , RelPath , RelativePart (..), RelativeRef (..), URI (..), URIRef , UserInfo )
32+ import URI.Host.RegName as RegName
33+ import URI.HostPortPair (HostPortPair )
34+ import URI.HostPortPair as HostPortPair
35+ import URI.Path.Segment (segmentNZFromString )
36+ import URI.Path.Segment as PathSegment
37+ import URI.Scheme as Scheme
38+ import URI.URIRef (URIRefOptions )
3439
3540foreign import onload ∷ ∀ e a . Eff e a → Eff e a
3641
42+ type MainURIRef = URIRef UserInfo (HostPortPair Host Port ) Path HierPath RelPath Query Fragment
43+
44+ mainURIRefOptions ∷ Record (URIRefOptions UserInfo (HostPortPair Host Port ) Path HierPath RelPath Query Fragment )
45+ mainURIRefOptions =
46+ { parseUserInfo: pure
47+ , printUserInfo: id
48+ , parseHosts: HostPortPair .parser pure pure
49+ , printHosts: HostPortPair .print id id
50+ , parsePath: pure
51+ , printPath: id
52+ , parseHierPath: pure
53+ , printHierPath: id
54+ , parseRelPath: pure
55+ , printRelPath: id
56+ , parseQuery: pure
57+ , printQuery: id
58+ , parseFragment: pure
59+ , printFragment: id
60+ }
61+
3762mkLatLngs ∷ ∀ e . MaybeT (Eff (dom ∷ DOM , random ∷ RANDOM |e )) (Array LC.LatLng )
3863mkLatLngs = do
3964 let inp = A .range 0 5
@@ -47,22 +72,27 @@ mkLatLngs = do
4772 pure $ A .zipWith (\lat lng → {lat, lng}) lats lngs
4873
4974
50- testURI ∷ URIRef
51- testURI =
52- Left $ URI.URI
53- (Just $ URI.Scheme " http" )
54- (URI.HierarchicalPart
55- (Just $ URI.Authority Nothing [(URI.NameAddress " {s}.tile.osm.org" ) × Nothing ])
56- (Just $ Right $ rootDir </> dir " {z}" </> dir " {x}" </> file " {y}.png" ))
57- Nothing
58- Nothing
59-
60- iconConf ∷ { iconUrl ∷ URIRef , iconSize ∷ LC.Point }
61- iconConf =
62- { iconUrl: Right $ URI.RelativeRef
63- (URI.RelativePart Nothing $ Just $ Right $ currentDir </> file " marker.svg" )
75+ testURI ∷ LeafURIRef
76+ testURI = mkLeafURIRef
77+ { uri: Left $ URI
78+ (Scheme .unsafeFromString " http" )
79+ (HierarchicalPartAuth
80+ (Authority Nothing (Just $ This $ NameAddress $ RegName .fromString $ unsafePartial $ NES .unsafeFromString " {s}.tile.osm.org" ))
81+ (Path $ map PathSegment .segmentFromString [" {z}" , " {x}" , " {y}.png" ]))
6482 Nothing
6583 Nothing
84+ , opts: mainURIRefOptions
85+ }
86+
87+ iconConf ∷ { iconUrl ∷ LeafURIRef , iconSize ∷ LC.Point }
88+ iconConf =
89+ { iconUrl: mkLeafURIRef
90+ { uri: Right $ RelativeRef
91+ (RelativePartNoAuth $ Just $ Left $ PathAbsolute $ Just $ Tuple (segmentNZFromString $ unsafePartial $ NES .unsafeFromString " marker.svg" ) [] )
92+ Nothing
93+ Nothing
94+ , opts: mainURIRefOptions
95+ }
6696 , iconSize: 40 × 40
6797 }
6898core
0 commit comments