* Adds react-native-windows UWP support This adds basic support for capturing photos and videos from either the front or back panel cameras, with some support for video quality, orientation, etc. This also uses ZXing.Net to support barcode scanning from the video preview frames. It also supports torch and flash modes. Videos and photos saved to disk (or camera roll / temporary folder) also supports some file metadata (e.g., lat/long). There are a number of features that have not yet been implemented: - Support `playSoundOnCapture` for default shutter sounds - Add orientation metadata properties on photo / video files - Support all barcode formats in ZXing.Net - Additional file metadata (like description) - Photo quality settings with `quality` and `jpegQuality` - Image post-processing with `mirrorImage` and `fixOrientation` - Support event listeners for `onZoomChanged` & `onFocusChanged` - Device authorization checks as supported on iOS * Updating NuGet packages for RNCamera UWP project * Minor fixes for legacy RCTCamera implementation * hack(CameraForView): default camera to any when panel info not available
73 lines
2.3 KiB
C#
73 lines
2.3 KiB
C#
using System;
|
|
using Windows.Foundation.Collections;
|
|
|
|
namespace RNCamera
|
|
{
|
|
static class GeolocationHelper
|
|
{
|
|
public static PropertySet GetLatitudeProperties(double latitude)
|
|
{
|
|
// Latitude and longitude are returned as double precision numbers,
|
|
// but we want to convert to degrees/minutes/seconds format.
|
|
var latRefText = (latitude >= 0) ? "N" : "S";
|
|
var latDeg = Math.Floor(Math.Abs(latitude));
|
|
var latMin = Math.Floor((Math.Abs(latitude) - latDeg) * 60);
|
|
var latSec = (Math.Abs(latitude) - latDeg - latMin / 60) * 3600;
|
|
|
|
uint[] latitudeNumerator =
|
|
{
|
|
(uint)latDeg,
|
|
(uint)latMin,
|
|
(uint)(latSec * 10000)
|
|
};
|
|
|
|
uint[] denominator =
|
|
{
|
|
1,
|
|
1,
|
|
10000
|
|
};
|
|
|
|
return new PropertySet
|
|
{
|
|
{ "System.GPS.LatitudeRef", latRefText },
|
|
{ "System.GPS.LatitudeNumerator", latitudeNumerator },
|
|
{ "System.GPS.LatitudeDenominator", denominator },
|
|
};
|
|
}
|
|
|
|
public static PropertySet GetLongitudeProperties(double longitude)
|
|
{
|
|
// Latitude and longitude are returned as double precision numbers,
|
|
// but we want to convert to degrees/minutes/seconds format.
|
|
var longRefText = (longitude >= 0) ? "E" : "W";
|
|
var longDeg = Math.Floor(Math.Abs(longitude));
|
|
var longMin = Math.Floor((Math.Abs(longitude) - longDeg) * 60);
|
|
var longSec = (Math.Abs(longitude) - longDeg - longMin / 60) * 3600;
|
|
|
|
uint[] longitudeNumerator =
|
|
{
|
|
(uint)longDeg,
|
|
(uint)longMin,
|
|
(uint)(longSec * 10000)
|
|
};
|
|
|
|
uint[] denominator =
|
|
{
|
|
1,
|
|
1,
|
|
10000
|
|
};
|
|
|
|
var pset = new PropertySet();
|
|
|
|
return new PropertySet
|
|
{
|
|
{ "System.GPS.LongitudeRef", longRefText },
|
|
{ "System.GPS.LongitudeNumerator", longitudeNumerator },
|
|
{ "System.GPS.LongitudeDenominator", denominator },
|
|
};
|
|
}
|
|
}
|
|
}
|