Skip to content

Commit

Permalink
Bring back route direction #1030 - increase route opacity and weight …
Browse files Browse the repository at this point in the history
…to 90%, changed route-layer.factory to routes.factory.
  • Loading branch information
HarelM committed May 14, 2019
1 parent 79a2222 commit afc12c1
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 47 deletions.
4 changes: 2 additions & 2 deletions IsraelHiking.Web/sources/application/application.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import { SidebarService } from "./services/sidebar.service";
import { HashService } from "./services/hash.service";
import { LayersService } from "./services/layers/layers.service";
import { DataContainerService } from "./services/data-container.service";
import { RouteLayerFactory } from "./services/layers/routelayers/route-layer.factory";
import { RoutesFactory } from "./services/layers/routelayers/routes.factory";
import { RouterService } from "./services/routers/router.service";
import { SnappingService } from "./services/snapping.service";
import { FitBoundsService } from "./services/fit-bounds.service";
Expand Down Expand Up @@ -325,7 +325,7 @@ NgModule({
HashService,
LayersService,
DataContainerService,
RouteLayerFactory,
RoutesFactory,
RouterService,
SnappingService,
FitBoundsService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { NgRedux } from "@angular-redux/store";

import { ResourcesService } from "../../../services/resources.service";
import { ToastService } from "../../../services/toast.service";
import { RouteLayerFactory } from "../../../services/layers/routelayers/route-layer.factory";
import { RoutesFactory } from "../../../services/layers/routelayers/routes.factory";
import { RouteBaseDialogComponent } from "./route-base-dialog.component";
import { SelectedRouteService } from "../../../services/layers/routelayers/selected-route.service";
import { ApplicationState } from "../../../models/models";
Expand All @@ -18,12 +18,12 @@ import { AddRouteAction } from "../../../reducres/routes.reducer";
export class RouteAddDialogComponent extends RouteBaseDialogComponent {
constructor(resources: ResourcesService,
selectedRouteService: SelectedRouteService,
routeLayerFactory: RouteLayerFactory,
routesFactory: RoutesFactory,
toastService: ToastService,
ngRedux: NgRedux<ApplicationState>,
) {
super(resources, selectedRouteService, routeLayerFactory, toastService, ngRedux);
this.routeData = routeLayerFactory.createRouteData(selectedRouteService.createRouteName(),
super(resources, selectedRouteService, routesFactory, toastService, ngRedux);
this.routeData = routesFactory.createRouteData(selectedRouteService.createRouteName(),
selectedRouteService.getLeastUsedColor());
this.isNew = true;
this.title = this.resources.addRoute;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import { Observable } from "rxjs";

import { ResourcesService } from "../../../services/resources.service";
import { ToastService } from "../../../services/toast.service";
import { RouteLayerFactory } from "../../../services/layers/routelayers/route-layer.factory";
import { RoutesFactory } from "../../../services/layers/routelayers/routes.factory";
import { BaseMapComponent } from "../../base-map.component";
import { ApplicationState, RouteData } from "../../../models/models";
import { ChangeRoutePropertiesAction } from "../../../reducres/routes.reducer";
import { SelectedRouteService } from "../../../services/layers/routelayers/selected-route.service";

export abstract class RouteBaseDialogComponent extends BaseMapComponent {
Expand All @@ -22,11 +21,11 @@ export abstract class RouteBaseDialogComponent extends BaseMapComponent {

constructor(resources: ResourcesService,
protected readonly selectedRouteService: SelectedRouteService,
protected readonly routeLayerFactory: RouteLayerFactory,
protected readonly routesFactory: RoutesFactory,
protected readonly toastService: ToastService,
protected readonly ngRedux: NgRedux<ApplicationState>) {
super(resources);
this.colors = this.routeLayerFactory.colors;
this.colors = this.routesFactory.colors;
}

public saveRoute() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ResourcesService } from "../../../services/resources.service";
import { FileService } from "../../../services/file.service";
import { FitBoundsService } from "../../../services/fit-bounds.service";
import { ToastService } from "../../../services/toast.service";
import { RouteLayerFactory } from "../../../services/layers/routelayers/route-layer.factory";
import { RoutesFactory } from "../../../services/layers/routelayers/routes.factory";
import { SelectedRouteService } from "../../../services/layers/routelayers/selected-route.service";
import { SpatialService } from "../../../services/spatial.service";
import { RouteBaseDialogComponent } from "./route-base-dialog.component";
Expand All @@ -23,13 +23,13 @@ export class RouteEditDialogComponent extends RouteBaseDialogComponent {

constructor(resources: ResourcesService,
selectedRouteService: SelectedRouteService,
routeLayerFactory: RouteLayerFactory,
routesFactory: RoutesFactory,
toastService: ToastService,
ngRedux: NgRedux<ApplicationState>,
private readonly fileService: FileService,
private readonly fitBoundsService: FitBoundsService
) {
super(resources, selectedRouteService, routeLayerFactory, toastService, ngRedux);
super(resources, selectedRouteService, routesFactory, toastService, ngRedux);

this.isNew = false;
this.title = this.resources.routeProperties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { BaseMapComponent } from "./base-map.component";
import { GeoLocationService } from "../services/geo-location.service";
import { ToastService } from "../services/toast.service";
import { FitBoundsService } from "../services/fit-bounds.service";
import { RouteLayerFactory } from "../services/layers/routelayers/route-layer.factory";
import { RoutesFactory } from "../services/layers/routelayers/routes.factory";
import { CancelableTimeoutService } from "../services/cancelable-timeout.service";
import { SelectedRouteService } from "../services/layers/routelayers/selected-route.service";
import { SpatialService } from "../services/spatial.service";
Expand Down Expand Up @@ -42,7 +42,7 @@ export class LocationComponent extends BaseMapComponent {
private readonly geoLocationService: GeoLocationService,
private readonly toastService: ToastService,
private readonly selectedRouteService: SelectedRouteService,
private readonly routeLayerFactory: RouteLayerFactory,
private readonly routesFactory: RoutesFactory,
private readonly cancelableTimeoutService: CancelableTimeoutService,
private readonly fitBoundsService: FitBoundsService,
private readonly fileService: FileService,
Expand Down Expand Up @@ -205,7 +205,7 @@ export class LocationComponent extends BaseMapComponent {
`${date.toISOString().split("T")[0]} ${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`;
name = this.resources.route + " " + dateString;
}
let route = this.routeLayerFactory.createRouteData(name, this.selectedRouteService.getLeastUsedColor());
let route = this.routesFactory.createRouteData(name, this.selectedRouteService.getLeastUsedColor());
let currentLocation = this.geoLocationService.currentLocation;
let routingType = this.ngRedux.getState().routeEditingState.routingType;
route.segments.push({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import { ResourcesService } from "../../services/resources.service";
import { SpatialService } from "../../services/spatial.service";
import { RemoveMissingPartAction, SetVisibleTraceAction, SetMissingPartsAction } from "../../reducres/traces.reducer";
import { AddRouteAction } from "../../reducres/routes.reducer";
import { RoutesFactory } from "../../services/layers/routelayers/routes.factory";
import { Trace, ApplicationState, LatLngAlt } from "../../models/models";
import { RouteLayerFactory } from "../../services/layers/routelayers/route-layer.factory";


@Component({
selector: "traces",
Expand All @@ -34,7 +35,7 @@ export class TracesComponent extends BaseMapComponent {
private missingParts$: Observable<GeoJSON.FeatureCollection<GeoJSON.LineString>>;

constructor(resources: ResourcesService,
private readonly routeLayerFactory: RouteLayerFactory,
private readonly routesFactory: RoutesFactory,
private readonly ngRedux: NgRedux<ApplicationState>) {
super(resources);
this.isConfigOpen = false;
Expand Down Expand Up @@ -122,7 +123,7 @@ export class TracesComponent extends BaseMapComponent {

public convertToRoute() {
for (let route of this.visibleTrace.dataContainer.routes) {
let routeToAdd = this.routeLayerFactory.createRouteData(route.name);
let routeToAdd = this.routesFactory.createRouteData(route.name);
routeToAdd.segments = route.segments;
routeToAdd.markers = route.markers;
this.ngRedux.dispatch(new AddRouteAction({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { ToastService } from "../services/toast.service";
import { SearchResultsProvider, ISearchResultsPointOfInterest } from "../services/search-results.provider";
import { BaseMapComponent } from "./base-map.component";
import { RoutingType, ApplicationState, RouteSegmentData, LatLngAlt } from "../models/models";
import { RouteLayerFactory } from "../services/layers/routelayers/route-layer.factory";
import { RoutesFactory } from "../services/layers/routelayers/routes.factory";
import { AddRouteAction } from "../reducres/routes.reducer";
import { SpatialService } from "../services/spatial.service";
import { SetSelectedRouteAction } from "../reducres/route-editing-state.reducer";
Expand Down Expand Up @@ -80,7 +80,7 @@ export class SearchComponent extends BaseMapComponent implements AfterViewInit {
private readonly routerService: RouterService,
private readonly fitBoundsService: FitBoundsService,
private readonly toastService: ToastService,
private readonly routeLayerFactory: RouteLayerFactory,
private readonly routesFactory: RoutesFactory,
private readonly router: Router,
private readonly ngRedux: NgRedux<ApplicationState>
) {
Expand Down Expand Up @@ -228,7 +228,7 @@ export class SearchComponent extends BaseMapComponent implements AfterViewInit {
}

public convertToRoute() {
let route = this.routeLayerFactory.createRouteData(this.directional.routeTitle);
let route = this.routesFactory.createRouteData(this.directional.routeTitle);
route.segments = this.directional.routeSegments;
this.ngRedux.dispatch(new AddRouteAction({
routeData: route
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { ToastService } from "../../../services/toast.service";
import { HashService, RouteStrings, IPoiRouterData } from "../../../services/hash.service";
import { SelectedRouteService } from "../../../services/layers/routelayers/selected-route.service";
import { AddRouteAction, AddPrivatePoiAction } from "../../../reducres/routes.reducer";
import { RouteLayerFactory } from "../../../services/layers/routelayers/route-layer.factory";
import { RoutesFactory } from "../../../services/layers/routelayers/routes.factory";
import { FitBoundsService } from "../../../services/fit-bounds.service";
import { SetSelectedPoiAction, SetUploadMarkerDataAction, SetSidebarAction } from "../../../reducres/poi.reducer";
import { SpatialService } from "../../../services/spatial.service";
Expand Down Expand Up @@ -60,7 +60,7 @@ export class PublicPoiSidebarComponent extends BaseMapComponent implements OnDes
private readonly poiService: PoiService,
private readonly authorizationService: AuthorizationService,
private readonly selectedRouteService: SelectedRouteService,
private readonly routeLayerFactory: RouteLayerFactory,
private readonly routesFactory: RoutesFactory,
private readonly toastService: ToastService,
private readonly hashService: HashService,
private readonly fitBoundsService: FitBoundsService,
Expand Down Expand Up @@ -275,7 +275,7 @@ export class PublicPoiSidebarComponent extends BaseMapComponent implements OnDes
let routesCopy = JSON.parse(JSON.stringify(this.poiExtended.dataContainer.routes)) as RouteData[];
for (let routeData of routesCopy) {
let name = this.selectedRouteService.createRouteName(routeData.name);
let newRoute = this.routeLayerFactory.createRouteData(name, this.selectedRouteService.getLeastUsedColor());
let newRoute = this.routesFactory.createRouteData(name, this.selectedRouteService.getLeastUsedColor());
newRoute.description = this.info.description;
newRoute.segments = routeData.segments;
newRoute.markers = routeData.markers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { FitBoundsService } from "./fit-bounds.service";
import { BulkReplaceRoutesAction } from "../reducres/routes.reducer";
import { SelectedRouteService } from "./layers/routelayers/selected-route.service";
import { MapService } from "./map.service";
import { RouteLayerFactory } from "./layers/routelayers/route-layer.factory";
import { RoutesFactory } from "./layers/routelayers/routes.factory";
import { RunningContextService } from "./running-context.service";
import { SetFileUrlAndBaseLayerAction } from "../reducres/in-memory.reducer";
import { SetSelectedRouteAction } from "../reducres/route-editing-state.reducer";
Expand All @@ -20,16 +20,14 @@ import { DataContainer, ApplicationState, LayerData } from "../models/models";
@Injectable()
export class DataContainerService {

// private layersInitializationPromise: Promise<any>;

constructor(private readonly shareUrlsService: ShareUrlsService,
private readonly layersService: LayersService,
private readonly fileService: FileService,
private readonly resourcesService: ResourcesService,
private readonly toastService: ToastService,
private readonly fitBoundsService: FitBoundsService,
private readonly selectedRouteService: SelectedRouteService,
private readonly routeLayerFactory: RouteLayerFactory,
private readonly routesFactory: RoutesFactory,
private readonly mapService: MapService,
private readonly runningContextService: RunningContextService,
private readonly ngRedux: NgRedux<ApplicationState>) {
Expand All @@ -38,7 +36,7 @@ export class DataContainerService {
public setData(dataContainer: DataContainer, keepCurrentRoutes: boolean) {
let routesData = [];
for (let route of dataContainer.routes) {
let routeToAdd = this.routeLayerFactory.createRouteDataAddMissingFields(route, this.selectedRouteService.getLeastUsedColor());
let routeToAdd = this.routesFactory.createRouteDataAddMissingFields(route, this.selectedRouteService.getLeastUsedColor());
routesData.push(routeToAdd);
}
if (keepCurrentRoutes) {
Expand Down Expand Up @@ -86,7 +84,6 @@ export class DataContainerService {
}

public setFileUrlAfterNavigation = async (url: string, baseLayer: string) => {
// await this.layersInitializationPromise;
try {
let data = await this.fileService.openFromUrl(url);
this.ngRedux.dispatch(new SetFileUrlAndBaseLayerAction({
Expand All @@ -105,8 +102,6 @@ export class DataContainerService {
if (shareUrl && shareUrl.id === shareId) {
return;
}
// HM TODO: do we need this promise?
// await this.layersInitializationPromise;
try {
shareUrl = await this.shareUrlsService.setShareUrlById(shareId);
this.setData(shareUrl.dataContainer, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { RouteData } from "../../../models/models";


@Injectable()
export class RouteLayerFactory {
export class RoutesFactory {

private static readonly DEFAULT_OPACITY = 0.5;
private static readonly DEFAULT_WEIGHT = 7;
private static readonly DEFAULT_OPACITY = 0.9;
private static readonly DEFAULT_WEIGHT = 9;

// default values - in case the response from server takes too long.
public colors: string[] = [
Expand Down Expand Up @@ -42,8 +42,8 @@ export class RouteLayerFactory {
description: "",
state: "ReadOnly",
color: color || this.colors[this.nextColorIndex],
opacity: RouteLayerFactory.DEFAULT_OPACITY,
weight: RouteLayerFactory.DEFAULT_WEIGHT,
opacity: RoutesFactory.DEFAULT_OPACITY,
weight: RoutesFactory.DEFAULT_WEIGHT,
markers: [],
segments: []
};
Expand All @@ -54,8 +54,8 @@ export class RouteLayerFactory {
public createRouteDataAddMissingFields(routeData: RouteData, color: string): RouteData {
let route = { ...routeData };
route.color = route.color || color;
route.opacity = route.opacity || RouteLayerFactory.DEFAULT_OPACITY;
route.weight = route.weight || RouteLayerFactory.DEFAULT_WEIGHT;
route.opacity = route.opacity || RoutesFactory.DEFAULT_OPACITY;
route.weight = route.weight || RoutesFactory.DEFAULT_WEIGHT;
route.id = route.id || this.generateRandomId();
route.state = "ReadOnly";
return route;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
AddPrivatePoiAction,
ChangeEditStateAction
} from "../../../reducres/routes.reducer";
import { RouteLayerFactory } from "./route-layer.factory";
import { RoutesFactory } from "./routes.factory";
import { ResourcesService } from "../../resources.service";
import { RouteData, ApplicationState, RouteSegmentData, ILatLngTime } from "../../../models/models";
import { SpatialService } from "../../spatial.service";
Expand All @@ -39,7 +39,7 @@ export class SelectedRouteService {
private recordingRouteId$: Observable<string>;

constructor(private readonly resourcesService: ResourcesService,
private readonly routeLayerFactory: RouteLayerFactory,
private readonly routesFactory: RoutesFactory,
private readonly routerService: RouterService,
private readonly ngRedux: NgRedux<ApplicationState>) {
this.routes = [];
Expand Down Expand Up @@ -75,7 +75,7 @@ export class SelectedRouteService {
this.ngRedux.dispatch(new SetSelectedRouteAction({ routeId: this.routes[0].id }));
}
if (this.routes.length === 0) {
let data = this.routeLayerFactory.createRouteData(this.createRouteName(), this.getLeastUsedColor());
let data = this.routesFactory.createRouteData(this.createRouteName(), this.getLeastUsedColor());
this.ngRedux.dispatch(new AddRouteAction({ routeData: data }));
this.setSelectedRoute(data.id);
}
Expand Down Expand Up @@ -107,8 +107,8 @@ export class SelectedRouteService {

public getLeastUsedColor() {
let colorCount = Number.POSITIVE_INFINITY;
let selectedColor = this.routeLayerFactory.colors[0];
for (let color of this.routeLayerFactory.colors) {
let selectedColor = this.routesFactory.colors[0];
for (let color of this.routesFactory.colors) {
let currentColorCount = this.routes.filter(r => r.color === color).length;
if (currentColorCount < colorCount) {
selectedColor = color;
Expand Down Expand Up @@ -167,7 +167,7 @@ export class SelectedRouteService {
routingType: postfixSegments[0].routingType
} as RouteSegmentData);
let splitRouteData =
this.routeLayerFactory.createRouteData(
this.routesFactory.createRouteData(
this.createRouteName(selectedRoute.name + " " + this.resourcesService.split),
this.getLeastUsedColor());
splitRouteData.segments = postfixSegments;
Expand Down Expand Up @@ -329,7 +329,7 @@ export class SelectedRouteService {
if (this.isNameAvailable(routeData.name) === false) {
routeData.name = this.createRouteName(routeData.name);
}
let routeToAdd = this.routeLayerFactory.createRouteDataAddMissingFields(routeData, this.getLeastUsedColor());
let routeToAdd = this.routesFactory.createRouteDataAddMissingFields(routeData, this.getLeastUsedColor());
this.ngRedux.dispatch(new AddRouteAction({
routeData: routeToAdd
}));
Expand Down

0 comments on commit afc12c1

Please sign in to comment.