All files / src/app/map/topography utils.ts

100% Statements 8/8
100% Branches 2/2
100% Functions 1/1
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107              1x 1x 1x 1x 1x                                                                       1x     1x         1x                                                                                                      
import { loadModules } from 'esri-loader';
import { linesImgUrl, dotImgUrl } from 'src/config/urls';
 
/**
 * The different names of the types of topographic information
 * available on the application's ArcGIS server.
 */
export enum TopographyTypeName {
  BUILDING = 'building',
  HARD = 'hard',
  LINEAR = 'linear',
  WATER = 'water'
}
 
/**
 * The categories of topographic information types that are
 * grouped together to be drawn on maps.
 */
export const topographicCategories = {
  roads: [
    TopographyTypeName.LINEAR,
    TopographyTypeName.WATER
  ],
  city: [
    TopographyTypeName.BUILDING,
    TopographyTypeName.HARD,
    TopographyTypeName.WATER
  ]
};
 
/**
 * A type of topographic information which can be drawn on a map.
 * TopographyTypes cover different sub-types of topographic information
 * extracted from the application's ArcGIS server.
 * Each TopographyType has an Esri Symbol associated to it to distringuish
 * it from the others when it is drawn on a map.
 */
export interface TopographyType {
  name: TopographyTypeName;
  topographySubTypes: string[];
  symbol: __esri.Symbol;
}
 
/**
 * Get the list of all the TopographyTypes for the application.
 */
export async function getAllTopographyTypes(): Promise<TopographyType[]> {
  const [
    SimpleFillSymbol,
    PictureFillSymbol
  ] = await loadModules([
    'esri/symbols/SimpleFillSymbol',
    'esri/symbols/PictureFillSymbol'
  ]);
 
  return [
    {
      name: TopographyTypeName.BUILDING,
      topographySubTypes: [
        'batiment'
      ],
      symbol: new PictureFillSymbol({
        url: linesImgUrl,
        height: '16px',
        width: '16px'
      })
    },
    {
      name: TopographyTypeName.HARD,
      topographySubTypes: [
        'ilot',
        'trottoir',
        'autre_revetement_dur',
        'rocher',
        'place_aviation',
      ],
      symbol: new SimpleFillSymbol({
        color: '#000000'
      })
    },
    {
      name: TopographyTypeName.LINEAR,
      topographySubTypes: [
        'route_chemin',
        'chemin_de_fer',
      ],
      symbol: new SimpleFillSymbol({
        color: '#000000'
      })
    },
    {
      name: TopographyTypeName.WATER,
      topographySubTypes: [
        'eau_stagnante',
        'bassin',
        'cours_eau',
        'fontaine',
      ],
      symbol: new PictureFillSymbol({
        url: dotImgUrl,
        height: '16px',
        width: '16px'
      })
    }
  ];
}