Skip to content
Snippets Groups Projects
Commit 3c75894b authored by Rhys Evans's avatar Rhys Evans
Browse files

Debugging of maps controller issue fixed. Pair Programming: Rhsy Nute and Rhys Evans

parent f69d3a7f
No related branches found
No related tags found
1 merge request!30Resolve "As a user I would like to see a map of the landmarks, so that I can figure out where to go"
Showing
with 97 additions and 1194 deletions
......@@ -11,7 +11,7 @@ public interface LocationRepository {
List<Location> getApprovedLocations();
List<Location> getApprovedLocations2(List<Location> list);
// List<Location> getApprovedLocations2(List<Location> list);
List<Location> getUnapprovedLocations();
......
......@@ -18,11 +18,12 @@ public class LocationRepositoryJDBC implements LocationRepository {
setlocationMapper();
}
public LocationRepositoryJDBC() {
JdbcTemplate ajdbc = new JdbcTemplate();
this.jdbc =ajdbc;
}
// public LocationRepositoryJDBC() {
// JdbcTemplate ajdbc = new JdbcTemplate();
// this.jdbc =ajdbc;
// setlocationMapper();
//
// }
private void setlocationMapper(){
......@@ -40,11 +41,16 @@ public class LocationRepositoryJDBC implements LocationRepository {
String sql= "SELECT * FROM locations";
return jdbc.query(sql, locationMapper);
}
public LocationRepositoryJDBC(JdbcTemplate jdbc, RowMapper<Location> locationMapper) {
this.jdbc = jdbc;
this.locationMapper = locationMapper;
}
// public LocationRepositoryJDBC() {
// JdbcTemplate ajdbc = new JdbcTemplate();
// this.jdbc =ajdbc;
// setlocationMapper();
//
// }
// public LocationRepositoryJDBC(JdbcTemplate jdbc, RowMapper<Location> locationMapper) {
// this.jdbc = jdbc;
// this.locationMapper = locationMapper;
// }
@Override // intended implementation at current: user data from templates/Landmarks/LandmarkFormTh.html is added to the Location table
public void addLocation(Location loc) {
......@@ -64,18 +70,18 @@ public class LocationRepositoryJDBC implements LocationRepository {
}
} return locationApprovalList;
}
@Override
public List<Location> getApprovedLocations2(List<Location> list){
List<Location> locationApprovalList= new ArrayList<Location>();
for (Location loc :list){
if (loc.isLocationApproved()) {
locationApprovalList.add(loc);
}
} return locationApprovalList;
}
//
// @Override
// public List<Location> getApprovedLocations2(List<Location> list){
//
// List<Location> locationApprovalList= new ArrayList<Location>();
// for (Location loc :list){
// if (loc.isLocationApproved()) {
// locationApprovalList.add(loc);
// }
// } return locationApprovalList;
// }
//
@Override
......
......@@ -15,7 +15,7 @@ import java.util.List;
//@Data
@AllArgsConstructor
@NoArgsConstructor
public class LocationsCoordinates extends LocationRepositoryJDBC {
public class LocationsCoordinates {
/// separate class to location to cover all locations within trails that have been approved and have long/lat coords attached for mapping.
private int locationID;
private Double locationCoordsLat;
......@@ -48,12 +48,12 @@ public class LocationsCoordinates extends LocationRepositoryJDBC {
this.locationCoordsLat = locationCoordsLat;
}
public LocationsCoordinates(JdbcTemplate aJdbc, int locationID, Double locationCoordsLat, Double locationCoordsLong) {
super(aJdbc);
this.locationID = locationID;
this.locationCoordsLong = locationCoordsLong;
this.locationCoordsLat = locationCoordsLat;
}
// public LocationsCoordinates(JdbcTemplate aJdbc, int locationID, Double locationCoordsLat, Double locationCoordsLong) {
// super(aJdbc);
// this.locationID = locationID;
// this.locationCoordsLong = locationCoordsLong;
// this.locationCoordsLat = locationCoordsLat;
// }
// public LocationsCoordinates(int locationID, Double locationCoordsLat, Double locationCoordsLong,JdbcTemplate jdbc) {
// super(jdbc);
......@@ -63,27 +63,26 @@ public class LocationsCoordinates extends LocationRepositoryJDBC {
// }
public LocationsCoordinates(JdbcTemplate aJdbc, int locationID, Double locationCoordsLat, Double locationCoordsLong, JdbcTemplate jdbc) {
super(aJdbc);
this.locationID = locationID;
this.locationCoordsLat = locationCoordsLat;
this.locationCoordsLong = locationCoordsLong;
this.jdbc = jdbc;
}
// public LocationsCoordinates(JdbcTemplate aJdbc, int locationID, Double locationCoordsLat, Double locationCoordsLong, JdbcTemplate jdbc) {
// super(aJdbc);
// this.locationID = locationID;
// this.locationCoordsLat = locationCoordsLat;
// this.locationCoordsLong = locationCoordsLong;
// this.jdbc = jdbc;
// }
public LocationsCoordinates(int locationID, Double locationCoordsLat, Double locationCoordsLong) {
super();
this.locationID = locationID;
this.locationCoordsLat = locationCoordsLat;
this.locationCoordsLong = locationCoordsLong;
}
public LocationsCoordinates(JdbcTemplate aJdbc) {
super(aJdbc);
}
// public LocationsCoordinates(JdbcTemplate aJdbc) {
// super(aJdbc);
// }
public List<Location> getFullListLocations(JdbcTemplate aJdbc){
LocationsCoordinates jdbcSuper= new LocationsCoordinates(aJdbc);
// LocationsCoordinates jdbcSuper= new LocationsCoordinates(aJdbc);
return new LocationRepositoryJDBC(aJdbc).getAllLocation();
}
......@@ -95,7 +94,7 @@ public class LocationsCoordinates extends LocationRepositoryJDBC {
// }
public List<Location> getFullUnapprovedLocations(JdbcTemplate aJdbc){
LocationsCoordinates jdbcSuper= new LocationsCoordinates(aJdbc);
// LocationsCoordinates jdbcSuper= new LocationsCoordinates(aJdbc);
return new LocationRepositoryJDBC(aJdbc).getUnapprovedLocations();
}
......
......@@ -22,8 +22,8 @@ public class PlacesController {
@Autowired
private PlacesCoordinatesRepository placeRepo;
// @Autowired
// private TrailsRepository locationRepo;
@Autowired
private LocationRepository locationRepo;
......@@ -31,17 +31,16 @@ public class PlacesController {
@GetMapping("/checkpoint")
public ModelAndView getLocationPages(){
ModelAndView modelAndView = new ModelAndView("landmarks/locationPage.html");
// List<Trail> locationssad = locationRepo.getAllTrails();
List<Location> locations = locationRepo.getAllLocation();
// List<Location> approvedLocations = locationRepo.getApprovedLocations2(locations);
List<LocationsCoordinates> locCoords = placeRepo.getAllLocationCoords();
List<Integer> locationIDIndex = new ArrayList<Integer>();
// List<Location> locationCoordsWorkaround = new ArrayList<Location>();
// for (LocationsCoordinates coord: locCoords){
// locationIDIndex.add(coord.getLocationID()-1);
// locationCoordsWorkaround.add(locations.get(coord.getLocationID()-1));
// }
// modelAndView.addObject("locations", locationCoordsWorkaround);
List<Location> locationCoordsWorkaround = new ArrayList<Location>();
for (LocationsCoordinates coord: locCoords){
locationIDIndex.add(coord.getLocationID()-1);
locationCoordsWorkaround.add(locations.get(coord.getLocationID()-1));
}
modelAndView.addObject("location", locationCoordsWorkaround);
modelAndView.addObject("locationCoords", locCoords);
return modelAndView;
}
......
......@@ -75,7 +75,7 @@ public class PlacesCoordinatesRepositoryJDBC implements PlacesCoordinatesReposit
public List<Location> getFullApprovedLocations(JdbcTemplate aJdbc) {
LocationsCoordinates jdbcSuper= new LocationsCoordinates(aJdbc);
// LocationsCoordinates jdbcSuper= new LocationsCoordinates(aJdbc);
return new LocationRepositoryJDBC(aJdbc).getApprovedLocations();
}
......@@ -128,45 +128,45 @@ public class PlacesCoordinatesRepositoryJDBC implements PlacesCoordinatesReposit
// Method used to approve and add locations with associated coordinates. List<Location> unapprovedLocations
public void approveLocationAndAddCoords(String locationsName, Double latCoords, Double longCoords,JdbcTemplate jdbc) {
// need list too
LocationsCoordinates jdbcTemp= new LocationsCoordinates(jdbc);
List<Location> unapprovedLocations = jdbcTemp.getFullUnapprovedLocations(jdbc);
List<Location> allLocations = jdbcTemp.getFullListLocations(jdbc);
PlacesCoordinatesRepositoryJDBC jbdcsecond = new PlacesCoordinatesRepositoryJDBC(jdbc);
List<TownWithTrails> allTowns = jbdcsecond.getAllTownCoords();
int unapporvedLocationsListIndex=99; // initialize variable to allow after if statement to run todo fix this
for (int i=0; i<unapprovedLocations.size();i++){ // check if location exists
if (Objects.equals(unapprovedLocations.get(i).getLocationName(), locationsName)){
unapporvedLocationsListIndex =i;
break;
} else if(!Objects.equals(unapprovedLocations.get(i).getLocationPlace(), locationsName)){
System.out.println("Error, location is not valid, please check your spelling or locations table.");
return;
}
String toBeApprovedLocationTown=unapprovedLocations.get(unapporvedLocationsListIndex).getLocationPlace();
int tableLocationIDOfInputtedLocation= getLocationTableIDValue(allLocations, locationsName);
LocationsCoordinates unapprovedLocation= new LocationsCoordinates(tableLocationIDOfInputtedLocation,latCoords, longCoords);
boolean locationWithinTownBoundaries= checkInputtedCoordsMatchTown(Double.toString(latCoords) ,Double.toString(longCoords), toBeApprovedLocationTown);
if (locationWithinTownBoundaries){
addLocationCoord(unapprovedLocation);
return;
} else {
return;}
// for (TownWithTrails town : allTowns){
// if (Objects.equals(toBeApprovedLocationTown, town.getTownName())){
}
}
// public void approveLocationAndAddCoords(String locationsName, Double latCoords, Double longCoords,JdbcTemplate jdbc) {
// // need list too
//
// LocationsCoordinates jdbcTemp= new LocationsCoordinates(jdbc);
// List<Location> unapprovedLocations = jdbcTemp.getFullUnapprovedLocations(jdbc);
// List<Location> allLocations = jdbcTemp.getFullListLocations(jdbc);
//
// PlacesCoordinatesRepositoryJDBC jbdcsecond = new PlacesCoordinatesRepositoryJDBC(jdbc);
// List<TownWithTrails> allTowns = jbdcsecond.getAllTownCoords();
// int unapporvedLocationsListIndex=99; // initialize variable to allow after if statement to run todo fix this
// for (int i=0; i<unapprovedLocations.size();i++){ // check if location exists
// if (Objects.equals(unapprovedLocations.get(i).getLocationName(), locationsName)){
// unapporvedLocationsListIndex =i;
// break;
//
// } else if(!Objects.equals(unapprovedLocations.get(i).getLocationPlace(), locationsName)){
// System.out.println("Error, location is not valid, please check your spelling or locations table.");
//
// return;
// }
// String toBeApprovedLocationTown=unapprovedLocations.get(unapporvedLocationsListIndex).getLocationPlace();
// int tableLocationIDOfInputtedLocation= getLocationTableIDValue(allLocations, locationsName);
// LocationsCoordinates unapprovedLocation= new LocationsCoordinates(tableLocationIDOfInputtedLocation,latCoords, longCoords);
// boolean locationWithinTownBoundaries= checkInputtedCoordsMatchTown(Double.toString(latCoords) ,Double.toString(longCoords), toBeApprovedLocationTown);
// if (locationWithinTownBoundaries){
// addLocationCoord(unapprovedLocation);
// return;
//
//
// } else {
// return;}
//
//// for (TownWithTrails town : allTowns){
//// if (Objects.equals(toBeApprovedLocationTown, town.getTownName())){
//
//
// }
//
// }
......
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [2020] [MINHAZ <minhazav@gmail.com>]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
This diff is collapsed.
import { Camera, CameraRenderingOptions, RenderedCamera, RenderingCallbacks } from "./core";
export declare class CameraImpl implements Camera {
private readonly mediaStream;
private constructor();
render(parentElement: HTMLElement, options: CameraRenderingOptions, callbacks: RenderingCallbacks): Promise<RenderedCamera>;
static create(videoConstraints: MediaTrackConstraints): Promise<Camera>;
}
export interface CameraDevice {
id: string;
label: string;
}
export interface CameraCapability<T> {
isSupported(): boolean;
apply(value: T): Promise<void>;
value(): T | null;
}
export interface RangeCameraCapability extends CameraCapability<number> {
min(): number;
max(): number;
step(): number;
}
export interface BooleanCameraCapability extends CameraCapability<boolean> {
}
export interface CameraCapabilities {
zoomFeature(): RangeCameraCapability;
torchFeature(): BooleanCameraCapability;
}
export type OnRenderSurfaceReady = (viewfinderWidth: number, viewfinderHeight: number) => void;
export interface RenderingCallbacks {
onRenderSurfaceReady: OnRenderSurfaceReady;
}
export interface RenderedCamera {
getSurface(): HTMLVideoElement;
pause(): void;
resume(onResumeCallback: () => void): void;
isPaused(): boolean;
close(): Promise<void>;
getRunningTrackCapabilities(): MediaTrackCapabilities;
getRunningTrackSettings(): MediaTrackSettings;
applyVideoConstraints(constraints: MediaTrackConstraints): Promise<void>;
getCapabilities(): CameraCapabilities;
}
export interface CameraRenderingOptions {
aspectRatio?: number;
}
export interface Camera {
render(parentElement: HTMLElement, options: CameraRenderingOptions, callbacks: RenderingCallbacks): Promise<RenderedCamera>;
}
import { Camera } from "./core";
export declare class CameraFactory {
static failIfNotSupported(): Promise<CameraFactory>;
private constructor();
create(videoConstraints: MediaTrackConstraints): Promise<Camera>;
}
export declare class CameraPermissions {
static hasPermissions(): Promise<boolean>;
}
import { CameraDevice } from "./core";
export declare class CameraRetriever {
static retrieve(): Promise<Array<CameraDevice>>;
private static rejectWithError;
private static isHttpsOrLocalhost;
private static getCamerasFromMediaDevices;
private static getCamerasFromMediaStreamTrack;
}
import { Camera, CameraRenderingOptions, RenderedCamera, RenderingCallbacks } from "./core";
export declare class CameraImpl implements Camera {
private readonly mediaStream;
private constructor();
render(parentElement: HTMLElement, options: CameraRenderingOptions, callbacks: RenderingCallbacks): Promise<RenderedCamera>;
static create(videoConstraints: MediaTrackConstraints): Promise<Camera>;
}
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CameraImpl = void 0;
var AbstractCameraCapability = (function () {
function AbstractCameraCapability(name, track) {
this.name = name;
this.track = track;
}
AbstractCameraCapability.prototype.isSupported = function () {
if (!this.track.getCapabilities) {
return false;
}
return this.name in this.track.getCapabilities();
};
AbstractCameraCapability.prototype.apply = function (value) {
var constraint = {};
constraint[this.name] = value;
var constraints = { advanced: [constraint] };
return this.track.applyConstraints(constraints);
};
AbstractCameraCapability.prototype.value = function () {
var settings = this.track.getSettings();
if (this.name in settings) {
var settingValue = settings[this.name];
return settingValue;
}
return null;
};
return AbstractCameraCapability;
}());
var AbstractRangeCameraCapability = (function (_super) {
__extends(AbstractRangeCameraCapability, _super);
function AbstractRangeCameraCapability(name, track) {
return _super.call(this, name, track) || this;
}
AbstractRangeCameraCapability.prototype.min = function () {
return this.getCapabilities().min;
};
AbstractRangeCameraCapability.prototype.max = function () {
return this.getCapabilities().max;
};
AbstractRangeCameraCapability.prototype.step = function () {
return this.getCapabilities().step;
};
AbstractRangeCameraCapability.prototype.apply = function (value) {
var constraint = {};
constraint[this.name] = value;
var constraints = { advanced: [constraint] };
return this.track.applyConstraints(constraints);
};
AbstractRangeCameraCapability.prototype.getCapabilities = function () {
this.failIfNotSupported();
var capabilities = this.track.getCapabilities();
var capability = capabilities[this.name];
return {
min: capability.min,
max: capability.max,
step: capability.step,
};
};
AbstractRangeCameraCapability.prototype.failIfNotSupported = function () {
if (!this.isSupported()) {
throw new Error("".concat(this.name, " capability not supported"));
}
};
return AbstractRangeCameraCapability;
}(AbstractCameraCapability));
var ZoomFeatureImpl = (function (_super) {
__extends(ZoomFeatureImpl, _super);
function ZoomFeatureImpl(track) {
return _super.call(this, "zoom", track) || this;
}
return ZoomFeatureImpl;
}(AbstractRangeCameraCapability));
var TorchFeatureImpl = (function (_super) {
__extends(TorchFeatureImpl, _super);
function TorchFeatureImpl(track) {
return _super.call(this, "torch", track) || this;
}
return TorchFeatureImpl;
}(AbstractCameraCapability));
var CameraCapabilitiesImpl = (function () {
function CameraCapabilitiesImpl(track) {
this.track = track;
}
CameraCapabilitiesImpl.prototype.zoomFeature = function () {
return new ZoomFeatureImpl(this.track);
};
CameraCapabilitiesImpl.prototype.torchFeature = function () {
return new TorchFeatureImpl(this.track);
};
return CameraCapabilitiesImpl;
}());
var RenderedCameraImpl = (function () {
function RenderedCameraImpl(parentElement, mediaStream, callbacks) {
this.isClosed = false;
this.parentElement = parentElement;
this.mediaStream = mediaStream;
this.callbacks = callbacks;
this.surface = this.createVideoElement(this.parentElement.clientWidth);
parentElement.append(this.surface);
}
RenderedCameraImpl.prototype.createVideoElement = function (width) {
var videoElement = document.createElement("video");
videoElement.style.width = "".concat(width, "px");
videoElement.style.display = "block";
videoElement.muted = true;
videoElement.setAttribute("muted", "true");
videoElement.playsInline = true;
return videoElement;
};
RenderedCameraImpl.prototype.setupSurface = function () {
var _this = this;
this.surface.onabort = function () {
throw "RenderedCameraImpl video surface onabort() called";
};
this.surface.onerror = function () {
throw "RenderedCameraImpl video surface onerror() called";
};
var onVideoStart = function () {
var videoWidth = _this.surface.clientWidth;
var videoHeight = _this.surface.clientHeight;
_this.callbacks.onRenderSurfaceReady(videoWidth, videoHeight);
_this.surface.removeEventListener("playing", onVideoStart);
};
this.surface.addEventListener("playing", onVideoStart);
this.surface.srcObject = this.mediaStream;
this.surface.play();
};
RenderedCameraImpl.create = function (parentElement, mediaStream, options, callbacks) {
return __awaiter(this, void 0, void 0, function () {
var renderedCamera, aspectRatioConstraint;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
renderedCamera = new RenderedCameraImpl(parentElement, mediaStream, callbacks);
if (!options.aspectRatio) return [3, 2];
aspectRatioConstraint = {
aspectRatio: options.aspectRatio
};
return [4, renderedCamera.getFirstTrackOrFail().applyConstraints(aspectRatioConstraint)];
case 1:
_a.sent();
_a.label = 2;
case 2:
renderedCamera.setupSurface();
return [2, renderedCamera];
}
});
});
};
RenderedCameraImpl.prototype.failIfClosed = function () {
if (this.isClosed) {
throw "The RenderedCamera has already been closed.";
}
};
RenderedCameraImpl.prototype.getFirstTrackOrFail = function () {
this.failIfClosed();
if (this.mediaStream.getVideoTracks().length === 0) {
throw "No video tracks found";
}
return this.mediaStream.getVideoTracks()[0];
};
RenderedCameraImpl.prototype.pause = function () {
this.failIfClosed();
this.surface.pause();
};
RenderedCameraImpl.prototype.resume = function (onResumeCallback) {
this.failIfClosed();
var $this = this;
var onVideoResume = function () {
setTimeout(onResumeCallback, 200);
$this.surface.removeEventListener("playing", onVideoResume);
};
this.surface.addEventListener("playing", onVideoResume);
this.surface.play();
};
RenderedCameraImpl.prototype.isPaused = function () {
this.failIfClosed();
return this.surface.paused;
};
RenderedCameraImpl.prototype.getSurface = function () {
this.failIfClosed();
return this.surface;
};
RenderedCameraImpl.prototype.getRunningTrackCapabilities = function () {
return this.getFirstTrackOrFail().getCapabilities();
};
RenderedCameraImpl.prototype.getRunningTrackSettings = function () {
return this.getFirstTrackOrFail().getSettings();
};
RenderedCameraImpl.prototype.applyVideoConstraints = function (constraints) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
if ("aspectRatio" in constraints) {
throw "Changing 'aspectRatio' in run-time is not yet supported.";
}
return [2, this.getFirstTrackOrFail().applyConstraints(constraints)];
});
});
};
RenderedCameraImpl.prototype.close = function () {
if (this.isClosed) {
return Promise.resolve();
}
var $this = this;
return new Promise(function (resolve, _) {
var tracks = $this.mediaStream.getVideoTracks();
var tracksToClose = tracks.length;
var tracksClosed = 0;
$this.mediaStream.getVideoTracks().forEach(function (videoTrack) {
$this.mediaStream.removeTrack(videoTrack);
videoTrack.stop();
++tracksClosed;
if (tracksClosed >= tracksToClose) {
$this.isClosed = true;
$this.parentElement.removeChild($this.surface);
resolve();
}
});
});
};
RenderedCameraImpl.prototype.getCapabilities = function () {
return new CameraCapabilitiesImpl(this.getFirstTrackOrFail());
};
return RenderedCameraImpl;
}());
var CameraImpl = (function () {
function CameraImpl(mediaStream) {
this.mediaStream = mediaStream;
}
CameraImpl.prototype.render = function (parentElement, options, callbacks) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2, RenderedCameraImpl.create(parentElement, this.mediaStream, options, callbacks)];
});
});
};
CameraImpl.create = function (videoConstraints) {
return __awaiter(this, void 0, void 0, function () {
var constraints, mediaStream;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!navigator.mediaDevices) {
throw "navigator.mediaDevices not supported";
}
constraints = {
audio: false,
video: videoConstraints
};
return [4, navigator.mediaDevices.getUserMedia(constraints)];
case 1:
mediaStream = _a.sent();
return [2, new CameraImpl(mediaStream)];
}
});
});
};
return CameraImpl;
}());
exports.CameraImpl = CameraImpl;
//# sourceMappingURL=core-impl.js.map
\ No newline at end of file
{"version":3,"file":"core-impl.js","sourceRoot":"","sources":["../../../src/camera/core-impl.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA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AuC;;;;;;wBAEvD,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE;4BACzB,MAAM,sCAAsC,CAAC;yBAChD;wBACG,WAAW,GAA2B;4BACtC,KAAK,EAAE,KAAK;4BACZ,KAAK,EAAE,gBAAgB;yBAC1B,CAAC;wBAEgB,WAAM,SAAS,CAAC,YAAY,CAAC,YAAY,CACvD,WAAW,CAAC,EAAA;;wBADZ,WAAW,GAAG,SACF;wBAChB,WAAO,IAAI,UAAU,CAAC,WAAW,CAAC,EAAC;;;;KACtC;IACL,iBAAC;AAAD,CAAC,AA9BD,IA8BC;AA9BY,gCAAU"}
\ No newline at end of file
export interface CameraDevice {
id: string;
label: string;
}
export interface CameraCapability<T> {
isSupported(): boolean;
apply(value: T): Promise<void>;
value(): T | null;
}
export interface RangeCameraCapability extends CameraCapability<number> {
min(): number;
max(): number;
step(): number;
}
export interface BooleanCameraCapability extends CameraCapability<boolean> {
}
export interface CameraCapabilities {
zoomFeature(): RangeCameraCapability;
torchFeature(): BooleanCameraCapability;
}
export type OnRenderSurfaceReady = (viewfinderWidth: number, viewfinderHeight: number) => void;
export interface RenderingCallbacks {
onRenderSurfaceReady: OnRenderSurfaceReady;
}
export interface RenderedCamera {
getSurface(): HTMLVideoElement;
pause(): void;
resume(onResumeCallback: () => void): void;
isPaused(): boolean;
close(): Promise<void>;
getRunningTrackCapabilities(): MediaTrackCapabilities;
getRunningTrackSettings(): MediaTrackSettings;
applyVideoConstraints(constraints: MediaTrackConstraints): Promise<void>;
getCapabilities(): CameraCapabilities;
}
export interface CameraRenderingOptions {
aspectRatio?: number;
}
export interface Camera {
render(parentElement: HTMLElement, options: CameraRenderingOptions, callbacks: RenderingCallbacks): Promise<RenderedCamera>;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=core.js.map
\ No newline at end of file
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../../src/camera/core.ts"],"names":[],"mappings":""}
\ No newline at end of file
import { Camera } from "./core";
export declare class CameraFactory {
static failIfNotSupported(): Promise<CameraFactory>;
private constructor();
create(videoConstraints: MediaTrackConstraints): Promise<Camera>;
}
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CameraFactory = void 0;
var core_impl_1 = require("./core-impl");
var CameraFactory = (function () {
function CameraFactory() {
}
CameraFactory.failIfNotSupported = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
if (!navigator.mediaDevices) {
throw "navigator.mediaDevices not supported";
}
return [2, new CameraFactory()];
});
});
};
CameraFactory.prototype.create = function (videoConstraints) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2, core_impl_1.CameraImpl.create(videoConstraints)];
});
});
};
return CameraFactory;
}());
exports.CameraFactory = CameraFactory;
//# sourceMappingURL=factories.js.map
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment