diff options
| author | mirror <mirror@localhost> | 2026-11-22 08:41:00 +0900 |
|---|---|---|
| committer | mirror <mirror@localhost> | 2026-11-22 08:41:00 +0900 |
| commit | 449d8b74bd6d9dae98a07254cdfad677b920e7b0 (patch) | |
| tree | c131c3528c4d517f56e19b854a7453fedb097d40 /lib/widgets/viewer/info | |
| download | aves-src-master.tar.gz aves-src-master.zip | |
Diffstat (limited to 'lib/widgets/viewer/info')
25 files changed, 7021 insertions, 0 deletions
diff --git a/lib/widgets/viewer/info/basic_section.dart b/lib/widgets/viewer/info/basic_section.dart new file mode 100644 index 0000000..09cf91f --- /dev/null +++ b/lib/widgets/viewer/info/basic_section.dart @@ -0,0 +1,397 @@ +import 'package:aves/app_mode.dart'; +import 'package:aves/image_providers/app_icon_image_provider.dart'; +import 'package:aves/model/app_inventory.dart'; +import 'package:aves/model/dynamic_albums.dart'; +import 'package:aves/model/entry/entry.dart'; +import 'package:aves/model/entry/extensions/favourites.dart'; +import 'package:aves/model/entry/extensions/multipage.dart'; +import 'package:aves/model/entry/extensions/props.dart'; +import 'package:aves/model/favourites.dart'; +import 'package:aves/model/filters/covered/stored_album.dart'; +import 'package:aves/model/filters/covered/tag.dart'; +import 'package:aves/model/filters/date.dart'; +import 'package:aves/model/filters/favourite.dart'; +import 'package:aves/model/filters/mime.dart'; +import 'package:aves/model/filters/rating.dart'; +import 'package:aves/model/filters/type.dart'; +import 'package:aves/model/filters/weekday.dart'; +import 'package:aves/model/settings/settings.dart'; +import 'package:aves/model/source/collection_lens.dart'; +import 'package:aves/ref/mime_types.dart'; +import 'package:aves/services/common/services.dart'; +import 'package:aves/theme/colors.dart'; +import 'package:aves/theme/format.dart'; +import 'package:aves/utils/file_utils.dart'; +import 'package:aves/utils/time_utils.dart'; +import 'package:aves/view/view.dart'; +import 'package:aves/widgets/common/action_controls/quick_choosers/rate_button.dart'; +import 'package:aves/widgets/common/action_controls/quick_choosers/tag_button.dart'; +import 'package:aves/widgets/common/extensions/build_context.dart'; +import 'package:aves/widgets/common/identity/aves_filter_chip.dart'; +import 'package:aves/widgets/viewer/action/entry_info_action_delegate.dart'; +import 'package:aves/widgets/viewer/info/common.dart'; +import 'package:aves_model/aves_model.dart'; +import 'package:collection/collection.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'package:provider/provider.dart'; + +class BasicSection extends StatefulWidget { + final AvesEntry entry; + final CollectionLens? collection; + final EntryInfoActionDelegate actionDelegate; + final ValueNotifier<bool> isScrollingNotifier; + final ValueNotifier<EntryAction?> isEditingMetadataNotifier; + final AFilterCallback onFilterSelection; + + const BasicSection({ + super.key, + required this.entry, + this.collection, + required this.actionDelegate, + required this.isScrollingNotifier, + required this.isEditingMetadataNotifier, + required this.onFilterSelection, + }); + + @override + State<BasicSection> createState() => _BasicSectionState(); +} + +class _BasicSectionState extends State<BasicSection> { + final FocusNode _chipFocusNode = FocusNode(); + + CollectionLens? get collection => widget.collection; + + EntryInfoActionDelegate get actionDelegate => widget.actionDelegate; + + @override + void initState() { + super.initState(); + _registerWidget(widget); + _onScrollingChanged(); + } + + @override + void didUpdateWidget(covariant BasicSection oldWidget) { + super.didUpdateWidget(oldWidget); + _unregisterWidget(oldWidget); + _registerWidget(widget); + } + + @override + void dispose() { + _unregisterWidget(widget); + _chipFocusNode.dispose(); + super.dispose(); + } + + void _registerWidget(BasicSection widget) { + widget.isScrollingNotifier.addListener(_onScrollingChanged); + } + + void _unregisterWidget(BasicSection widget) { + widget.isScrollingNotifier.removeListener(_onScrollingChanged); + } + + @override + Widget build(BuildContext context) { + final entry = widget.entry; + return AnimatedBuilder( + animation: entry.metadataChangeNotifier, + builder: (context, child) { + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _BasicInfo(entry: entry), + Focus( + focusNode: _chipFocusNode, + skipTraversal: true, + canRequestFocus: false, + child: _buildChips(context), + ), + _buildEditButtons(context), + ], + ); + }); + } + + Widget _buildChips(BuildContext context) { + final entry = widget.entry; + final tags = entry.tags.toList()..sort(compareAsciiUpperCaseNatural); + final dateTime = entry.bestDate; + final album = entry.directory; + final filters = { + MimeFilter(entry.mimeType), + if (entry.isAnimated) TypeFilter.animated, + if (entry.isGeotiff) TypeFilter.geotiff, + if (entry.isHdr) TypeFilter.hdr, + if (entry.isMotionPhoto) TypeFilter.motionPhoto, + if (entry.isRaw) TypeFilter.raw, + if (entry.isImage && entry.is360) TypeFilter.panorama, + if (entry.isPureVideo && entry.is360) TypeFilter.sphericalVideo, + if (entry.isPureVideo && !entry.is360) MimeFilter.video, + if (dateTime != null) ...[DateFilter(DateLevel.ymd, dateTime.date), WeekDayFilter(dateTime.weekday)], + if (album != null) StoredAlbumFilter(album, collection?.source.getStoredAlbumDisplayName(context, album)), + ...dynamicAlbums.all.where((v) => v.test(entry)).toSet(), + if (entry.rating != 0) RatingFilter(entry.rating), + ...tags.map(TagFilter.new), + }; + return AnimatedBuilder( + animation: favourites, + builder: (context, child) { + final effectiveFilters = [ + ...filters, + if (entry.isFavourite) FavouriteFilter.instance, + ]..sort(); + + return Padding( + padding: const EdgeInsets.symmetric(horizontal: AvesFilterChip.outlineWidth / 2) + const EdgeInsets.only(top: 8), + child: Wrap( + spacing: 8, + runSpacing: 8, + children: effectiveFilters + .map((filter) => AvesFilterChip( + filter: filter, + onTap: widget.onFilterSelection, + )) + .toList(), + ), + ); + }, + ); + } + + Widget _buildEditButtons(BuildContext context) { + final appMode = context.watch<ValueNotifier<AppMode>>().value; + final entry = widget.entry; + final children = [ + EntryAction.editRating, + EntryAction.editTags, + ] + .where((v) => actionDelegate.isVisible( + appMode: appMode, + targetEntry: entry, + action: v, + )) + .where((v) => actionDelegate.canApply(entry, v)) + .map((v) => _buildEditMetadataButton(context, v)) + .toList(); + + return children.isEmpty + ? const SizedBox() + : TooltipTheme( + data: TooltipTheme.of(context).copyWith( + preferBelow: false, + ), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: AvesFilterChip.outlineWidth / 2) + const EdgeInsets.only(top: 8), + child: Wrap( + spacing: 8, + runSpacing: 8, + children: children, + ), + ), + ); + } + + Widget _buildEditMetadataButton(BuildContext context, EntryAction action) { + final entry = widget.entry; + return ValueListenableBuilder<EntryAction?>( + valueListenable: widget.isEditingMetadataNotifier, + builder: (context, editingAction, child) { + final isEditing = editingAction != null; + final onPressed = isEditing ? null : () => actionDelegate.onActionSelected(context, entry, collection, action); + Widget button; + switch (action) { + case EntryAction.editRating: + button = RateButton( + blurred: false, + onChooserValue: (rating) => actionDelegate.quickRate(context, entry, rating), + onPressed: onPressed, + ); + case EntryAction.editTags: + button = TagButton( + blurred: false, + onChooserValue: (filter) => actionDelegate.quickTag(context, entry, filter), + onPressed: onPressed, + ); + default: + button = IconButton( + icon: action.getIcon(), + onPressed: onPressed, + tooltip: action.getText(context), + ); + } + return Stack( + children: [ + DecoratedBox( + decoration: BoxDecoration( + border: Border.fromBorderSide(BorderSide( + color: isEditing ? Theme.of(context).disabledColor : context.select<AvesColorsData, Color>((v) => v.neutral), + width: AvesFilterChip.outlineWidth, + )), + borderRadius: const BorderRadius.all(Radius.circular(AvesFilterChip.defaultRadius)), + ), + child: button, + ), + Positioned.fill( + child: Visibility( + visible: editingAction == action, + child: const Padding( + padding: EdgeInsets.all(1.0), + child: CircularProgressIndicator( + strokeWidth: AvesFilterChip.outlineWidth, + ), + ), + ), + ), + ], + ); + }, + ); + } + + void _onScrollingChanged() { + if (!widget.isScrollingNotifier.value) { + if (settings.useTvLayout) { + // using `autofocus` while scrolling seems to fail for widget built offscreen + // so we give focus to this page when the screen is no longer scrolling + _chipFocusNode.children.firstOrNull?.requestFocus(); + } + } + } +} + +class _BasicInfo extends StatefulWidget { + final AvesEntry entry; + + const _BasicInfo({ + required this.entry, + }); + + @override + State<_BasicInfo> createState() => _BasicInfoState(); +} + +class _BasicInfoState extends State<_BasicInfo> { + Future<String?> _ownerPackageLoader = SynchronousFuture(null); + Future<void> _appNameLoader = SynchronousFuture(null); + + AvesEntry get entry => widget.entry; + + static const ownerPackageNamePropKey = 'owner_package_name'; + static const iconSize = 20.0; + + @override + void initState() { + super.initState(); + if (!entry.trashed && entry.isMediaStoreMediaContent) { + _ownerPackageLoader = metadataFetchService.hasContentResolverProp(ownerPackageNamePropKey).then((exists) { + return exists ? metadataFetchService.getContentResolverProp(entry, ownerPackageNamePropKey) : SynchronousFuture(null); + }); + final isViewerMode = context.read<ValueNotifier<AppMode>>().value == AppMode.view; + if (isViewerMode && settings.isInstalledAppAccessAllowed) { + _appNameLoader = appInventory.initAppNames(); + } + } + } + + @override + Widget build(BuildContext context) { + final l10n = context.l10n; + final infoUnknown = l10n.viewerInfoUnknown; + final locale = context.locale; + final use24hour = MediaQuery.alwaysUse24HourFormatOf(context); + + // TODO TLAD line break on all characters for the following fields when this is fixed: https://github.com/flutter/flutter/issues/61081 + // inserting ZWSP (\u200B) between characters does help, but it messes with width and height computation (another Flutter issue) + final title = entry.bestTitle ?? infoUnknown; + final date = entry.bestDate; + final dateText = date != null ? formatDateTime(date, locale, use24hour) : infoUnknown; + final showResolution = !entry.isSvg && entry.isSized; + final sizeText = entry.sizeBytes != null ? formatFileSize(locale, entry.sizeBytes!) : infoUnknown; + final path = entry.path; + + return FutureBuilder<String?>( + future: _ownerPackageLoader, + builder: (context, snapshot) { + final ownerPackage = snapshot.data; + return FutureBuilder<void>( + future: _appNameLoader, + builder: (context, snapshot) { + return InfoRowGroup( + info: { + l10n.viewerInfoLabelTitle: title, + l10n.viewerInfoLabelDate: dateText, + if (entry.isVideo) ..._buildVideoRows(context), + if (showResolution) l10n.viewerInfoLabelResolution: context.applyDirectionality(getRasterResolutionText(locale)), + l10n.viewerInfoLabelSize: context.applyDirectionality(sizeText), + if (!entry.trashed) l10n.viewerInfoLabelUri: entry.uri, + if (path != null) l10n.viewerInfoLabelPath: path, + if (ownerPackage != null) l10n.viewerInfoLabelOwner: ownerPackage, + }, + spanBuilders: { + l10n.viewerInfoLabelOwner: _ownerHandler(ownerPackage), + }, + ); + }, + ); + }, + ); + } + + Map<String, String> _buildVideoRows(BuildContext context) { + return { + context.l10n.viewerInfoLabelDuration: entry.durationText, + }; + } + + InfoValueSpanBuilder _ownerHandler(String? ownerPackage) { + if (ownerPackage == null) return (context, key, value) => []; + + final appName = appInventory.getCurrentAppName(ownerPackage) ?? ownerPackage; + return (context, key, value) => [ + WidgetSpan( + alignment: PlaceholderAlignment.middle, + child: Padding( + padding: const EdgeInsetsDirectional.only(start: 2, end: 4), + child: ConstrainedBox( + // use constraints instead of sizing `Image`, + // so that it can collapse when handling an empty image + constraints: const BoxConstraints( + maxWidth: iconSize, + maxHeight: iconSize, + ), + child: Image( + image: AppIconImage( + packageName: ownerPackage, + size: iconSize, + ), + ), + ), + ), + ), + TextSpan( + text: appName, + style: InfoRowGroup.valueStyle, + ), + ]; + } + + String getRasterResolutionText(String locale) { + var s = entry.getResolutionText(locale); + + // guess whether this is a photo, according to file type + final isPhoto = [MimeTypes.heic, MimeTypes.heif, MimeTypes.jpeg, MimeTypes.tiff].contains(entry.mimeType) || entry.isRaw; + if (isPhoto) { + final megaPixels = (entry.width * entry.height / 1000000).round(); + if (megaPixels > 0) { + s += ' • ${NumberFormat('0', locale).format(megaPixels)} MP'; + } + } + + return s; + } +} diff --git a/lib/widgets/viewer/info/color_section.dart b/lib/widgets/viewer/info/color_section.dart new file mode 100644 index 0000000..abecb67 --- /dev/null +++ b/lib/widgets/viewer/info/color_section.dart @@ -0,0 +1,124 @@ +import 'dart:async'; +import 'dart:isolate'; +import 'dart:math'; +import 'dart:ui' as ui; + +import 'package:aves/model/entry/entry.dart'; +import 'package:aves/model/entry/extensions/images.dart'; +import 'package:aves/theme/durations.dart'; +import 'package:aves/theme/icons.dart'; +import 'package:aves/widgets/common/basic/color_indicator.dart'; +import 'package:aves/widgets/viewer/info/common.dart'; +import 'package:flex_color_picker/flex_color_picker.dart' as flex; +import 'package:flutter/material.dart'; +import 'package:flutter/scheduler.dart'; +import 'package:flutter_staggered_animations/flutter_staggered_animations.dart'; +import 'package:palette_generator/palette_generator.dart'; +import 'package:provider/provider.dart'; + +class ColorSectionSliver extends StatefulWidget { + final AvesEntry entry; + + const ColorSectionSliver({super.key, required this.entry}); + + @override + State<ColorSectionSliver> createState() => _ColorSectionSliverState(); +} + +class _ColorSectionSliverState extends State<ColorSectionSliver> { + late final Future<List<Color>> _paletteLoader; + + @override + void initState() { + super.initState(); + final provider = widget.entry.getThumbnail(extent: min(200, widget.entry.displaySize.longestSide)); + _paletteLoader = _loadPalette(provider); + } + + @override + Widget build(BuildContext context) { + return SliverToBoxAdapter( + child: FutureBuilder<List<Color>>( + future: _paletteLoader, + builder: (context, snapshot) { + final colors = snapshot.data; + if (colors == null || colors.isEmpty) return const SizedBox(); + + final durations = context.watch<DurationsData>(); + return Wrap( + alignment: WrapAlignment.center, + children: AnimationConfiguration.toStaggeredList( + duration: durations.staggeredAnimation, + delay: durations.staggeredAnimationDelay * timeDilation, + childAnimationBuilder: (child) => SlideAnimation( + verticalOffset: 50.0, + child: FadeInAnimation( + child: child, + ), + ), + children: [ + const SectionRow(icon: AIcons.palette), + ...colors.map( + (v) => Padding( + padding: const EdgeInsets.all(8), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + ColorIndicator(value: v), + const SizedBox(width: 8), + Directionality( + textDirection: TextDirection.ltr, + child: SelectableText( + '#${v.hex}', + style: const TextStyle(fontFamily: 'monospace'), + ), + ), + ], + ), + ), + ), + ], + ), + ); + }, + ), + ); + } + + // `PaletteGenerator.fromImage()` directly blocks the main isolate, + // so we use another isolate to compute the palette + Future<List<Color>> _loadPalette(ImageProvider provider) async { + final stream = provider.resolve(ImageConfiguration.empty); + final imageCompleter = Completer<ui.Image>(); + late ImageStreamListener listener; + listener = ImageStreamListener((info, _) { + stream.removeListener(listener); + imageCompleter.complete(info.image); + }); + stream.addListener(listener); + final image = await imageCompleter.future; + final imageData = await image.toByteData(); + if (imageData == null) { + throw StateError('Failed to encode the image.'); + } + + final encodedImage = EncodedImage( + imageData, + width: image.width, + height: image.height, + ); + final generator = await _getPaletteGenerator(encodedImage); + return generator.paletteColors.map((v) => v.color).toList(); + } + + // the isolate does not start unless called from a static method + static Future<PaletteGenerator> _getPaletteGenerator(EncodedImage encodedImage) { + // `Isolate.run()` closure supports passing `EncodedImage` but not `ui.Image` + return Isolate.run(() => PaletteGenerator.fromByteData( + encodedImage, + maximumColorCount: 10, + // do not use the default palette filter + filters: [], + )); + } +} diff --git a/lib/widgets/viewer/info/common.dart b/lib/widgets/viewer/info/common.dart new file mode 100644 index 0000000..16c4e9d --- /dev/null +++ b/lib/widgets/viewer/info/common.dart @@ -0,0 +1,198 @@ +import 'dart:math'; + +import 'package:aves/widgets/common/basic/link_chip.dart'; +import 'package:aves/widgets/common/identity/aves_filter_chip.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/gestures.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; + +class SectionRow extends StatelessWidget { + final IconData icon; + + const SectionRow({ + super.key, + required this.icon, + }); + + @override + Widget build(BuildContext context) { + const dim = 32.0; + Widget buildDivider() => const SizedBox( + width: dim, + child: Divider( + thickness: AvesFilterChip.outlineWidth, + ), + ); + return Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + buildDivider(), + Padding( + padding: const EdgeInsets.all(16), + child: Icon( + icon, + size: dim, + ), + ), + buildDivider(), + ], + ); + } +} + +class InfoRowGroup extends StatefulWidget { + final Map<String, String> info; + final int maxValueLength; + final Map<String, InfoValueSpanBuilder> spanBuilders; + + static const int defaultMaxValueLength = 140; + static const double keyValuePadding = 16; + static const double fontSize = 13; + static const valueStyle = TextStyle(fontSize: fontSize); + static final _keyStyle = valueStyle.copyWith(height: 2.0); + + static TextStyle keyStyle(BuildContext context) { + final theme = Theme.of(context); + return theme.textTheme.bodySmall!.copyWith(color: theme.colorScheme.onSurfaceVariant).merge(_keyStyle); + } + + const InfoRowGroup({ + super.key, + required this.info, + this.maxValueLength = defaultMaxValueLength, + Map<String, InfoValueSpanBuilder>? spanBuilders, + }) : spanBuilders = spanBuilders ?? const {}; + + @override + State<InfoRowGroup> createState() => _InfoRowGroupState(); + + static InfoValueSpanBuilder linkSpanBuilder({ + required String Function(BuildContext context) linkText, + required void Function(BuildContext context) onTap, + }) { + return (context, key, value) { + value = linkText(context); + // `colorScheme.secondary` is overridden upstream as an `ExpansionTileCard` theming workaround, + // so we use `colorScheme.primary` instead + final linkColor = Theme.of(context).colorScheme.primary; + + return [ + WidgetSpan( + child: LinkChip( + text: value, + color: linkColor, + textStyle: InfoRowGroup.valueStyle, + // open link on tap + onTap: () => onTap(context), + ), + alignment: PlaceholderAlignment.middle, + ), + ]; + }; + } +} + +class _InfoRowGroupState extends State<InfoRowGroup> { + final List<String> _expandedKeys = []; + + Map<String, String> get keyValues => widget.info; + + int get maxValueLength => widget.maxValueLength; + + Map<String, InfoValueSpanBuilder> get spanBuilders => widget.spanBuilders; + + @override + Widget build(BuildContext context) { + if (keyValues.isEmpty) return const SizedBox(); + + final _keyStyle = InfoRowGroup.keyStyle(context); + + // compute the size of keys and space in order to align values + final textScaler = MediaQuery.textScalerOf(context); + final keySizes = Map.fromEntries(keyValues.keys.map((key) => MapEntry(key, _getSpanWidth(TextSpan(text: _buildTextValue(key), style: _keyStyle), textScaler)))); + + final lastKey = keyValues.keys.last; + return LayoutBuilder( + builder: (context, constraints) { + // find longest key below threshold + final maxBaseValueX = constraints.maxWidth / 3; + final baseValueX = keySizes.values.where((size) => size < maxBaseValueX).fold(0.0, max); + + return SelectableText.rich( + TextSpan( + children: keyValues.entries.expand( + (kv) { + final key = kv.key; + final value = kv.value; + final customSpanBuilder = spanBuilders[key]; + final spanBuilder = customSpanBuilder ?? _buildTextValueSpans; + final thisSpaceSize = max(0.0, (baseValueX - keySizes[key]!)) + InfoRowGroup.keyValuePadding; + + InlineSpan paddingSpan; + if (customSpanBuilder != null) { + // add padding using hair spaces instead of a straightforward `SizedBox` in a `WidgetSpan`, + // because ordering of multiple `WidgetSpan`s (e.g. with owner app icon) in Bidi context is tricky + final baseSpaceWidth = _getSpanWidth(TextSpan(text: '\u200A' * 100, style: _keyStyle), textScaler); + final spaceCount = (100 * thisSpaceSize / baseSpaceWidth).round(); + paddingSpan = TextSpan(text: '\u200A' * spaceCount); + } else { + final textScaleFactor = textScaler.scale(thisSpaceSize) / thisSpaceSize; + paddingSpan = WidgetSpan( + child: SizedBox( + width: thisSpaceSize / textScaleFactor, + // as of Flutter v3.0.0, the underline decoration from the following `TextSpan` + // is applied to the `WidgetSpan` too, so we add a dummy `Text` as a workaround + child: const Text(''), + ), + ); + } + + return [ + TextSpan(text: _buildTextValue(key), style: _keyStyle), + paddingSpan, + ...spanBuilder(context, key, value), + if (key != lastKey) const TextSpan(text: '\n'), + ]; + }, + ).toList(), + ), + style: InfoRowGroup.valueStyle, + ); + }, + ); + } + + double _getSpanWidth(TextSpan span, TextScaler textScaler) { + final paragraph = RenderParagraph( + span, + textDirection: TextDirection.ltr, + textScaler: textScaler, + )..layout(const BoxConstraints(), parentUsesSize: true); + final width = paragraph.getMaxIntrinsicWidth(double.infinity); + paragraph.dispose(); + return width; + } + + List<InlineSpan> _buildTextValueSpans(BuildContext context, String key, String value) { + GestureRecognizer? recognizer; + + // long values are clipped, and made expandable by tapping them + final showPreviewOnly = maxValueLength > 0 && value.length > maxValueLength && !_expandedKeys.contains(key); + if (showPreviewOnly) { + value = '${value.substring(0, maxValueLength)}…'; + // show full value on tap + recognizer = TapGestureRecognizer()..onTap = () => setState(() => _expandedKeys.add(key)); + } + + return [TextSpan(text: _buildTextValue(value), recognizer: recognizer)]; + } + + // each text span embeds and pops a Bidi isolate, + // so that layout of the spans follows the directionality of the locale + // (e.g. keys on the right for RTL locale, whatever the key intrinsic directionality) + // and each span respects the directionality of its inner text only + String _buildTextValue(String value) => '${Unicode.FSI}$value${Unicode.PDI}'; +} + +typedef InfoValueSpanBuilder = List<InlineSpan> Function(BuildContext context, String key, String value); diff --git a/lib/widgets/viewer/info/embedded/embedded_data_opener.dart b/lib/widgets/viewer/info/embedded/embedded_data_opener.dart new file mode 100644 index 0000000..917fa63 --- /dev/null +++ b/lib/widgets/viewer/info/embedded/embedded_data_opener.dart @@ -0,0 +1,89 @@ +import 'dart:async'; + +import 'package:aves/model/entry/entry.dart'; +import 'package:aves/model/entry/extensions/keys.dart'; +import 'package:aves/ref/mime_types.dart'; +import 'package:aves/services/common/services.dart'; +import 'package:aves/widgets/common/action_mixins/feedback.dart'; +import 'package:aves/widgets/common/behaviour/routes.dart'; +import 'package:aves/widgets/common/extensions/build_context.dart'; +import 'package:aves/widgets/dialogs/aves_dialog.dart'; +import 'package:aves/widgets/viewer/entry_viewer_page.dart'; +import 'package:aves/widgets/viewer/info/embedded/notifications.dart'; +import 'package:flutter/material.dart'; + +class EmbeddedDataOpener extends StatelessWidget with FeedbackMixin { + final bool enabled; + final AvesEntry entry; + final Widget child; + + const EmbeddedDataOpener({ + super.key, + required this.enabled, + required this.entry, + required this.child, + }); + + @override + Widget build(BuildContext context) { + return NotificationListener<OpenEmbeddedDataNotification>( + onNotification: (notification) { + if (enabled) { + _openEmbeddedData(context, notification); + return true; + } + return false; + }, + child: child, + ); + } + + Future<void> _openEmbeddedData(BuildContext context, OpenEmbeddedDataNotification notification) async { + late Map fields; + switch (notification.source) { + case EmbeddedDataSource.googleDevice: + fields = await embeddedDataService.extractGoogleDeviceItem(entry, notification.dataUri!); + case EmbeddedDataSource.motionPhotoVideo: + fields = await embeddedDataService.extractMotionPhotoVideo(entry); + case EmbeddedDataSource.mpf: + fields = await embeddedDataService.extractJpegMpfItem(entry, notification.mpfId!); + case EmbeddedDataSource.videoCover: + fields = await embeddedDataService.extractVideoEmbeddedPicture(entry); + case EmbeddedDataSource.xmp: + fields = await embeddedDataService.extractXmpDataProp(entry, notification.props, notification.mimeType); + } + AvesEntry.normalizeMimeTypeFields(fields); + final mimeType = fields[EntryFields.mimeType] as String?; + final uri = fields[EntryFields.uri] as String?; + if (mimeType == null || uri == null) { + showFeedback(context, FeedbackType.warn, context.l10n.viewerInfoOpenEmbeddedFailureFeedback); + return; + } + + if (!MimeTypes.isImage(mimeType) && !MimeTypes.isVideo(mimeType)) { + // open with another app + unawaited(appService.open(uri, mimeType, forceChooser: true).then((success) { + if (!success) { + // fallback to sharing, so that the file can be saved somewhere + appService.shareSingle(uri, mimeType).then((success) { + if (!success) showNoMatchingAppDialog(context); + }); + } + })); + return; + } + + _openTempEntry(context, AvesEntry.fromMap(fields)); + } + + void _openTempEntry(BuildContext context, AvesEntry tempEntry) { + Navigator.maybeOf(context)?.push( + TransparentMaterialPageRoute( + settings: const RouteSettings(name: EntryViewerPage.routeName), + pageBuilder: (context, a, sa) => EntryViewerPage( + initialEntry: tempEntry, + ), + ), + ); + } +} diff --git a/lib/widgets/viewer/info/embedded/notifications.dart b/lib/widgets/viewer/info/embedded/notifications.dart new file mode 100644 index 0000000..b8401f2 --- /dev/null +++ b/lib/widgets/viewer/info/embedded/notifications.dart @@ -0,0 +1,54 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; + +enum EmbeddedDataSource { googleDevice, motionPhotoVideo, mpf, videoCover, xmp } + +@immutable +class OpenEmbeddedDataNotification extends Notification { + final EmbeddedDataSource source; + final List<dynamic>? props; + final String? mimeType, dataUri; + final int? mpfId; + + const OpenEmbeddedDataNotification._private({ + required this.source, + this.props, + this.mimeType, + this.dataUri, + this.mpfId, + }); + + factory OpenEmbeddedDataNotification.googleDevice({ + required String dataUri, + }) => + OpenEmbeddedDataNotification._private( + source: EmbeddedDataSource.googleDevice, + dataUri: dataUri, + ); + + factory OpenEmbeddedDataNotification.motionPhotoVideo() => const OpenEmbeddedDataNotification._private( + source: EmbeddedDataSource.motionPhotoVideo, + ); + + factory OpenEmbeddedDataNotification.mpf(int id) => OpenEmbeddedDataNotification._private( + source: EmbeddedDataSource.mpf, + mpfId: id, + ); + + factory OpenEmbeddedDataNotification.videoCover() => const OpenEmbeddedDataNotification._private( + source: EmbeddedDataSource.videoCover, + ); + + factory OpenEmbeddedDataNotification.xmp({ + required List<dynamic> props, + required String mimeType, + }) => + OpenEmbeddedDataNotification._private( + source: EmbeddedDataSource.xmp, + props: props, + mimeType: mimeType, + ); + + @override + String toString() => '$runtimeType#${shortHash(this)}{source=$source, props=$props, mimeType=$mimeType, dataUri=$dataUri, index=$mpfId}'; +} diff --git a/lib/widgets/viewer/info/info_app_bar.dart b/lib/widgets/viewer/info/info_app_bar.dart new file mode 100644 index 0000000..566b13d --- /dev/null +++ b/lib/widgets/viewer/info/info_app_bar.dart @@ -0,0 +1,127 @@ +import 'package:aves/app_mode.dart'; +import 'package:aves/model/entry/entry.dart'; +import 'package:aves/model/entry/extensions/props.dart'; +import 'package:aves/model/selection.dart'; +import 'package:aves/model/settings/enums/accessibility_animations.dart'; +import 'package:aves/model/settings/settings.dart'; +import 'package:aves/model/source/collection_lens.dart'; +import 'package:aves/theme/icons.dart'; +import 'package:aves/theme/themes.dart'; +import 'package:aves/view/view.dart'; +import 'package:aves/widgets/common/app_bar/app_bar_title.dart'; +import 'package:aves/widgets/common/app_bar/sliver_app_bar_title.dart'; +import 'package:aves/widgets/common/basic/font_size_icon_theme.dart'; +import 'package:aves/widgets/common/basic/popup/menu_row.dart'; +import 'package:aves/widgets/common/extensions/build_context.dart'; +import 'package:aves/widgets/common/search/route.dart'; +import 'package:aves/widgets/viewer/action/entry_info_action_delegate.dart'; +import 'package:aves/widgets/viewer/info/info_search_delegate.dart'; +import 'package:aves/widgets/viewer/info/metadata/metadata_dir.dart'; +import 'package:aves_model/aves_model.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/scheduler.dart'; +import 'package:provider/provider.dart'; + +class InfoAppBar extends StatelessWidget { + final AvesEntry entry; + final CollectionLens? collection; + final EntryInfoActionDelegate actionDelegate; + final ValueNotifier<Map<String, MetadataDirectory>> metadataNotifier; + final VoidCallback onBackPressed; + + const InfoAppBar({ + super.key, + required this.entry, + required this.collection, + required this.actionDelegate, + required this.metadataNotifier, + required this.onBackPressed, + }); + + @override + Widget build(BuildContext context) { + final appMode = context.watch<ValueNotifier<AppMode>>().value; + bool isVisible(EntryAction action) => actionDelegate.isVisible( + appMode: appMode, + targetEntry: entry, + action: action, + ); + final commonActions = EntryActions.commonMetadataActions.where(isVisible); + final formatSpecificActions = EntryActions.formatSpecificMetadataActions.where(isVisible); + final useTvLayout = settings.useTvLayout; + final animations = context.select<Settings, AccessibilityAnimations>((v) => v.accessibilityAnimations); + return SliverAppBar( + leading: useTvLayout + ? null + : FontSizeIconTheme( + child: IconButton( + // key is expected by test driver + key: const Key('back-button'), + icon: const Icon(AIcons.goUp), + onPressed: onBackPressed, + tooltip: context.l10n.viewerInfoBackToViewerTooltip, + ), + ), + automaticallyImplyLeading: false, + title: SliverAppBarTitleWrapper( + child: InteractiveAppBarTitle( + onTap: () => _goToSearch(context), + child: Text(context.l10n.viewerInfoPageTitle), + ), + ), + actions: useTvLayout + ? [] + : [ + IconButton( + icon: const Icon(AIcons.search), + onPressed: () => _goToSearch(context), + tooltip: MaterialLocalizations.of(context).searchFieldLabel, + ), + if (entry.canEdit) + PopupMenuButton<EntryAction>( + itemBuilder: (context) => [ + ...commonActions.map((action) => _toMenuItem(context, action, enabled: actionDelegate.canApply(entry, action))), + if (formatSpecificActions.isNotEmpty) ...[ + const PopupMenuDivider(), + ...formatSpecificActions.map((action) => _toMenuItem(context, action, enabled: actionDelegate.canApply(entry, action))), + ], + if (isVisible(EntryAction.debug)) ...[ + const PopupMenuDivider(), + _toMenuItem(context, EntryAction.debug, enabled: true), + ] + ], + onSelected: (action) async { + // wait for the popup menu to hide before proceeding with the action + await Future.delayed(animations.popUpAnimationDelay * timeDilation); + await actionDelegate.onActionSelected(context, entry, collection, action); + }, + popUpAnimationStyle: animations.popUpAnimationStyle, + ), + ].map((v) => FontSizeIconTheme(child: v)).toList(), + floating: true, + ); + } + + PopupMenuItem<EntryAction> _toMenuItem(BuildContext context, EntryAction action, {required bool enabled}) { + return PopupMenuItem( + value: action, + enabled: enabled, + child: MenuRow(text: action.getText(context), icon: action.getIcon()), + ); + } + + void _goToSearch(BuildContext context) { + final isSelecting = context.read<Selection<AvesEntry>?>()?.isSelecting ?? false; + Navigator.maybeOf(context)?.push( + SearchPageRoute( + delegate: InfoSearchDelegate( + searchFieldLabel: context.l10n.viewerInfoSearchFieldLabel, + searchFieldStyle: Themes.searchFieldStyle(context), + entry: entry, + metadataNotifier: metadataNotifier, + isSelecting: isSelecting, + ), + ), + ); + } +} diff --git a/lib/widgets/viewer/info/info_page.dart b/lib/widgets/viewer/info/info_page.dart new file mode 100644 index 0000000..0326d63 --- /dev/null +++ b/lib/widgets/viewer/info/info_page.dart @@ -0,0 +1,292 @@ +import 'dart:async'; + +import 'package:aves/model/entry/entry.dart'; +import 'package:aves/model/entry/extensions/multipage.dart'; +import 'package:aves/model/filters/filters.dart'; +import 'package:aves/model/selection.dart'; +import 'package:aves/model/settings/settings.dart'; +import 'package:aves/model/source/collection_lens.dart'; +import 'package:aves/theme/durations.dart'; +import 'package:aves/widgets/common/basic/insets.dart'; +import 'package:aves/widgets/common/basic/scaffold.dart'; +import 'package:aves/widgets/common/basic/tv_edge_focus.dart'; +import 'package:aves/widgets/viewer/action/entry_info_action_delegate.dart'; +import 'package:aves/widgets/viewer/controls/notifications.dart'; +import 'package:aves/widgets/viewer/info/basic_section.dart'; +import 'package:aves/widgets/viewer/info/color_section.dart'; +import 'package:aves/widgets/viewer/info/embedded/embedded_data_opener.dart'; +import 'package:aves/widgets/viewer/info/info_app_bar.dart'; +import 'package:aves/widgets/viewer/info/location_section.dart'; +import 'package:aves/widgets/viewer/info/metadata/metadata_dir.dart'; +import 'package:aves/widgets/viewer/info/metadata/metadata_section.dart'; +import 'package:aves/widgets/viewer/multipage/conductor.dart'; +import 'package:aves/widgets/viewer/page_entry_builder.dart'; +import 'package:aves_model/aves_model.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class InfoPage extends StatefulWidget { + final CollectionLens? collection; + final ValueNotifier<AvesEntry?> entryNotifier; + final ValueNotifier<bool> isScrollingNotifier; + + const InfoPage({ + super.key, + required this.collection, + required this.entryNotifier, + required this.isScrollingNotifier, + }); + + @override + State<StatefulWidget> createState() => _InfoPageState(); +} + +class _InfoPageState extends State<InfoPage> { + final ScrollController _scrollController = ScrollController(); + bool _scrollStartFromTop = false; + + static const splitScreenWidthThreshold = 600; + + @override + void dispose() { + _scrollController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return AvesScaffold( + body: GestureAreaProtectorStack( + child: SafeArea( + bottom: false, + child: NotificationListener<ScrollNotification>( + onNotification: _handleTopScroll, + child: ValueListenableBuilder<AvesEntry?>( + valueListenable: widget.entryNotifier, + builder: (context, mainEntry, child) { + if (mainEntry == null) return const SizedBox(); + + final isSelecting = context.select<Selection<AvesEntry>?, bool>((v) => v?.isSelecting ?? false); + Widget _buildContent({AvesEntry? pageEntry}) { + final targetEntry = pageEntry ?? mainEntry; + return EmbeddedDataOpener( + enabled: !isSelecting, + entry: targetEntry, + child: _InfoPageContent( + collection: widget.collection, + entry: targetEntry, + isScrollingNotifier: widget.isScrollingNotifier, + scrollController: _scrollController, + split: MediaQuery.sizeOf(context).width > splitScreenWidthThreshold, + goToViewer: _goToViewer, + ), + ); + } + + return mainEntry.isStack + ? PageEntryBuilder( + multiPageController: context.read<MultiPageConductor>().getController(mainEntry), + builder: (pageEntry) => _buildContent(pageEntry: pageEntry), + ) + : _buildContent(); + }, + ), + ), + ), + ), + resizeToAvoidBottomInset: false, + ); + } + + bool _handleTopScroll(ScrollNotification notification) { + if (notification is ScrollStartNotification) { + final metrics = notification.metrics; + _scrollStartFromTop = metrics.pixels == metrics.minScrollExtent; + } + if (_scrollStartFromTop) { + if (notification is ScrollUpdateNotification) { + _scrollStartFromTop = notification.scrollDelta! < 0; + } else if (notification is ScrollEndNotification) { + _scrollStartFromTop = false; + } else if (notification is OverscrollNotification) { + if (notification.overscroll < 0) { + _goToViewer(); + _scrollStartFromTop = false; + } + } + } + return false; + } + + void _goToViewer() { + ShowImageNotification().dispatch(context); + _scrollController.animateTo( + 0, + duration: ADurations.pageTransitionLoose, + curve: Curves.easeInOut, + ); + } +} + +class _InfoPageContent extends StatefulWidget { + final CollectionLens? collection; + final AvesEntry entry; + final ValueNotifier<bool> isScrollingNotifier; + final ScrollController scrollController; + final bool split; + final VoidCallback goToViewer; + + const _InfoPageContent({ + required this.collection, + required this.entry, + required this.isScrollingNotifier, + required this.scrollController, + required this.split, + required this.goToViewer, + }); + + @override + State<_InfoPageContent> createState() => _InfoPageContentState(); +} + +class _InfoPageContentState extends State<_InfoPageContent> { + final Set<StreamSubscription> _subscriptions = {}; + late EntryInfoActionDelegate _actionDelegate; + final ValueNotifier<Map<String, MetadataDirectory>> _metadataNotifier = ValueNotifier({}); + final ValueNotifier<EntryAction?> _isEditingMetadataNotifier = ValueNotifier(null); + + static const horizontalPadding = EdgeInsets.symmetric(horizontal: 8); + + CollectionLens? get collection => widget.collection; + + AvesEntry get entry => widget.entry; + + @override + void initState() { + super.initState(); + _registerWidget(widget); + } + + @override + void didUpdateWidget(covariant _InfoPageContent oldWidget) { + super.didUpdateWidget(oldWidget); + + if (oldWidget.entry != widget.entry) { + _unregisterWidget(oldWidget); + _registerWidget(widget); + } + } + + @override + void dispose() { + _metadataNotifier.dispose(); + _isEditingMetadataNotifier.dispose(); + _unregisterWidget(widget); + super.dispose(); + } + + void _registerWidget(_InfoPageContent widget) { + _actionDelegate = EntryInfoActionDelegate(); + _subscriptions.add(_actionDelegate.eventStream.listen(_onActionDelegateEvent)); + } + + void _unregisterWidget(_InfoPageContent widget) { + _subscriptions + ..forEach((sub) => sub.cancel()) + ..clear(); + } + + @override + Widget build(BuildContext context) { + final basicSection = BasicSection( + entry: entry, + collection: collection, + actionDelegate: _actionDelegate, + isScrollingNotifier: widget.isScrollingNotifier, + isEditingMetadataNotifier: _isEditingMetadataNotifier, + onFilterSelection: _onFilterSelection, + ); + final locationAtTop = widget.split && entry.hasGps; + final locationSection = LocationSection( + collection: collection, + entry: entry, + showTitle: !locationAtTop, + isScrollingNotifier: widget.isScrollingNotifier, + onFilterSelection: _onFilterSelection, + ); + final basicAndLocationSliver = locationAtTop + ? SliverToBoxAdapter( + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded(child: basicSection), + const SizedBox(width: 8), + Expanded(child: locationSection), + ], + ), + ) + : SliverList( + delegate: SliverChildListDelegate.fixed( + [ + basicSection, + locationSection, + ], + ), + ); + + return NotificationListener<SelectFilterNotification>( + onNotification: (notification) { + _onFilterSelection(notification.filter); + return true; + }, + child: CustomScrollView( + controller: widget.scrollController, + slivers: [ + const SliverToBoxAdapter( + child: TvEdgeFocus(), + ), + InfoAppBar( + entry: entry, + collection: collection, + actionDelegate: _actionDelegate, + metadataNotifier: _metadataNotifier, + onBackPressed: widget.goToViewer, + ), + SliverPadding( + padding: horizontalPadding + const EdgeInsets.only(top: 8), + sliver: basicAndLocationSliver, + ), + SliverPadding( + padding: horizontalPadding + const EdgeInsets.only(bottom: 8), + sliver: MetadataSectionSliver( + entry: entry, + metadataNotifier: _metadataNotifier, + ), + ), + if (!settings.useTvLayout) + SliverPadding( + padding: horizontalPadding + const EdgeInsets.only(bottom: 8), + sliver: ColorSectionSliver(entry: entry), + ), + const BottomPaddingSliver(), + ], + ), + ); + } + + void _onActionDelegateEvent(ActionEvent<EntryAction> event) { + Future.delayed(ADurations.dialogTransitionLoose).then((_) { + if (!mounted) return; + if (event is ActionStartedEvent) { + _isEditingMetadataNotifier.value = event.action; + } else if (event is ActionEndedEvent) { + _isEditingMetadataNotifier.value = null; + } + }); + } + + void _onFilterSelection(CollectionFilter filter) { + if (!mounted) return; + SelectFilterNotification(filter).dispatch(context); + } +} diff --git a/lib/widgets/viewer/info/info_search_delegate.dart b/lib/widgets/viewer/info/info_search_delegate.dart new file mode 100644 index 0000000..868d8fd --- /dev/null +++ b/lib/widgets/viewer/info/info_search_delegate.dart @@ -0,0 +1,133 @@ +import 'package:aves/model/entry/entry.dart'; +import 'package:aves/theme/icons.dart'; +import 'package:aves/widgets/common/extensions/build_context.dart'; +import 'package:aves/widgets/common/identity/empty.dart'; +import 'package:aves/widgets/common/providers/media_query_data_provider.dart'; +import 'package:aves/widgets/common/search/delegate.dart'; +import 'package:aves/widgets/viewer/info/embedded/embedded_data_opener.dart'; +import 'package:aves/widgets/viewer/info/metadata/metadata_dir.dart'; +import 'package:aves/widgets/viewer/info/metadata/metadata_dir_tile.dart'; +import 'package:collection/collection.dart'; +import 'package:flutter/material.dart'; + +class InfoSearchDelegate extends AvesSearchDelegate { + final AvesEntry entry; + final ValueNotifier<Map<String, MetadataDirectory>> metadataNotifier; + final bool isSelecting; + + Map<String, MetadataDirectory> get metadata => metadataNotifier.value; + + static const pageRouteName = '/info/search'; + + InfoSearchDelegate({ + required super.searchFieldLabel, + required super.searchFieldStyle, + required this.entry, + required this.metadataNotifier, + required this.isSelecting, + }) : super( + routeName: pageRouteName, + ); + + @override + Widget? buildLeading(BuildContext context) { + return IconButton( + icon: AnimatedIcon( + icon: AnimatedIcons.menu_arrow, + progress: transitionAnimation, + ), + onPressed: () => Navigator.maybeOf(context)?.pop(), + tooltip: MaterialLocalizations.of(context).backButtonTooltip, + ); + } + + @override + List<Widget>? buildActions(BuildContext context) { + return [ + if (query.isNotEmpty) + IconButton( + icon: const Icon(AIcons.clear), + onPressed: () { + query = ''; + showSuggestions(context); + }, + tooltip: context.l10n.clearTooltip, + ), + ]; + } + + @override + Widget buildSuggestions(BuildContext context) { + final l10n = context.l10n; + final suggestions = { + l10n.viewerInfoSearchSuggestionDate: 'date or time or when -timer -uptime -exposure -timeline -verbatim', + l10n.viewerInfoSearchSuggestionDescription: 'description or title or comment or textual or abstract or object name -line', + l10n.viewerInfoSearchSuggestionDimensions: 'width or height or dimension or framesize or imagelength', + l10n.viewerInfoSearchSuggestionResolution: 'resolution', + l10n.viewerInfoSearchSuggestionRights: 'rights or copyright or attribution or license or artist or creator or by-line or credit -tool', + }; + return ListView( + children: suggestions.entries + .map((kv) => ListTile( + title: Text(kv.key), + onTap: () { + query = kv.value; + showResults(context); + }, + )) + .toList(), + ); + } + + @override + Widget buildResults(BuildContext context) { + if (query.isEmpty) { + showSuggestions(context); + return const SizedBox(); + } + + final queryParts = query.toUpperCase().split(' ')..removeWhere((s) => s.isEmpty); + final queryExcludeIncludeGroups = groupBy<String, bool>(queryParts, (s) => s.startsWith('-')); + final queryExcludeAll = (queryExcludeIncludeGroups[true] ?? []).map((s) => s.substring(1)); + final queryIncludeAny = (queryExcludeIncludeGroups[false] ?? []).join(' ').split(' OR '); + + bool testKey(String key) { + key = key.toUpperCase(); + return queryIncludeAny.any(key.contains) && queryExcludeAll.every((q) => !key.contains(q)); + } + + final filteredMetadata = Map.fromEntries(metadata.entries.map((kv) { + final filteredDir = kv.value.filterKeys(testKey); + return MapEntry(kv.key, filteredDir); + })); + + final tiles = filteredMetadata.entries + .where((kv) => kv.value.tags.isNotEmpty) + .map((kv) => MetadataDirTile( + entry: entry, + title: kv.key, + dir: kv.value, + initiallyExpanded: true, + showThumbnails: false, + )) + .toList(); + return MediaQueryDataProvider( + child: SafeArea( + child: tiles.isEmpty + ? EmptyContent( + icon: AIcons.info, + text: context.l10n.viewerInfoSearchEmpty, + ) + : EmbeddedDataOpener( + enabled: !isSelecting, + entry: entry, + child: ListView.builder( + padding: const EdgeInsets.all(8), + itemBuilder: (context, index) => tiles[index], + itemCount: tiles.length, + ), + ), + ), + ); + } +} diff --git a/lib/widgets/viewer/info/location_section.dart b/lib/widgets/viewer/info/location_section.dart new file mode 100644 index 0000000..0119430 --- /dev/null +++ b/lib/widgets/viewer/info/location_section.dart @@ -0,0 +1,231 @@ +import 'package:aves/app_mode.dart'; +import 'package:aves/model/entry/entry.dart'; +import 'package:aves/model/entry/extensions/location.dart'; +import 'package:aves/model/filters/covered/location.dart'; +import 'package:aves/model/settings/enums/coordinate_format.dart'; +import 'package:aves/model/settings/settings.dart'; +import 'package:aves/model/source/collection_lens.dart'; +import 'package:aves/services/common/services.dart'; +import 'package:aves/theme/icons.dart'; +import 'package:aves/widgets/common/extensions/build_context.dart'; +import 'package:aves/widgets/common/identity/aves_filter_chip.dart'; +import 'package:aves/widgets/common/map/geo_map.dart'; +import 'package:aves/widgets/common/map/map_action_delegate.dart'; +import 'package:aves/widgets/common/providers/map_theme_provider.dart'; +import 'package:aves/widgets/dialogs/aves_dialog.dart'; +import 'package:aves/widgets/map/map_page.dart'; +import 'package:aves/widgets/viewer/info/common.dart'; +import 'package:aves_map/aves_map.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class LocationSection extends StatefulWidget { + final CollectionLens? collection; + final AvesEntry entry; + final bool showTitle; + final ValueNotifier<bool> isScrollingNotifier; + final AFilterCallback onFilterSelection; + + const LocationSection({ + super.key, + required this.collection, + required this.entry, + required this.showTitle, + required this.isScrollingNotifier, + required this.onFilterSelection, + }); + + @override + State<LocationSection> createState() => _LocationSectionState(); +} + +class _LocationSectionState extends State<LocationSection> { + final AvesMapController _mapController = AvesMapController(); + + CollectionLens? get collection => widget.collection; + + AvesEntry get entry => widget.entry; + + @override + void initState() { + super.initState(); + _registerWidget(widget); + } + + @override + void didUpdateWidget(covariant LocationSection oldWidget) { + super.didUpdateWidget(oldWidget); + _unregisterWidget(oldWidget); + _registerWidget(widget); + } + + @override + void dispose() { + _unregisterWidget(widget); + super.dispose(); + } + + void _registerWidget(LocationSection widget) { + widget.entry.metadataChangeNotifier.addListener(_onMetadataChanged); + } + + void _unregisterWidget(LocationSection widget) { + widget.entry.metadataChangeNotifier.removeListener(_onMetadataChanged); + } + + @override + Widget build(BuildContext context) { + if (!entry.hasGps) return const SizedBox(); + + final canNavigate = context.select<ValueNotifier<AppMode>, bool>((v) => v.value.canNavigate); + return NotificationListener( + onNotification: (notification) { + if (notification is OpenMapAppNotification) { + _openMapApp(); + return true; + } + return false; + }, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (widget.showTitle) const SectionRow(icon: AIcons.location), + MapTheme( + interactive: false, + showCoordinateFilter: false, + navigationButton: canNavigate ? MapNavigationButton.map : MapNavigationButton.none, + visualDensity: VisualDensity.compact, + mapHeight: 200, + child: GeoMap( + controller: _mapController, + entries: [entry], + availableSize: MediaQuery.sizeOf(context), + isAnimatingNotifier: widget.isScrollingNotifier, + onUserZoomChange: (zoom) => settings.infoMapZoom = zoom.roundToDouble(), + onMarkerTap: collection != null && canNavigate ? (location, entry) => _openMapPage(context) : null, + openMapPage: collection != null ? _openMapPage : null, + ), + ), + AnimatedBuilder( + animation: entry.addressChangeNotifier, + builder: (context, child) { + final filters = <LocationFilter>[]; + if (entry.hasAddress) { + final address = entry.addressDetails!; + final country = address.countryName; + if (country != null && country.isNotEmpty) filters.add(LocationFilter(LocationLevel.country, '$country${LocationFilter.locationSeparator}${address.countryCode}')); + final state = address.stateName; + if (state != null && state.isNotEmpty) filters.add(LocationFilter(LocationLevel.state, '$state${LocationFilter.locationSeparator}${address.stateCode}')); + final place = address.place; + if (place != null && place.isNotEmpty) filters.add(LocationFilter(LocationLevel.place, place)); + } + + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _AddressInfoGroup(entry: entry), + if (filters.isNotEmpty) + Padding( + padding: const EdgeInsets.symmetric(horizontal: AvesFilterChip.outlineWidth / 2) + const EdgeInsets.only(top: 8), + child: Wrap( + spacing: 8, + runSpacing: 8, + children: filters + .map((filter) => AvesFilterChip( + filter: filter, + onTap: widget.onFilterSelection, + )) + .toList(), + ), + ), + ], + ); + }, + ), + ], + ), + ); + } + + Future<void> _openMapPage(BuildContext context) async { + final baseCollection = collection; + if (baseCollection == null) return; + + final mapCollection = baseCollection.copyWith( + listenToSource: true, + fixedSelection: baseCollection.sortedEntries.where((entry) => entry.hasGps).toList(), + ); + await Navigator.maybeOf(context)?.push( + MaterialPageRoute( + settings: const RouteSettings(name: MapPage.routeName), + builder: (context) => MapPage( + collection: mapCollection, + initialEntry: entry, + ), + ), + ); + } + + Future<void> _openMapApp() async { + final latLng = entry.latLng; + if (latLng != null) { + await appService.openMap(latLng).then((success) { + if (!success) showNoMatchingAppDialog(context); + }); + } + } + + void _onMetadataChanged() { + setState(() {}); + + final location = entry.latLng; + if (location != null) { + _mapController.notifyMarkerLocationChange(); + _mapController.moveTo(location); + } + } +} + +class _AddressInfoGroup extends StatefulWidget { + final AvesEntry entry; + + const _AddressInfoGroup({required this.entry}); + + @override + State<_AddressInfoGroup> createState() => _AddressInfoGroupState(); +} + +class _AddressInfoGroupState extends State<_AddressInfoGroup> { + late Future<String?> _addressLineLoader; + + AvesEntry get entry => widget.entry; + + @override + void initState() { + super.initState(); + _addressLineLoader = availability.canLocatePlaces.then((connected) { + if (connected) { + return entry.findAddressLine(geocoderLocale: settings.appliedLocale); + } + return null; + }); + } + + @override + Widget build(BuildContext context) { + return FutureBuilder<String?>( + future: _addressLineLoader, + builder: (context, snapshot) { + final fullAddress = !snapshot.hasError && snapshot.connectionState == ConnectionState.done ? snapshot.data : null; + final address = fullAddress ?? entry.shortAddress; + final l10n = context.l10n; + return InfoRowGroup( + info: { + l10n.viewerInfoLabelCoordinates: settings.coordinateFormat.format(context, entry.latLng!), + if (address.isNotEmpty) l10n.viewerInfoLabelAddress: address, + }, + ); + }, + ); + } +} diff --git a/lib/widgets/viewer/info/metadata/geotiff.dart b/lib/widgets/viewer/info/metadata/geotiff.dart new file mode 100644 index 0000000..fb647b9 --- /dev/null +++ b/lib/widgets/viewer/info/metadata/geotiff.dart @@ -0,0 +1,3847 @@ +import 'package:aves/ref/metadata/geotiff.dart'; + +class GeoTiffDirectory { + // TODO TLAD [geotiff] avoid string-based match + static int? tagForName(String name) { + switch (name) { + case 'Model Type': + return GeoTiffKeys.modelType; + case 'Raster Type': + return GeoTiffKeys.rasterType; + case 'Geographic Type': + return GeoTiffKeys.geographicType; + case 'Geographic Geodetic Datum': + return GeoTiffKeys.geogGeodeticDatum; + case 'Geographic Angular Units': + return GeoTiffKeys.geogAngularUnits; + case 'Geographic Ellipsoid': + return GeoTiffKeys.geogEllipsoid; + case 'Projected Coordinate System Type': + return GeoTiffKeys.projCSType; + case 'Projection': + return GeoTiffKeys.projection; + case 'Projected Coordinate Transform': + return GeoTiffKeys.projCoordinateTransform; + case 'Projection Linear Units': + return GeoTiffKeys.projLinearUnits; + case 'Vertical Units': + return GeoTiffKeys.verticalUnits; + default: + return null; + } + } + + static String formatValue(int? tag, String v) { + switch (tag) { + case GeoTiffKeys.modelType: + return getModelTypeDescription(v); + case GeoTiffKeys.rasterType: + return getRasterTypeDescription(v); + case GeoTiffKeys.geographicType: + return getGeographicTypeDescription(v); + case GeoTiffKeys.geogGeodeticDatum: + return getGeogGeodeticDatumDescription(v); + case GeoTiffKeys.geogEllipsoid: + return getGeogEllipsoidDescription(v); + case GeoTiffKeys.projCSType: + return getProjCSTypeDescription(v); + case GeoTiffKeys.projection: + return getProjectionDescription(v); + case GeoTiffKeys.projCoordinateTransform: + return getProjCoordinateTransformDescription(v); + case GeoTiffKeys.projLinearUnits: + case GeoTiffKeys.geogAngularUnits: + case GeoTiffKeys.verticalUnits: + return getGeoTiffUnitsDescription(v); + default: + return v; + } + } + + static String getModelTypeDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 1: + return 'Projected'; + case 2: + return 'Geographic'; + case 3: + return 'Geocentric'; + case 32767: + return 'User Defined'; + default: + return 'Unknown ($value)'; + } + } + + static String getRasterTypeDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 1: + return 'Pixel Is Area'; + case 2: + return 'Pixel Is Point'; + case 32767: + return 'User Defined'; + default: + return 'Unknown ($value)'; + } + } + + static String getGeographicTypeDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 4001: + return 'Airy 1830'; + case 4002: + return 'Airy Modified 1849'; + case 4003: + return 'Australian National Spheroid'; + case 4004: + return 'Bessel 1841'; + case 4005: + return 'Bessel Modified'; + case 4006: + return 'Bessel Namibia'; + case 4007: + return 'Clarke 1858'; + case 4008: + return 'Clarke 1866'; + case 4009: + return 'Clarke 1866 Michigan'; + case 4010: + return 'Clarke 1880 Benoit'; + case 4011: + return 'Clarke 1880 IGN'; + case 4012: + return 'Clarke 1880 RGS'; + case 4013: + return 'Clarke 1880 Arc'; + case 4014: + return 'Clarke 1880 SGA 1922'; + case 4015: + return 'Everest 1830 1937 Adjustment'; + case 4016: + return 'Everest 1830 1967 Definition'; + case 4017: + return 'Everest 1830 1975 Definition'; + case 4018: + return 'Everest 1830 Modified'; + case 4019: + return 'GRS 1980'; + case 4020: + return 'Helmert 1906'; + case 4021: + return 'Indonesian National Spheroid'; + case 4022: + return 'International 1924'; + case 4023: + return 'International 1967'; + case 4024: + return 'Krassowsky 1940'; + case 4025: + return 'NWL9D'; + case 4026: + return 'NWL10D'; + case 4027: + return 'Plessis 1817'; + case 4028: + return 'Struve 1860'; + case 4029: + return 'War Office'; + case 4030: + return 'WGS84'; + case 4031: + return 'GEM10C'; + case 4032: + return 'OSU86F'; + case 4033: + return 'OSU91A'; + case 4034: + return 'Clarke 1880'; + case 4035: + return 'Sphere'; + case 4120: + return 'Greek'; + case 4121: + return 'GGRS87'; + case 4123: + return 'KKJ'; + case 4124: + return 'RT90'; + case 4133: + return 'EST92'; + case 4201: + return 'Adindan'; + case 4202: + return 'AGD66'; + case 4203: + return 'AGD84'; + case 4204: + return 'Ain el Abd'; + case 4205: + return 'Afgooye'; + case 4206: + return 'Agadez'; + case 4207: + return 'Lisbon'; + case 4208: + return 'Aratu'; + case 4209: + return 'Arc 1950'; + case 4210: + return 'Arc 1960'; + case 4211: + return 'Batavia'; + case 4212: + return 'Barbados'; + case 4213: + return 'Beduaram'; + case 4214: + return 'Beijing 1954'; + case 4215: + return 'Belge 1950'; + case 4216: + return 'Bermuda 1957'; + case 4217: + return 'Bern 1898'; + case 4218: + return 'Bogota'; + case 4219: + return 'Bukit Rimpah'; + case 4220: + return 'Camacupa'; + case 4221: + return 'Campo Inchauspe'; + case 4222: + return 'Cape'; + case 4223: + return 'Carthage'; + case 4224: + return 'Chua'; + case 4225: + return 'Corrego Alegre'; + case 4226: + return 'Cote d Ivoire'; + case 4227: + return 'Deir ez Zor'; + case 4228: + return 'Douala'; + case 4229: + return 'Egypt 1907'; + case 4230: + return 'ED50'; + case 4231: + return 'ED87'; + case 4232: + return 'Fahud'; + case 4233: + return 'Gandajika 1970'; + case 4234: + return 'Garoua'; + case 4235: + return 'Guyane Francaise'; + case 4236: + return 'Hu Tzu Shan'; + case 4237: + return 'HD72'; + case 4238: + return 'ID74'; + case 4239: + return 'Indian 1954'; + case 4240: + return 'Indian 1975'; + case 4241: + return 'Jamaica 1875'; + case 4242: + return 'JAD69'; + case 4243: + return 'Kalianpur'; + case 4244: + return 'Kandawala'; + case 4245: + return 'Kertau'; + case 4246: + return 'KOC'; + case 4247: + return 'La Canoa'; + case 4248: + return 'PSAD56'; + case 4249: + return 'Lake'; + case 4250: + return 'Leigon'; + case 4251: + return 'Liberia 1964'; + case 4252: + return 'Lome'; + case 4253: + return 'Luzon 1911'; + case 4254: + return 'Hito XVIII 1963'; + case 4255: + return 'Herat North'; + case 4256: + return 'Mahe 1971'; + case 4257: + return 'Makassar'; + case 4258: + return 'EUREF89'; + case 4259: + return 'Malongo 1987'; + case 4260: + return 'Manoca'; + case 4261: + return 'Merchich'; + case 4262: + return 'Massawa'; + case 4263: + return 'Minna'; + case 4264: + return 'Mhast'; + case 4265: + return 'Monte Mario'; + case 4266: + return 'M poraloko'; + case 4267: + return 'NAD27'; + case 4268: + return 'NAD Michigan'; + case 4269: + return 'NAD83'; + case 4270: + return 'Nahrwan 1967'; + case 4271: + return 'Naparima 1972'; + case 4272: + return 'GD49'; + case 4273: + return 'NGO 1948'; + case 4274: + return '73'; + case 4275: + return 'NTF'; + case 4276: + return 'NSWC 9Z 2'; + case 4277: + return 'OSGB 1936'; + case 4278: + return 'OSGB70'; + case 4279: + return 'OS SN80'; + case 4280: + return 'Padang'; + case 4281: + return 'Palestine 1923'; + case 4282: + return 'Pointe Noire'; + case 4283: + return 'GDA94'; + case 4284: + return 'Pulkovo 1942'; + case 4285: + return 'Qatar'; + case 4286: + return 'Qatar 1948'; + case 4287: + return 'Qornoq'; + case 4288: + return 'Loma Quintana'; + case 4289: + return 'Amersfoort'; + case 4290: + return 'RT38'; + case 4291: + return 'SAD69'; + case 4292: + return 'Sapper Hill 1943'; + case 4293: + return 'Schwarzeck'; + case 4294: + return 'Segora'; + case 4295: + return 'Serindung'; + case 4296: + return 'Sudan'; + case 4297: + return 'Tananarive'; + case 4298: + return 'Timbalai 1948'; + case 4299: + return 'TM65'; + case 4300: + return 'TM75'; + case 4301: + return 'Tokyo'; + case 4302: + return 'Trinidad 1903'; + case 4303: + return 'TC 1948'; + case 4304: + return 'Voirol 1875'; + case 4305: + return 'Voirol Unifie'; + case 4306: + return 'Bern 1938'; + case 4307: + return 'Nord Sahara 1959'; + case 4308: + return 'Stockholm 1938'; + case 4309: + return 'Yacare'; + case 4310: + return 'Yoff'; + case 4311: + return 'Zanderij'; + case 4312: + return 'MGI'; + case 4313: + return 'Belge 1972'; + case 4314: + return 'DHDN'; + case 4315: + return 'Conakry 1905'; + case 4317: + return 'Dealul Piscului 1970'; + case 4322: + return 'WGS 72'; + case 4324: + return 'WGS 72BE'; + case 4326: + return 'WGS 84'; + case 4801: + return 'Bern 1898 Bern'; + case 4802: + return 'Bogota Bogota'; + case 4803: + return 'Lisbon Lisbon'; + case 4804: + return 'Makassar Jakarta'; + case 4805: + return 'MGI Ferro'; + case 4806: + return 'Monte Mario Rome'; + case 4807: + return 'NTF Paris'; + case 4808: + return 'Padang Jakarta'; + case 4809: + return 'Belge 1950 Brussels'; + case 4810: + return 'Tananarive Paris'; + case 4811: + return 'Voirol 1875 Paris'; + case 4812: + return 'Voirol Unifie Paris'; + case 4813: + return 'Batavia Jakarta'; + case 4815: + return 'Greek Athens'; + case 4901: + return 'ATF Paris'; + case 4902: + return 'NDG Paris'; + case 32767: + return 'User Defined'; + default: + return 'Unknown ($value)'; + } + } + + static String getGeogGeodeticDatumDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 6001: + return 'Airy 1830'; + case 6002: + return 'Airy Modified 1849'; + case 6003: + return 'Australian National Spheroid'; + case 6004: + return 'Bessel 1841'; + case 6005: + return 'Bessel Modified'; + case 6006: + return 'Bessel Namibia'; + case 6007: + return 'Clarke 1858'; + case 6008: + return 'Clarke 1866'; + case 6009: + return 'Clarke 1866 Michigan'; + case 6010: + return 'Clarke 1880 Benoit'; + case 6011: + return 'Clarke 1880 IGN'; + case 6012: + return 'Clarke 1880 RGS'; + case 6013: + return 'Clarke 1880 Arc'; + case 6014: + return 'Clarke 1880 SGA 1922'; + case 6015: + return 'Everest 1830 1937 Adjustment'; + case 6016: + return 'Everest 1830 1967 Definition'; + case 6017: + return 'Everest 1830 1975 Definition'; + case 6018: + return 'Everest 1830 Modified'; + case 6019: + return 'GRS 1980'; + case 6020: + return 'Helmert 1906'; + case 6021: + return 'Indonesian National Spheroid'; + case 6022: + return 'International 1924'; + case 6023: + return 'International 1967'; + case 6024: + return 'Krassowsky 1960'; + case 6025: + return 'NWL9D'; + case 6026: + return 'NWL10D'; + case 6027: + return 'Plessis 1817'; + case 6028: + return 'Struve 1860'; + case 6029: + return 'War Office'; + case 6030: + return 'WGS84'; + case 6031: + return 'GEM10C'; + case 6032: + return 'OSU86F'; + case 6033: + return 'OSU91A'; + case 6034: + return 'Clarke 1880'; + case 6035: + return 'Sphere'; + case 6201: + return 'Adindan'; + case 6202: + return 'Australian Geodetic Datum 1966'; + case 6203: + return 'Australian Geodetic Datum 1984'; + case 6204: + return 'Ain el Abd 1970'; + case 6205: + return 'Afgooye'; + case 6206: + return 'Agadez'; + case 6207: + return 'Lisbon'; + case 6208: + return 'Aratu'; + case 6209: + return 'Arc 1950'; + case 6210: + return 'Arc 1960'; + case 6211: + return 'Batavia'; + case 6212: + return 'Barbados'; + case 6213: + return 'Beduaram'; + case 6214: + return 'Beijing 1954'; + case 6215: + return 'Reseau National Belge 1950'; + case 6216: + return 'Bermuda 1957'; + case 6217: + return 'Bern 1898'; + case 6218: + return 'Bogota'; + case 6219: + return 'Bukit Rimpah'; + case 6220: + return 'Camacupa'; + case 6221: + return 'Campo Inchauspe'; + case 6222: + return 'Cape'; + case 6223: + return 'Carthage'; + case 6224: + return 'Chua'; + case 6225: + return 'Corrego Alegre'; + case 6226: + return 'Cote d Ivoire'; + case 6227: + return 'Deir ez Zor'; + case 6228: + return 'Douala'; + case 6229: + return 'Egypt 1907'; + case 6230: + return 'European Datum 1950'; + case 6231: + return 'European Datum 1987'; + case 6232: + return 'Fahud'; + case 6233: + return 'Gandajika 1970'; + case 6234: + return 'Garoua'; + case 6235: + return 'Guyane Francaise'; + case 6236: + return 'Hu Tzu Shan'; + case 6237: + return 'Hungarian Datum 1972'; + case 6238: + return 'Indonesian Datum 1974'; + case 6239: + return 'Indian 1954'; + case 6240: + return 'Indian 1975'; + case 6241: + return 'Jamaica 1875'; + case 6242: + return 'Jamaica 1969'; + case 6243: + return 'Kalianpur'; + case 6244: + return 'Kandawala'; + case 6245: + return 'Kertau'; + case 6246: + return 'Kuwait Oil Company'; + case 6247: + return 'La Canoa'; + case 6248: + return 'Provisional S American Datum 1956'; + case 6249: + return 'Lake'; + case 6250: + return 'Leigon'; + case 6251: + return 'Liberia 1964'; + case 6252: + return 'Lome'; + case 6253: + return 'Luzon 1911'; + case 6254: + return 'Hito XVIII 1963'; + case 6255: + return 'Herat North'; + case 6256: + return 'Mahe 1971'; + case 6257: + return 'Makassar'; + case 6258: + return 'European Reference System 1989'; + case 6259: + return 'Malongo 1987'; + case 6260: + return 'Manoca'; + case 6261: + return 'Merchich'; + case 6262: + return 'Massawa'; + case 6263: + return 'Minna'; + case 6264: + return 'Mhast'; + case 6265: + return 'Monte Mario'; + case 6266: + return 'M poraloko'; + case 6267: + return 'North American Datum 1927'; + case 6268: + return 'NAD Michigan'; + case 6269: + return 'North American Datum 1983'; + case 6270: + return 'Nahrwan 1967'; + case 6271: + return 'Naparima 1972'; + case 6272: + return 'New Zealand Geodetic Datum 1949'; + case 6273: + return 'NGO 1948'; + case 6274: + return 'Datum 73'; + case 6275: + return 'Nouvelle Triangulation Francaise'; + case 6276: + return 'NSWC 9Z 2'; + case 6277: + return 'OSGB 1936'; + case 6278: + return 'OSGB 1970 SN'; + case 6279: + return 'OS SN 1980'; + case 6280: + return 'Padang 1884'; + case 6281: + return 'Palestine 1923'; + case 6282: + return 'Pointe Noire'; + case 6283: + return 'Geocentric Datum of Australia 1994'; + case 6284: + return 'Pulkovo 1942'; + case 6285: + return 'Qatar'; + case 6286: + return 'Qatar 1948'; + case 6287: + return 'Qornoq'; + case 6288: + return 'Loma Quintana'; + case 6289: + return 'Amersfoort'; + case 6290: + return 'RT38'; + case 6291: + return 'South American Datum 1969'; + case 6292: + return 'Sapper Hill 1943'; + case 6293: + return 'Schwarzeck'; + case 6294: + return 'Segora'; + case 6295: + return 'Serindung'; + case 6296: + return 'Sudan'; + case 6297: + return 'Tananarive 1925'; + case 6298: + return 'Timbalai 1948'; + case 6299: + return 'TM65'; + case 6300: + return 'TM75'; + case 6301: + return 'Tokyo'; + case 6302: + return 'Trinidad 1903'; + case 6303: + return 'Trucial Coast 1948'; + case 6304: + return 'Voirol 1875'; + case 6305: + return 'Voirol Unifie 1960'; + case 6306: + return 'Bern 1938'; + case 6307: + return 'Nord Sahara 1959'; + case 6308: + return 'Stockholm 1938'; + case 6309: + return 'Yacare'; + case 6310: + return 'Yoff'; + case 6311: + return 'Zanderij'; + case 6312: + return 'Militar Geographische Institut'; + case 6313: + return 'Reseau National Belge 1972'; + case 6314: + return 'Deutsche Hauptdreiecksnetz'; + case 6315: + return 'Conakry 1905'; + case 6317: + return 'Dealul Piscului 1970'; + case 6322: + return 'WGS72'; + case 6324: + return 'WGS72 Transit Broadcast Ephemeris'; + case 6326: + return 'WGS84'; + case 6901: + return 'Ancienne Triangulation Francaise'; + case 6902: + return 'Nord de Guerre'; + case 32767: + return 'User Defined'; + default: + return 'Unknown ($value)'; + } + } + + static String getGeogEllipsoidDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 7001: + return 'Airy 1830'; + case 7002: + return 'Airy Modified 1849'; + case 7003: + return 'Australian National Spheroid'; + case 7004: + return 'Bessel 1841'; + case 7005: + return 'Bessel Modified'; + case 7006: + return 'Bessel Namibia'; + case 7007: + return 'Clarke 1858'; + case 7008: + return 'Clarke 1866'; + case 7009: + return 'Clarke 1866 Michigan'; + case 7010: + return 'Clarke 1880 Benoit'; + case 7011: + return 'Clarke 1880 IGN'; + case 7012: + return 'Clarke 1880 RGS'; + case 7013: + return 'Clarke 1880 Arc'; + case 7014: + return 'Clarke 1880 SGA 1922'; + case 7015: + return 'Everest 1830 1937 Adjustment'; + case 7016: + return 'Everest 1830 1967 Definition'; + case 7017: + return 'Everest 1830 1975 Definition'; + case 7018: + return 'Everest 1830 Modified'; + case 7019: + return 'GRS 1980'; + case 7020: + return 'Helmert 1906'; + case 7021: + return 'Indonesian National Spheroid'; + case 7022: + return 'International 1924'; + case 7023: + return 'International 1967'; + case 7024: + return 'Krassowsky 1940'; + case 7025: + return 'NWL 9D'; + case 7026: + return 'NWL 10D'; + case 7027: + return 'Plessis 1817'; + case 7028: + return 'Struve 1860'; + case 7029: + return 'War Office'; + case 7030: + return 'WGS 84'; + case 7031: + return 'GEM 10C'; + case 7032: + return 'OSU86F'; + case 7033: + return 'OSU91A'; + case 7034: + return 'Clarke 1880'; + case 7035: + return 'Sphere'; + case 32767: + return 'User Defined'; + default: + return 'Unknown ($value)'; + } + } + + static String getProjCSTypeDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 2100: + return 'GGRS87 Greek Grid'; + case 2176: + return 'ETRS89 Poland CS2000 zone 5'; + case 2177: + return 'ETRS89 Poland CS2000 zone 7'; + case 2178: + return 'ETRS89 Poland CS2000 zone 8'; + case 2180: + return 'ETRS89 Poland CS92'; + case 2204: + return 'NAD27 Tennessee'; + case 2205: + return 'NAD83 Kentucky North'; + case 2391: + return 'KKJ Finland zone 1'; + case 2392: + return 'KKJ Finland zone 2'; + case 2393: + return 'KKJ Finland zone 3'; + case 2394: + return 'KKJ Finland zone 4'; + case 2400: + return 'RT90 2 5 gon W'; + case 2600: + return 'Lietuvos Koordinoei Sistema 1994'; + case 3045: + return 'ETRS89 UTM zone 33N'; + case 3053: + return 'Hjorsey 1955 Lambert'; + case 3057: + return 'ISN93 Lambert 1993'; + case 3300: + return 'Estonian Coordinate System of 1992'; + case 3786: + return 'Popular Visualisation CRS / Mercator'; + case 3857: + return 'WGS 84 / Pseudo-Mercator'; + case 20137: + return 'Adindan UTM zone 37N'; + case 20138: + return 'Adindan UTM zone 38N'; + case 20248: + return 'AGD66 AMG zone 48'; + case 20249: + return 'AGD66 AMG zone 49'; + case 20250: + return 'AGD66 AMG zone 50'; + case 20251: + return 'AGD66 AMG zone 51'; + case 20252: + return 'AGD66 AMG zone 52'; + case 20253: + return 'AGD66 AMG zone 53'; + case 20254: + return 'AGD66 AMG zone 54'; + case 20255: + return 'AGD66 AMG zone 55'; + case 20256: + return 'AGD66 AMG zone 56'; + case 20257: + return 'AGD66 AMG zone 57'; + case 20258: + return 'AGD66 AMG zone 58'; + case 20348: + return 'AGD84 AMG zone 48'; + case 20349: + return 'AGD84 AMG zone 49'; + case 20350: + return 'AGD84 AMG zone 50'; + case 20351: + return 'AGD84 AMG zone 51'; + case 20352: + return 'AGD84 AMG zone 52'; + case 20353: + return 'AGD84 AMG zone 53'; + case 20354: + return 'AGD84 AMG zone 54'; + case 20355: + return 'AGD84 AMG zone 55'; + case 20356: + return 'AGD84 AMG zone 56'; + case 20357: + return 'AGD84 AMG zone 57'; + case 20358: + return 'AGD84 AMG zone 58'; + case 20437: + return 'Ain el Abd UTM zone 37N'; + case 20438: + return 'Ain el Abd UTM zone 38N'; + case 20439: + return 'Ain el Abd UTM zone 39N'; + case 20499: + return 'Ain el Abd Bahrain Grid'; + case 20538: + return 'Afgooye UTM zone 38N'; + case 20539: + return 'Afgooye UTM zone 39N'; + case 20700: + return 'Lisbon Portuguese Grid'; + case 20822: + return 'Aratu UTM zone 22S'; + case 20823: + return 'Aratu UTM zone 23S'; + case 20824: + return 'Aratu UTM zone 24S'; + case 20973: + return 'Arc 1950 Lo13'; + case 20975: + return 'Arc 1950 Lo15'; + case 20977: + return 'Arc 1950 Lo17'; + case 20979: + return 'Arc 1950 Lo19'; + case 20981: + return 'Arc 1950 Lo21'; + case 20983: + return 'Arc 1950 Lo23'; + case 20985: + return 'Arc 1950 Lo25'; + case 20987: + return 'Arc 1950 Lo27'; + case 20989: + return 'Arc 1950 Lo29'; + case 20991: + return 'Arc 1950 Lo31'; + case 20993: + return 'Arc 1950 Lo33'; + case 20995: + return 'Arc 1950 Lo35'; + case 21100: + return 'Batavia NEIEZ'; + case 21148: + return 'Batavia UTM zone 48S'; + case 21149: + return 'Batavia UTM zone 49S'; + case 21150: + return 'Batavia UTM zone 50S'; + case 21413: + return 'Beijing Gauss zone 13'; + case 21414: + return 'Beijing Gauss zone 14'; + case 21415: + return 'Beijing Gauss zone 15'; + case 21416: + return 'Beijing Gauss zone 16'; + case 21417: + return 'Beijing Gauss zone 17'; + case 21418: + return 'Beijing Gauss zone 18'; + case 21419: + return 'Beijing Gauss zone 19'; + case 21420: + return 'Beijing Gauss zone 20'; + case 21421: + return 'Beijing Gauss zone 21'; + case 21422: + return 'Beijing Gauss zone 22'; + case 21423: + return 'Beijing Gauss zone 23'; + case 21473: + return 'Beijing Gauss 13N'; + case 21474: + return 'Beijing Gauss 14N'; + case 21475: + return 'Beijing Gauss 15N'; + case 21476: + return 'Beijing Gauss 16N'; + case 21477: + return 'Beijing Gauss 17N'; + case 21478: + return 'Beijing Gauss 18N'; + case 21479: + return 'Beijing Gauss 19N'; + case 21480: + return 'Beijing Gauss 20N'; + case 21481: + return 'Beijing Gauss 21N'; + case 21482: + return 'Beijing Gauss 22N'; + case 21483: + return 'Beijing Gauss 23N'; + case 21500: + return 'Belge Lambert 50'; + case 21790: + return 'Bern 1898 Swiss Old'; + case 21817: + return 'Bogota UTM zone 17N'; + case 21818: + return 'Bogota UTM zone 18N'; + case 21891: + return 'Bogota Colombia 3W'; + case 21892: + return 'Bogota Colombia Bogota'; + case 21893: + return 'Bogota Colombia 3E'; + case 21894: + return 'Bogota Colombia 6E'; + case 22032: + return 'Camacupa UTM 32S'; + case 22033: + return 'Camacupa UTM 33S'; + case 22191: + return 'C Inchauspe Argentina 1'; + case 22192: + return 'C Inchauspe Argentina 2'; + case 22193: + return 'C Inchauspe Argentina 3'; + case 22194: + return 'C Inchauspe Argentina 4'; + case 22195: + return 'C Inchauspe Argentina 5'; + case 22196: + return 'C Inchauspe Argentina 6'; + case 22197: + return 'C Inchauspe Argentina 7'; + case 22332: + return 'Carthage UTM zone 32N'; + case 22391: + return 'Carthage Nord Tunisie'; + case 22392: + return 'Carthage Sud Tunisie'; + case 22523: + return 'Corrego Alegre UTM 23S'; + case 22524: + return 'Corrego Alegre UTM 24S'; + case 22832: + return 'Douala UTM zone 32N'; + case 22992: + return 'Egypt 1907 Red Belt'; + case 22993: + return 'Egypt 1907 Purple Belt'; + case 22994: + return 'Egypt 1907 Ext Purple'; + case 23028: + return 'ED50 UTM zone 28N'; + case 23029: + return 'ED50 UTM zone 29N'; + case 23030: + return 'ED50 UTM zone 30N'; + case 23031: + return 'ED50 UTM zone 31N'; + case 23032: + return 'ED50 UTM zone 32N'; + case 23033: + return 'ED50 UTM zone 33N'; + case 23034: + return 'ED50 UTM zone 34N'; + case 23035: + return 'ED50 UTM zone 35N'; + case 23036: + return 'ED50 UTM zone 36N'; + case 23037: + return 'ED50 UTM zone 37N'; + case 23038: + return 'ED50 UTM zone 38N'; + case 23239: + return 'Fahud UTM zone 39N'; + case 23240: + return 'Fahud UTM zone 40N'; + case 23433: + return 'Garoua UTM zone 33N'; + case 23700: + return 'HD72 EOV'; + case 23846: + return 'ID74 UTM zone 46N'; + case 23847: + return 'ID74 UTM zone 47N'; + case 23848: + return 'ID74 UTM zone 48N'; + case 23849: + return 'ID74 UTM zone 49N'; + case 23850: + return 'ID74 UTM zone 50N'; + case 23851: + return 'ID74 UTM zone 51N'; + case 23852: + return 'ID74 UTM zone 52N'; + case 23853: + return 'ID74 UTM zone 53N'; + case 23886: + return 'ID74 UTM zone 46S'; + case 23887: + return 'ID74 UTM zone 47S'; + case 23888: + return 'ID74 UTM zone 48S'; + case 23889: + return 'ID74 UTM zone 49S'; + case 23890: + return 'ID74 UTM zone 50S'; + case 23891: + return 'ID74 UTM zone 51S'; + case 23892: + return 'ID74 UTM zone 52S'; + case 23893: + return 'ID74 UTM zone 53S'; + case 23894: + return 'ID74 UTM zone 54S'; + case 23947: + return 'Indian 1954 UTM 47N'; + case 23948: + return 'Indian 1954 UTM 48N'; + case 24047: + return 'Indian 1975 UTM 47N'; + case 24048: + return 'Indian 1975 UTM 48N'; + case 24100: + return 'Jamaica 1875 Old Grid'; + case 24200: + return 'JAD69 Jamaica Grid'; + case 24370: + return 'Kalianpur India 0'; + case 24371: + return 'Kalianpur India I'; + case 24372: + return 'Kalianpur India IIa'; + case 24373: + return 'Kalianpur India IIIa'; + case 24374: + return 'Kalianpur India IVa'; + case 24382: + return 'Kalianpur India IIb'; + case 24383: + return 'Kalianpur India IIIb'; + case 24384: + return 'Kalianpur India IVb'; + case 24500: + return 'Kertau Singapore Grid'; + case 24547: + return 'Kertau UTM zone 47N'; + case 24548: + return 'Kertau UTM zone 48N'; + case 24720: + return 'La Canoa UTM zone 20N'; + case 24721: + return 'La Canoa UTM zone 21N'; + case 24818: + return 'PSAD56 UTM zone 18N'; + case 24819: + return 'PSAD56 UTM zone 19N'; + case 24820: + return 'PSAD56 UTM zone 20N'; + case 24821: + return 'PSAD56 UTM zone 21N'; + case 24877: + return 'PSAD56 UTM zone 17S'; + case 24878: + return 'PSAD56 UTM zone 18S'; + case 24879: + return 'PSAD56 UTM zone 19S'; + case 24880: + return 'PSAD56 UTM zone 20S'; + case 24891: + return 'PSAD56 Peru west zone'; + case 24892: + return 'PSAD56 Peru central'; + case 24893: + return 'PSAD56 Peru east zone'; + case 25000: + return 'Leigon Ghana Grid'; + case 25231: + return 'Lome UTM zone 31N'; + case 25391: + return 'Luzon Philippines I'; + case 25392: + return 'Luzon Philippines II'; + case 25393: + return 'Luzon Philippines III'; + case 25394: + return 'Luzon Philippines IV'; + case 25395: + return 'Luzon Philippines V'; + case 25700: + return 'Makassar NEIEZ'; + case 25932: + return 'Malongo 1987 UTM 32S'; + case 26191: + return 'Merchich Nord Maroc'; + case 26192: + return 'Merchich Sud Maroc'; + case 26193: + return 'Merchich Sahara'; + case 26237: + return 'Massawa UTM zone 37N'; + case 26331: + return 'Minna UTM zone 31N'; + case 26332: + return 'Minna UTM zone 32N'; + case 26391: + return 'Minna Nigeria West'; + case 26392: + return 'Minna Nigeria Mid Belt'; + case 26393: + return 'Minna Nigeria East'; + case 26432: + return 'Mhast UTM zone 32S'; + case 26591: + return 'Monte Mario Italy 1'; + case 26592: + return 'Monte Mario Italy 2'; + case 26632: + return 'M poraloko UTM 32N'; + case 26692: + return 'M poraloko UTM 32S'; + case 26703: + return 'NAD27 UTM zone 3N'; + case 26704: + return 'NAD27 UTM zone 4N'; + case 26705: + return 'NAD27 UTM zone 5N'; + case 26706: + return 'NAD27 UTM zone 6N'; + case 26707: + return 'NAD27 UTM zone 7N'; + case 26708: + return 'NAD27 UTM zone 8N'; + case 26709: + return 'NAD27 UTM zone 9N'; + case 26710: + return 'NAD27 UTM zone 10N'; + case 26711: + return 'NAD27 UTM zone 11N'; + case 26712: + return 'NAD27 UTM zone 12N'; + case 26713: + return 'NAD27 UTM zone 13N'; + case 26714: + return 'NAD27 UTM zone 14N'; + case 26715: + return 'NAD27 UTM zone 15N'; + case 26716: + return 'NAD27 UTM zone 16N'; + case 26717: + return 'NAD27 UTM zone 17N'; + case 26718: + return 'NAD27 UTM zone 18N'; + case 26719: + return 'NAD27 UTM zone 19N'; + case 26720: + return 'NAD27 UTM zone 20N'; + case 26721: + return 'NAD27 UTM zone 21N'; + case 26722: + return 'NAD27 UTM zone 22N'; + case 26729: + return 'NAD27 Alabama East'; + case 26730: + return 'NAD27 Alabama West'; + case 26731: + return 'NAD27 Alaska zone 1'; + case 26732: + return 'NAD27 Alaska zone 2'; + case 26733: + return 'NAD27 Alaska zone 3'; + case 26734: + return 'NAD27 Alaska zone 4'; + case 26735: + return 'NAD27 Alaska zone 5'; + case 26736: + return 'NAD27 Alaska zone 6'; + case 26737: + return 'NAD27 Alaska zone 7'; + case 26738: + return 'NAD27 Alaska zone 8'; + case 26739: + return 'NAD27 Alaska zone 9'; + case 26740: + return 'NAD27 Alaska zone 10'; + case 26741: + return 'NAD27 California I'; + case 26742: + return 'NAD27 California II'; + case 26743: + return 'NAD27 California III'; + case 26744: + return 'NAD27 California IV'; + case 26745: + return 'NAD27 California V'; + case 26746: + return 'NAD27 California VI'; + case 26747: + return 'NAD27 California VII'; + case 26748: + return 'NAD27 Arizona East'; + case 26749: + return 'NAD27 Arizona Central'; + case 26750: + return 'NAD27 Arizona West'; + case 26751: + return 'NAD27 Arkansas North'; + case 26752: + return 'NAD27 Arkansas South'; + case 26753: + return 'NAD27 Colorado North'; + case 26754: + return 'NAD27 Colorado Central'; + case 26755: + return 'NAD27 Colorado South'; + case 26756: + return 'NAD27 Connecticut'; + case 26757: + return 'NAD27 Delaware'; + case 26758: + return 'NAD27 Florida East'; + case 26759: + return 'NAD27 Florida West'; + case 26760: + return 'NAD27 Florida North'; + case 26761: + return 'NAD27 Hawaii zone 1'; + case 26762: + return 'NAD27 Hawaii zone 2'; + case 26763: + return 'NAD27 Hawaii zone 3'; + case 26764: + return 'NAD27 Hawaii zone 4'; + case 26765: + return 'NAD27 Hawaii zone 5'; + case 26766: + return 'NAD27 Georgia East'; + case 26767: + return 'NAD27 Georgia West'; + case 26768: + return 'NAD27 Idaho East'; + case 26769: + return 'NAD27 Idaho Central'; + case 26770: + return 'NAD27 Idaho West'; + case 26771: + return 'NAD27 Illinois East'; + case 26772: + return 'NAD27 Illinois West'; + case 26773: + return 'NAD27 Indiana East'; + case 26774: + return 'NAD27 Indiana West'; + case 26775: + return 'NAD27 Iowa North'; + case 26776: + return 'NAD27 Iowa South'; + case 26777: + return 'NAD27 Kansas North'; + case 26778: + return 'NAD27 Kansas South'; + case 26779: + return 'NAD27 Kentucky North'; + case 26780: + return 'NAD27 Kentucky South'; + case 26781: + return 'NAD27 Louisiana North'; + case 26782: + return 'NAD27 Louisiana South'; + case 26783: + return 'NAD27 Maine East'; + case 26784: + return 'NAD27 Maine West'; + case 26785: + return 'NAD27 Maryland'; + case 26786: + return 'NAD27 Massachusetts'; + case 26787: + return 'NAD27 Massachusetts Is'; + case 26788: + return 'NAD27 Michigan North'; + case 26789: + return 'NAD27 Michigan Central'; + case 26790: + return 'NAD27 Michigan South'; + case 26791: + return 'NAD27 Minnesota North'; + case 26792: + return 'NAD27 Minnesota Cent'; + case 26793: + return 'NAD27 Minnesota South'; + case 26794: + return 'NAD27 Mississippi East'; + case 26795: + return 'NAD27 Mississippi West'; + case 26796: + return 'NAD27 Missouri East'; + case 26797: + return 'NAD27 Missouri Central'; + case 26798: + return 'NAD27 Missouri West'; + case 26801: + return 'NAD Michigan Michigan East'; + case 26802: + return 'NAD Michigan Michigan Old Central'; + case 26803: + return 'NAD Michigan Michigan West'; + case 26903: + return 'NAD83 UTM zone 3N'; + case 26904: + return 'NAD83 UTM zone 4N'; + case 26905: + return 'NAD83 UTM zone 5N'; + case 26906: + return 'NAD83 UTM zone 6N'; + case 26907: + return 'NAD83 UTM zone 7N'; + case 26908: + return 'NAD83 UTM zone 8N'; + case 26909: + return 'NAD83 UTM zone 9N'; + case 26910: + return 'NAD83 UTM zone 10N'; + case 26911: + return 'NAD83 UTM zone 11N'; + case 26912: + return 'NAD83 UTM zone 12N'; + case 26913: + return 'NAD83 UTM zone 13N'; + case 26914: + return 'NAD83 UTM zone 14N'; + case 26915: + return 'NAD83 UTM zone 15N'; + case 26916: + return 'NAD83 UTM zone 16N'; + case 26917: + return 'NAD83 UTM zone 17N'; + case 26918: + return 'NAD83 UTM zone 18N'; + case 26919: + return 'NAD83 UTM zone 19N'; + case 26920: + return 'NAD83 UTM zone 20N'; + case 26921: + return 'NAD83 UTM zone 21N'; + case 26922: + return 'NAD83 UTM zone 22N'; + case 26923: + return 'NAD83 UTM zone 23N'; + case 26929: + return 'NAD83 Alabama East'; + case 26930: + return 'NAD83 Alabama West'; + case 26931: + return 'NAD83 Alaska zone 1'; + case 26932: + return 'NAD83 Alaska zone 2'; + case 26933: + return 'NAD83 Alaska zone 3'; + case 26934: + return 'NAD83 Alaska zone 4'; + case 26935: + return 'NAD83 Alaska zone 5'; + case 26936: + return 'NAD83 Alaska zone 6'; + case 26937: + return 'NAD83 Alaska zone 7'; + case 26938: + return 'NAD83 Alaska zone 8'; + case 26939: + return 'NAD83 Alaska zone 9'; + case 26940: + return 'NAD83 Alaska zone 10'; + case 26941: + return 'NAD83 California 1'; + case 26942: + return 'NAD83 California 2'; + case 26943: + return 'NAD83 California 3'; + case 26944: + return 'NAD83 California 4'; + case 26945: + return 'NAD83 California 5'; + case 26946: + return 'NAD83 California 6'; + case 26948: + return 'NAD83 Arizona East'; + case 26949: + return 'NAD83 Arizona Central'; + case 26950: + return 'NAD83 Arizona West'; + case 26951: + return 'NAD83 Arkansas North'; + case 26952: + return 'NAD83 Arkansas South'; + case 26953: + return 'NAD83 Colorado North'; + case 26954: + return 'NAD83 Colorado Central'; + case 26955: + return 'NAD83 Colorado South'; + case 26956: + return 'NAD83 Connecticut'; + case 26957: + return 'NAD83 Delaware'; + case 26958: + return 'NAD83 Florida East'; + case 26959: + return 'NAD83 Florida West'; + case 26960: + return 'NAD83 Florida North'; + case 26961: + return 'NAD83 Hawaii zone 1'; + case 26962: + return 'NAD83 Hawaii zone 2'; + case 26963: + return 'NAD83 Hawaii zone 3'; + case 26964: + return 'NAD83 Hawaii zone 4'; + case 26965: + return 'NAD83 Hawaii zone 5'; + case 26966: + return 'NAD83 Georgia East'; + case 26967: + return 'NAD83 Georgia West'; + case 26968: + return 'NAD83 Idaho East'; + case 26969: + return 'NAD83 Idaho Central'; + case 26970: + return 'NAD83 Idaho West'; + case 26971: + return 'NAD83 Illinois East'; + case 26972: + return 'NAD83 Illinois West'; + case 26973: + return 'NAD83 Indiana East'; + case 26974: + return 'NAD83 Indiana West'; + case 26975: + return 'NAD83 Iowa North'; + case 26976: + return 'NAD83 Iowa South'; + case 26977: + return 'NAD83 Kansas North'; + case 26978: + return 'NAD83 Kansas South'; + case 26979: + return 'NAD83 Kentucky North'; + case 26980: + return 'NAD83 Kentucky South'; + case 26981: + return 'NAD83 Louisiana North'; + case 26982: + return 'NAD83 Louisiana South'; + case 26983: + return 'NAD83 Maine East'; + case 26984: + return 'NAD83 Maine West'; + case 26985: + return 'NAD83 Maryland'; + case 26986: + return 'NAD83 Massachusetts'; + case 26987: + return 'NAD83 Massachusetts Is'; + case 26988: + return 'NAD83 Michigan North'; + case 26989: + return 'NAD83 Michigan Central'; + case 26990: + return 'NAD83 Michigan South'; + case 26991: + return 'NAD83 Minnesota North'; + case 26992: + return 'NAD83 Minnesota Cent'; + case 26993: + return 'NAD83 Minnesota South'; + case 26994: + return 'NAD83 Mississippi East'; + case 26995: + return 'NAD83 Mississippi West'; + case 26996: + return 'NAD83 Missouri East'; + case 26997: + return 'NAD83 Missouri Central'; + case 26998: + return 'NAD83 Missouri West'; + case 27038: + return 'Nahrwan 1967 UTM 38N'; + case 27039: + return 'Nahrwan 1967 UTM 39N'; + case 27040: + return 'Nahrwan 1967 UTM 40N'; + case 27120: + return 'Naparima UTM 20N'; + case 27200: + return 'GD49 NZ Map Grid'; + case 27291: + return 'GD49 North Island Grid'; + case 27292: + return 'GD49 South Island Grid'; + case 27429: + return 'Datum 73 UTM zone 29N'; + case 27500: + return 'ATF Nord de Guerre'; + case 27581: + return 'NTF France I'; + case 27582: + return 'NTF France II'; + case 27583: + return 'NTF France III'; + case 27591: + return 'NTF Nord France'; + case 27592: + return 'NTF Centre France'; + case 27593: + return 'NTF Sud France'; + case 27700: + return 'British National Grid'; + case 28232: + return 'Point Noire UTM 32S'; + case 28348: + return 'GDA94 MGA zone 48'; + case 28349: + return 'GDA94 MGA zone 49'; + case 28350: + return 'GDA94 MGA zone 50'; + case 28351: + return 'GDA94 MGA zone 51'; + case 28352: + return 'GDA94 MGA zone 52'; + case 28353: + return 'GDA94 MGA zone 53'; + case 28354: + return 'GDA94 MGA zone 54'; + case 28355: + return 'GDA94 MGA zone 55'; + case 28356: + return 'GDA94 MGA zone 56'; + case 28357: + return 'GDA94 MGA zone 57'; + case 28358: + return 'GDA94 MGA zone 58'; + case 28404: + return 'Pulkovo Gauss zone 4'; + case 28405: + return 'Pulkovo Gauss zone 5'; + case 28406: + return 'Pulkovo Gauss zone 6'; + case 28407: + return 'Pulkovo Gauss zone 7'; + case 28408: + return 'Pulkovo Gauss zone 8'; + case 28409: + return 'Pulkovo Gauss zone 9'; + case 28410: + return 'Pulkovo Gauss zone 10'; + case 28411: + return 'Pulkovo Gauss zone 11'; + case 28412: + return 'Pulkovo Gauss zone 12'; + case 28413: + return 'Pulkovo Gauss zone 13'; + case 28414: + return 'Pulkovo Gauss zone 14'; + case 28415: + return 'Pulkovo Gauss zone 15'; + case 28416: + return 'Pulkovo Gauss zone 16'; + case 28417: + return 'Pulkovo Gauss zone 17'; + case 28418: + return 'Pulkovo Gauss zone 18'; + case 28419: + return 'Pulkovo Gauss zone 19'; + case 28420: + return 'Pulkovo Gauss zone 20'; + case 28421: + return 'Pulkovo Gauss zone 21'; + case 28422: + return 'Pulkovo Gauss zone 22'; + case 28423: + return 'Pulkovo Gauss zone 23'; + case 28424: + return 'Pulkovo Gauss zone 24'; + case 28425: + return 'Pulkovo Gauss zone 25'; + case 28426: + return 'Pulkovo Gauss zone 26'; + case 28427: + return 'Pulkovo Gauss zone 27'; + case 28428: + return 'Pulkovo Gauss zone 28'; + case 28429: + return 'Pulkovo Gauss zone 29'; + case 28430: + return 'Pulkovo Gauss zone 30'; + case 28431: + return 'Pulkovo Gauss zone 31'; + case 28432: + return 'Pulkovo Gauss zone 32'; + case 28464: + return 'Pulkovo Gauss 4N'; + case 28465: + return 'Pulkovo Gauss 5N'; + case 28466: + return 'Pulkovo Gauss 6N'; + case 28467: + return 'Pulkovo Gauss 7N'; + case 28468: + return 'Pulkovo Gauss 8N'; + case 28469: + return 'Pulkovo Gauss 9N'; + case 28470: + return 'Pulkovo Gauss 10N'; + case 28471: + return 'Pulkovo Gauss 11N'; + case 28472: + return 'Pulkovo Gauss 12N'; + case 28473: + return 'Pulkovo Gauss 13N'; + case 28474: + return 'Pulkovo Gauss 14N'; + case 28475: + return 'Pulkovo Gauss 15N'; + case 28476: + return 'Pulkovo Gauss 16N'; + case 28477: + return 'Pulkovo Gauss 17N'; + case 28478: + return 'Pulkovo Gauss 18N'; + case 28479: + return 'Pulkovo Gauss 19N'; + case 28480: + return 'Pulkovo Gauss 20N'; + case 28481: + return 'Pulkovo Gauss 21N'; + case 28482: + return 'Pulkovo Gauss 22N'; + case 28483: + return 'Pulkovo Gauss 23N'; + case 28484: + return 'Pulkovo Gauss 24N'; + case 28485: + return 'Pulkovo Gauss 25N'; + case 28486: + return 'Pulkovo Gauss 26N'; + case 28487: + return 'Pulkovo Gauss 27N'; + case 28488: + return 'Pulkovo Gauss 28N'; + case 28489: + return 'Pulkovo Gauss 29N'; + case 28490: + return 'Pulkovo Gauss 30N'; + case 28491: + return 'Pulkovo Gauss 31N'; + case 28492: + return 'Pulkovo Gauss 32N'; + case 28600: + return 'Qatar National Grid'; + case 28991: + return 'RD Netherlands Old'; + case 28992: + return 'RD Netherlands New'; + case 29118: + return 'SAD69 UTM zone 18N'; + case 29119: + return 'SAD69 UTM zone 19N'; + case 29120: + return 'SAD69 UTM zone 20N'; + case 29121: + return 'SAD69 UTM zone 21N'; + case 29122: + return 'SAD69 UTM zone 22N'; + case 29177: + return 'SAD69 UTM zone 17S'; + case 29178: + return 'SAD69 UTM zone 18S'; + case 29179: + return 'SAD69 UTM zone 19S'; + case 29180: + return 'SAD69 UTM zone 20S'; + case 29181: + return 'SAD69 UTM zone 21S'; + case 29182: + return 'SAD69 UTM zone 22S'; + case 29183: + return 'SAD69 UTM zone 23S'; + case 29184: + return 'SAD69 UTM zone 24S'; + case 29185: + return 'SAD69 UTM zone 25S'; + case 29220: + return 'Sapper Hill UTM 20S'; + case 29221: + return 'Sapper Hill UTM 21S'; + case 29333: + return 'Schwarzeck UTM 33S'; + case 29635: + return 'Sudan UTM zone 35N'; + case 29636: + return 'Sudan UTM zone 36N'; + case 29700: + return 'Tananarive Laborde'; + case 29738: + return 'Tananarive UTM 38S'; + case 29739: + return 'Tananarive UTM 39S'; + case 29800: + return 'Timbalai 1948 Borneo'; + case 29849: + return 'Timbalai 1948 UTM 49N'; + case 29850: + return 'Timbalai 1948 UTM 50N'; + case 29900: + return 'TM65 Irish Nat Grid'; + case 30200: + return 'Trinidad 1903 Trinidad'; + case 30339: + return 'TC 1948 UTM zone 39N'; + case 30340: + return 'TC 1948 UTM zone 40N'; + case 30491: + return 'Voirol N Algerie ancien'; + case 30492: + return 'Voirol S Algerie ancien'; + case 30591: + return 'Voirol Unifie N Algerie'; + case 30592: + return 'Voirol Unifie S Algerie'; + case 30600: + return 'Bern 1938 Swiss New'; + case 30729: + return 'Nord Sahara UTM 29N'; + case 30730: + return 'Nord Sahara UTM 30N'; + case 30731: + return 'Nord Sahara UTM 31N'; + case 30732: + return 'Nord Sahara UTM 32N'; + case 31028: + return 'Yoff UTM zone 28N'; + case 31121: + return 'Zanderij UTM zone 21N'; + case 31291: + return 'MGI Austria West'; + case 31292: + return 'MGI Austria Central'; + case 31293: + return 'MGI Austria East'; + case 31300: + return 'Belge Lambert 72'; + case 31491: + return 'DHDN Germany zone 1'; + case 31492: + return 'DHDN Germany zone 2'; + case 31493: + return 'DHDN Germany zone 3'; + case 31494: + return 'DHDN Germany zone 4'; + case 31495: + return 'DHDN Germany zone 5'; + case 31700: + return 'Dealul Piscului 1970 Stereo 70'; + case 32001: + return 'NAD27 Montana North'; + case 32002: + return 'NAD27 Montana Central'; + case 32003: + return 'NAD27 Montana South'; + case 32005: + return 'NAD27 Nebraska North'; + case 32006: + return 'NAD27 Nebraska South'; + case 32007: + return 'NAD27 Nevada East'; + case 32008: + return 'NAD27 Nevada Central'; + case 32009: + return 'NAD27 Nevada West'; + case 32010: + return 'NAD27 New Hampshire'; + case 32011: + return 'NAD27 New Jersey'; + case 32012: + return 'NAD27 New Mexico East'; + case 32013: + return 'NAD27 New Mexico Cent'; + case 32014: + return 'NAD27 New Mexico West'; + case 32015: + return 'NAD27 New York East'; + case 32016: + return 'NAD27 New York Central'; + case 32017: + return 'NAD27 New York West'; + case 32018: + return 'NAD27 New York Long Is'; + case 32019: + return 'NAD27 North Carolina'; + case 32020: + return 'NAD27 North Dakota N'; + case 32021: + return 'NAD27 North Dakota S'; + case 32022: + return 'NAD27 Ohio North'; + case 32023: + return 'NAD27 Ohio South'; + case 32024: + return 'NAD27 Oklahoma North'; + case 32025: + return 'NAD27 Oklahoma South'; + case 32026: + return 'NAD27 Oregon North'; + case 32027: + return 'NAD27 Oregon South'; + case 32028: + return 'NAD27 Pennsylvania N'; + case 32029: + return 'NAD27 Pennsylvania S'; + case 32030: + return 'NAD27 Rhode Island'; + case 32031: + return 'NAD27 South Carolina N'; + case 32033: + return 'NAD27 South Carolina S'; + case 32034: + return 'NAD27 South Dakota N'; + case 32035: + return 'NAD27 South Dakota S'; + case 32036: + return 'NAD27 Tennessee'; + case 32037: + return 'NAD27 Texas North'; + case 32038: + return 'NAD27 Texas North Cen'; + case 32039: + return 'NAD27 Texas Central'; + case 32040: + return 'NAD27 Texas South Cen'; + case 32041: + return 'NAD27 Texas South'; + case 32042: + return 'NAD27 Utah North'; + case 32043: + return 'NAD27 Utah Central'; + case 32044: + return 'NAD27 Utah South'; + case 32045: + return 'NAD27 Vermont'; + case 32046: + return 'NAD27 Virginia North'; + case 32047: + return 'NAD27 Virginia South'; + case 32048: + return 'NAD27 Washington North'; + case 32049: + return 'NAD27 Washington South'; + case 32050: + return 'NAD27 West Virginia N'; + case 32051: + return 'NAD27 West Virginia S'; + case 32052: + return 'NAD27 Wisconsin North'; + case 32053: + return 'NAD27 Wisconsin Cen'; + case 32054: + return 'NAD27 Wisconsin South'; + case 32055: + return 'NAD27 Wyoming East'; + case 32056: + return 'NAD27 Wyoming E Cen'; + case 32057: + return 'NAD27 Wyoming W Cen'; + case 32058: + return 'NAD27 Wyoming West'; + case 32059: + return 'NAD27 Puerto Rico'; + case 32060: + return 'NAD27 St Croix'; + case 32100: + return 'NAD83 Montana'; + case 32104: + return 'NAD83 Nebraska'; + case 32107: + return 'NAD83 Nevada East'; + case 32108: + return 'NAD83 Nevada Central'; + case 32109: + return 'NAD83 Nevada West'; + case 32110: + return 'NAD83 New Hampshire'; + case 32111: + return 'NAD83 New Jersey'; + case 32112: + return 'NAD83 New Mexico East'; + case 32113: + return 'NAD83 New Mexico Cent'; + case 32114: + return 'NAD83 New Mexico West'; + case 32115: + return 'NAD83 New York East'; + case 32116: + return 'NAD83 New York Central'; + case 32117: + return 'NAD83 New York West'; + case 32118: + return 'NAD83 New York Long Is'; + case 32119: + return 'NAD83 North Carolina'; + case 32120: + return 'NAD83 North Dakota N'; + case 32121: + return 'NAD83 North Dakota S'; + case 32122: + return 'NAD83 Ohio North'; + case 32123: + return 'NAD83 Ohio South'; + case 32124: + return 'NAD83 Oklahoma North'; + case 32125: + return 'NAD83 Oklahoma South'; + case 32126: + return 'NAD83 Oregon North'; + case 32127: + return 'NAD83 Oregon South'; + case 32128: + return 'NAD83 Pennsylvania N'; + case 32129: + return 'NAD83 Pennsylvania S'; + case 32130: + return 'NAD83 Rhode Island'; + case 32133: + return 'NAD83 South Carolina'; + case 32134: + return 'NAD83 South Dakota N'; + case 32135: + return 'NAD83 South Dakota S'; + case 32136: + return 'NAD83 Tennessee'; + case 32137: + return 'NAD83 Texas North'; + case 32138: + return 'NAD83 Texas North Cen'; + case 32139: + return 'NAD83 Texas Central'; + case 32140: + return 'NAD83 Texas South Cen'; + case 32141: + return 'NAD83 Texas South'; + case 32142: + return 'NAD83 Utah North'; + case 32143: + return 'NAD83 Utah Central'; + case 32144: + return 'NAD83 Utah South'; + case 32145: + return 'NAD83 Vermont'; + case 32146: + return 'NAD83 Virginia North'; + case 32147: + return 'NAD83 Virginia South'; + case 32148: + return 'NAD83 Washington North'; + case 32149: + return 'NAD83 Washington South'; + case 32150: + return 'NAD83 West Virginia N'; + case 32151: + return 'NAD83 West Virginia S'; + case 32152: + return 'NAD83 Wisconsin North'; + case 32153: + return 'NAD83 Wisconsin Cen'; + case 32154: + return 'NAD83 Wisconsin South'; + case 32155: + return 'NAD83 Wyoming East'; + case 32156: + return 'NAD83 Wyoming E Cen'; + case 32157: + return 'NAD83 Wyoming W Cen'; + case 32158: + return 'NAD83 Wyoming West'; + case 32161: + return 'NAD83 Puerto Rico Virgin Is'; + case 32201: + return 'WGS72 UTM zone 1N'; + case 32202: + return 'WGS72 UTM zone 2N'; + case 32203: + return 'WGS72 UTM zone 3N'; + case 32204: + return 'WGS72 UTM zone 4N'; + case 32205: + return 'WGS72 UTM zone 5N'; + case 32206: + return 'WGS72 UTM zone 6N'; + case 32207: + return 'WGS72 UTM zone 7N'; + case 32208: + return 'WGS72 UTM zone 8N'; + case 32209: + return 'WGS72 UTM zone 9N'; + case 32210: + return 'WGS72 UTM zone 10N'; + case 32211: + return 'WGS72 UTM zone 11N'; + case 32212: + return 'WGS72 UTM zone 12N'; + case 32213: + return 'WGS72 UTM zone 13N'; + case 32214: + return 'WGS72 UTM zone 14N'; + case 32215: + return 'WGS72 UTM zone 15N'; + case 32216: + return 'WGS72 UTM zone 16N'; + case 32217: + return 'WGS72 UTM zone 17N'; + case 32218: + return 'WGS72 UTM zone 18N'; + case 32219: + return 'WGS72 UTM zone 19N'; + case 32220: + return 'WGS72 UTM zone 20N'; + case 32221: + return 'WGS72 UTM zone 21N'; + case 32222: + return 'WGS72 UTM zone 22N'; + case 32223: + return 'WGS72 UTM zone 23N'; + case 32224: + return 'WGS72 UTM zone 24N'; + case 32225: + return 'WGS72 UTM zone 25N'; + case 32226: + return 'WGS72 UTM zone 26N'; + case 32227: + return 'WGS72 UTM zone 27N'; + case 32228: + return 'WGS72 UTM zone 28N'; + case 32229: + return 'WGS72 UTM zone 29N'; + case 32230: + return 'WGS72 UTM zone 30N'; + case 32231: + return 'WGS72 UTM zone 31N'; + case 32232: + return 'WGS72 UTM zone 32N'; + case 32233: + return 'WGS72 UTM zone 33N'; + case 32234: + return 'WGS72 UTM zone 34N'; + case 32235: + return 'WGS72 UTM zone 35N'; + case 32236: + return 'WGS72 UTM zone 36N'; + case 32237: + return 'WGS72 UTM zone 37N'; + case 32238: + return 'WGS72 UTM zone 38N'; + case 32239: + return 'WGS72 UTM zone 39N'; + case 32240: + return 'WGS72 UTM zone 40N'; + case 32241: + return 'WGS72 UTM zone 41N'; + case 32242: + return 'WGS72 UTM zone 42N'; + case 32243: + return 'WGS72 UTM zone 43N'; + case 32244: + return 'WGS72 UTM zone 44N'; + case 32245: + return 'WGS72 UTM zone 45N'; + case 32246: + return 'WGS72 UTM zone 46N'; + case 32247: + return 'WGS72 UTM zone 47N'; + case 32248: + return 'WGS72 UTM zone 48N'; + case 32249: + return 'WGS72 UTM zone 49N'; + case 32250: + return 'WGS72 UTM zone 50N'; + case 32251: + return 'WGS72 UTM zone 51N'; + case 32252: + return 'WGS72 UTM zone 52N'; + case 32253: + return 'WGS72 UTM zone 53N'; + case 32254: + return 'WGS72 UTM zone 54N'; + case 32255: + return 'WGS72 UTM zone 55N'; + case 32256: + return 'WGS72 UTM zone 56N'; + case 32257: + return 'WGS72 UTM zone 57N'; + case 32258: + return 'WGS72 UTM zone 58N'; + case 32259: + return 'WGS72 UTM zone 59N'; + case 32260: + return 'WGS72 UTM zone 60N'; + case 32301: + return 'WGS72 UTM zone 1S'; + case 32302: + return 'WGS72 UTM zone 2S'; + case 32303: + return 'WGS72 UTM zone 3S'; + case 32304: + return 'WGS72 UTM zone 4S'; + case 32305: + return 'WGS72 UTM zone 5S'; + case 32306: + return 'WGS72 UTM zone 6S'; + case 32307: + return 'WGS72 UTM zone 7S'; + case 32308: + return 'WGS72 UTM zone 8S'; + case 32309: + return 'WGS72 UTM zone 9S'; + case 32310: + return 'WGS72 UTM zone 10S'; + case 32311: + return 'WGS72 UTM zone 11S'; + case 32312: + return 'WGS72 UTM zone 12S'; + case 32313: + return 'WGS72 UTM zone 13S'; + case 32314: + return 'WGS72 UTM zone 14S'; + case 32315: + return 'WGS72 UTM zone 15S'; + case 32316: + return 'WGS72 UTM zone 16S'; + case 32317: + return 'WGS72 UTM zone 17S'; + case 32318: + return 'WGS72 UTM zone 18S'; + case 32319: + return 'WGS72 UTM zone 19S'; + case 32320: + return 'WGS72 UTM zone 20S'; + case 32321: + return 'WGS72 UTM zone 21S'; + case 32322: + return 'WGS72 UTM zone 22S'; + case 32323: + return 'WGS72 UTM zone 23S'; + case 32324: + return 'WGS72 UTM zone 24S'; + case 32325: + return 'WGS72 UTM zone 25S'; + case 32326: + return 'WGS72 UTM zone 26S'; + case 32327: + return 'WGS72 UTM zone 27S'; + case 32328: + return 'WGS72 UTM zone 28S'; + case 32329: + return 'WGS72 UTM zone 29S'; + case 32330: + return 'WGS72 UTM zone 30S'; + case 32331: + return 'WGS72 UTM zone 31S'; + case 32332: + return 'WGS72 UTM zone 32S'; + case 32333: + return 'WGS72 UTM zone 33S'; + case 32334: + return 'WGS72 UTM zone 34S'; + case 32335: + return 'WGS72 UTM zone 35S'; + case 32336: + return 'WGS72 UTM zone 36S'; + case 32337: + return 'WGS72 UTM zone 37S'; + case 32338: + return 'WGS72 UTM zone 38S'; + case 32339: + return 'WGS72 UTM zone 39S'; + case 32340: + return 'WGS72 UTM zone 40S'; + case 32341: + return 'WGS72 UTM zone 41S'; + case 32342: + return 'WGS72 UTM zone 42S'; + case 32343: + return 'WGS72 UTM zone 43S'; + case 32344: + return 'WGS72 UTM zone 44S'; + case 32345: + return 'WGS72 UTM zone 45S'; + case 32346: + return 'WGS72 UTM zone 46S'; + case 32347: + return 'WGS72 UTM zone 47S'; + case 32348: + return 'WGS72 UTM zone 48S'; + case 32349: + return 'WGS72 UTM zone 49S'; + case 32350: + return 'WGS72 UTM zone 50S'; + case 32351: + return 'WGS72 UTM zone 51S'; + case 32352: + return 'WGS72 UTM zone 52S'; + case 32353: + return 'WGS72 UTM zone 53S'; + case 32354: + return 'WGS72 UTM zone 54S'; + case 32355: + return 'WGS72 UTM zone 55S'; + case 32356: + return 'WGS72 UTM zone 56S'; + case 32357: + return 'WGS72 UTM zone 57S'; + case 32358: + return 'WGS72 UTM zone 58S'; + case 32359: + return 'WGS72 UTM zone 59S'; + case 32360: + return 'WGS72 UTM zone 60S'; + case 32401: + return 'WGS72BE UTM zone 1N'; + case 32402: + return 'WGS72BE UTM zone 2N'; + case 32403: + return 'WGS72BE UTM zone 3N'; + case 32404: + return 'WGS72BE UTM zone 4N'; + case 32405: + return 'WGS72BE UTM zone 5N'; + case 32406: + return 'WGS72BE UTM zone 6N'; + case 32407: + return 'WGS72BE UTM zone 7N'; + case 32408: + return 'WGS72BE UTM zone 8N'; + case 32409: + return 'WGS72BE UTM zone 9N'; + case 32410: + return 'WGS72BE UTM zone 10N'; + case 32411: + return 'WGS72BE UTM zone 11N'; + case 32412: + return 'WGS72BE UTM zone 12N'; + case 32413: + return 'WGS72BE UTM zone 13N'; + case 32414: + return 'WGS72BE UTM zone 14N'; + case 32415: + return 'WGS72BE UTM zone 15N'; + case 32416: + return 'WGS72BE UTM zone 16N'; + case 32417: + return 'WGS72BE UTM zone 17N'; + case 32418: + return 'WGS72BE UTM zone 18N'; + case 32419: + return 'WGS72BE UTM zone 19N'; + case 32420: + return 'WGS72BE UTM zone 20N'; + case 32421: + return 'WGS72BE UTM zone 21N'; + case 32422: + return 'WGS72BE UTM zone 22N'; + case 32423: + return 'WGS72BE UTM zone 23N'; + case 32424: + return 'WGS72BE UTM zone 24N'; + case 32425: + return 'WGS72BE UTM zone 25N'; + case 32426: + return 'WGS72BE UTM zone 26N'; + case 32427: + return 'WGS72BE UTM zone 27N'; + case 32428: + return 'WGS72BE UTM zone 28N'; + case 32429: + return 'WGS72BE UTM zone 29N'; + case 32430: + return 'WGS72BE UTM zone 30N'; + case 32431: + return 'WGS72BE UTM zone 31N'; + case 32432: + return 'WGS72BE UTM zone 32N'; + case 32433: + return 'WGS72BE UTM zone 33N'; + case 32434: + return 'WGS72BE UTM zone 34N'; + case 32435: + return 'WGS72BE UTM zone 35N'; + case 32436: + return 'WGS72BE UTM zone 36N'; + case 32437: + return 'WGS72BE UTM zone 37N'; + case 32438: + return 'WGS72BE UTM zone 38N'; + case 32439: + return 'WGS72BE UTM zone 39N'; + case 32440: + return 'WGS72BE UTM zone 40N'; + case 32441: + return 'WGS72BE UTM zone 41N'; + case 32442: + return 'WGS72BE UTM zone 42N'; + case 32443: + return 'WGS72BE UTM zone 43N'; + case 32444: + return 'WGS72BE UTM zone 44N'; + case 32445: + return 'WGS72BE UTM zone 45N'; + case 32446: + return 'WGS72BE UTM zone 46N'; + case 32447: + return 'WGS72BE UTM zone 47N'; + case 32448: + return 'WGS72BE UTM zone 48N'; + case 32449: + return 'WGS72BE UTM zone 49N'; + case 32450: + return 'WGS72BE UTM zone 50N'; + case 32451: + return 'WGS72BE UTM zone 51N'; + case 32452: + return 'WGS72BE UTM zone 52N'; + case 32453: + return 'WGS72BE UTM zone 53N'; + case 32454: + return 'WGS72BE UTM zone 54N'; + case 32455: + return 'WGS72BE UTM zone 55N'; + case 32456: + return 'WGS72BE UTM zone 56N'; + case 32457: + return 'WGS72BE UTM zone 57N'; + case 32458: + return 'WGS72BE UTM zone 58N'; + case 32459: + return 'WGS72BE UTM zone 59N'; + case 32460: + return 'WGS72BE UTM zone 60N'; + case 32501: + return 'WGS72BE UTM zone 1S'; + case 32502: + return 'WGS72BE UTM zone 2S'; + case 32503: + return 'WGS72BE UTM zone 3S'; + case 32504: + return 'WGS72BE UTM zone 4S'; + case 32505: + return 'WGS72BE UTM zone 5S'; + case 32506: + return 'WGS72BE UTM zone 6S'; + case 32507: + return 'WGS72BE UTM zone 7S'; + case 32508: + return 'WGS72BE UTM zone 8S'; + case 32509: + return 'WGS72BE UTM zone 9S'; + case 32510: + return 'WGS72BE UTM zone 10S'; + case 32511: + return 'WGS72BE UTM zone 11S'; + case 32512: + return 'WGS72BE UTM zone 12S'; + case 32513: + return 'WGS72BE UTM zone 13S'; + case 32514: + return 'WGS72BE UTM zone 14S'; + case 32515: + return 'WGS72BE UTM zone 15S'; + case 32516: + return 'WGS72BE UTM zone 16S'; + case 32517: + return 'WGS72BE UTM zone 17S'; + case 32518: + return 'WGS72BE UTM zone 18S'; + case 32519: + return 'WGS72BE UTM zone 19S'; + case 32520: + return 'WGS72BE UTM zone 20S'; + case 32521: + return 'WGS72BE UTM zone 21S'; + case 32522: + return 'WGS72BE UTM zone 22S'; + case 32523: + return 'WGS72BE UTM zone 23S'; + case 32524: + return 'WGS72BE UTM zone 24S'; + case 32525: + return 'WGS72BE UTM zone 25S'; + case 32526: + return 'WGS72BE UTM zone 26S'; + case 32527: + return 'WGS72BE UTM zone 27S'; + case 32528: + return 'WGS72BE UTM zone 28S'; + case 32529: + return 'WGS72BE UTM zone 29S'; + case 32530: + return 'WGS72BE UTM zone 30S'; + case 32531: + return 'WGS72BE UTM zone 31S'; + case 32532: + return 'WGS72BE UTM zone 32S'; + case 32533: + return 'WGS72BE UTM zone 33S'; + case 32534: + return 'WGS72BE UTM zone 34S'; + case 32535: + return 'WGS72BE UTM zone 35S'; + case 32536: + return 'WGS72BE UTM zone 36S'; + case 32537: + return 'WGS72BE UTM zone 37S'; + case 32538: + return 'WGS72BE UTM zone 38S'; + case 32539: + return 'WGS72BE UTM zone 39S'; + case 32540: + return 'WGS72BE UTM zone 40S'; + case 32541: + return 'WGS72BE UTM zone 41S'; + case 32542: + return 'WGS72BE UTM zone 42S'; + case 32543: + return 'WGS72BE UTM zone 43S'; + case 32544: + return 'WGS72BE UTM zone 44S'; + case 32545: + return 'WGS72BE UTM zone 45S'; + case 32546: + return 'WGS72BE UTM zone 46S'; + case 32547: + return 'WGS72BE UTM zone 47S'; + case 32548: + return 'WGS72BE UTM zone 48S'; + case 32549: + return 'WGS72BE UTM zone 49S'; + case 32550: + return 'WGS72BE UTM zone 50S'; + case 32551: + return 'WGS72BE UTM zone 51S'; + case 32552: + return 'WGS72BE UTM zone 52S'; + case 32553: + return 'WGS72BE UTM zone 53S'; + case 32554: + return 'WGS72BE UTM zone 54S'; + case 32555: + return 'WGS72BE UTM zone 55S'; + case 32556: + return 'WGS72BE UTM zone 56S'; + case 32557: + return 'WGS72BE UTM zone 57S'; + case 32558: + return 'WGS72BE UTM zone 58S'; + case 32559: + return 'WGS72BE UTM zone 59S'; + case 32560: + return 'WGS72BE UTM zone 60S'; + case 32601: + return 'WGS84 UTM zone 1N'; + case 32602: + return 'WGS84 UTM zone 2N'; + case 32603: + return 'WGS84 UTM zone 3N'; + case 32604: + return 'WGS84 UTM zone 4N'; + case 32605: + return 'WGS84 UTM zone 5N'; + case 32606: + return 'WGS84 UTM zone 6N'; + case 32607: + return 'WGS84 UTM zone 7N'; + case 32608: + return 'WGS84 UTM zone 8N'; + case 32609: + return 'WGS84 UTM zone 9N'; + case 32610: + return 'WGS84 UTM zone 10N'; + case 32611: + return 'WGS84 UTM zone 11N'; + case 32612: + return 'WGS84 UTM zone 12N'; + case 32613: + return 'WGS84 UTM zone 13N'; + case 32614: + return 'WGS84 UTM zone 14N'; + case 32615: + return 'WGS84 UTM zone 15N'; + case 32616: + return 'WGS84 UTM zone 16N'; + case 32617: + return 'WGS84 UTM zone 17N'; + case 32618: + return 'WGS84 UTM zone 18N'; + case 32619: + return 'WGS84 UTM zone 19N'; + case 32620: + return 'WGS84 UTM zone 20N'; + case 32621: + return 'WGS84 UTM zone 21N'; + case 32622: + return 'WGS84 UTM zone 22N'; + case 32623: + return 'WGS84 UTM zone 23N'; + case 32624: + return 'WGS84 UTM zone 24N'; + case 32625: + return 'WGS84 UTM zone 25N'; + case 32626: + return 'WGS84 UTM zone 26N'; + case 32627: + return 'WGS84 UTM zone 27N'; + case 32628: + return 'WGS84 UTM zone 28N'; + case 32629: + return 'WGS84 UTM zone 29N'; + case 32630: + return 'WGS84 UTM zone 30N'; + case 32631: + return 'WGS84 UTM zone 31N'; + case 32632: + return 'WGS84 UTM zone 32N'; + case 32633: + return 'WGS84 UTM zone 33N'; + case 32634: + return 'WGS84 UTM zone 34N'; + case 32635: + return 'WGS84 UTM zone 35N'; + case 32636: + return 'WGS84 UTM zone 36N'; + case 32637: + return 'WGS84 UTM zone 37N'; + case 32638: + return 'WGS84 UTM zone 38N'; + case 32639: + return 'WGS84 UTM zone 39N'; + case 32640: + return 'WGS84 UTM zone 40N'; + case 32641: + return 'WGS84 UTM zone 41N'; + case 32642: + return 'WGS84 UTM zone 42N'; + case 32643: + return 'WGS84 UTM zone 43N'; + case 32644: + return 'WGS84 UTM zone 44N'; + case 32645: + return 'WGS84 UTM zone 45N'; + case 32646: + return 'WGS84 UTM zone 46N'; + case 32647: + return 'WGS84 UTM zone 47N'; + case 32648: + return 'WGS84 UTM zone 48N'; + case 32649: + return 'WGS84 UTM zone 49N'; + case 32650: + return 'WGS84 UTM zone 50N'; + case 32651: + return 'WGS84 UTM zone 51N'; + case 32652: + return 'WGS84 UTM zone 52N'; + case 32653: + return 'WGS84 UTM zone 53N'; + case 32654: + return 'WGS84 UTM zone 54N'; + case 32655: + return 'WGS84 UTM zone 55N'; + case 32656: + return 'WGS84 UTM zone 56N'; + case 32657: + return 'WGS84 UTM zone 57N'; + case 32658: + return 'WGS84 UTM zone 58N'; + case 32659: + return 'WGS84 UTM zone 59N'; + case 32660: + return 'WGS84 UTM zone 60N'; + case 32701: + return 'WGS84 UTM zone 1S'; + case 32702: + return 'WGS84 UTM zone 2S'; + case 32703: + return 'WGS84 UTM zone 3S'; + case 32704: + return 'WGS84 UTM zone 4S'; + case 32705: + return 'WGS84 UTM zone 5S'; + case 32706: + return 'WGS84 UTM zone 6S'; + case 32707: + return 'WGS84 UTM zone 7S'; + case 32708: + return 'WGS84 UTM zone 8S'; + case 32709: + return 'WGS84 UTM zone 9S'; + case 32710: + return 'WGS84 UTM zone 10S'; + case 32711: + return 'WGS84 UTM zone 11S'; + case 32712: + return 'WGS84 UTM zone 12S'; + case 32713: + return 'WGS84 UTM zone 13S'; + case 32714: + return 'WGS84 UTM zone 14S'; + case 32715: + return 'WGS84 UTM zone 15S'; + case 32716: + return 'WGS84 UTM zone 16S'; + case 32717: + return 'WGS84 UTM zone 17S'; + case 32718: + return 'WGS84 UTM zone 18S'; + case 32719: + return 'WGS84 UTM zone 19S'; + case 32720: + return 'WGS84 UTM zone 20S'; + case 32721: + return 'WGS84 UTM zone 21S'; + case 32722: + return 'WGS84 UTM zone 22S'; + case 32723: + return 'WGS84 UTM zone 23S'; + case 32724: + return 'WGS84 UTM zone 24S'; + case 32725: + return 'WGS84 UTM zone 25S'; + case 32726: + return 'WGS84 UTM zone 26S'; + case 32727: + return 'WGS84 UTM zone 27S'; + case 32728: + return 'WGS84 UTM zone 28S'; + case 32729: + return 'WGS84 UTM zone 29S'; + case 32730: + return 'WGS84 UTM zone 30S'; + case 32731: + return 'WGS84 UTM zone 31S'; + case 32732: + return 'WGS84 UTM zone 32S'; + case 32733: + return 'WGS84 UTM zone 33S'; + case 32734: + return 'WGS84 UTM zone 34S'; + case 32735: + return 'WGS84 UTM zone 35S'; + case 32736: + return 'WGS84 UTM zone 36S'; + case 32737: + return 'WGS84 UTM zone 37S'; + case 32738: + return 'WGS84 UTM zone 38S'; + case 32739: + return 'WGS84 UTM zone 39S'; + case 32740: + return 'WGS84 UTM zone 40S'; + case 32741: + return 'WGS84 UTM zone 41S'; + case 32742: + return 'WGS84 UTM zone 42S'; + case 32743: + return 'WGS84 UTM zone 43S'; + case 32744: + return 'WGS84 UTM zone 44S'; + case 32745: + return 'WGS84 UTM zone 45S'; + case 32746: + return 'WGS84 UTM zone 46S'; + case 32747: + return 'WGS84 UTM zone 47S'; + case 32748: + return 'WGS84 UTM zone 48S'; + case 32749: + return 'WGS84 UTM zone 49S'; + case 32750: + return 'WGS84 UTM zone 50S'; + case 32751: + return 'WGS84 UTM zone 51S'; + case 32752: + return 'WGS84 UTM zone 52S'; + case 32753: + return 'WGS84 UTM zone 53S'; + case 32754: + return 'WGS84 UTM zone 54S'; + case 32755: + return 'WGS84 UTM zone 55S'; + case 32756: + return 'WGS84 UTM zone 56S'; + case 32757: + return 'WGS84 UTM zone 57S'; + case 32758: + return 'WGS84 UTM zone 58S'; + case 32759: + return 'WGS84 UTM zone 59S'; + case 32760: + return 'WGS84 UTM zone 60S'; + case 32767: + return 'User Defined'; + default: + return 'Unknown ($value)'; + } + } + + static String getProjectionDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 10101: + return 'Alabama CS27 East'; + case 10102: + return 'Alabama CS27 West'; + case 10131: + return 'Alabama CS83 East'; + case 10132: + return 'Alabama CS83 West'; + case 10201: + return 'Arizona Coordinate System east'; + case 10202: + return 'Arizona Coordinate System Central'; + case 10203: + return 'Arizona Coordinate System west'; + case 10231: + return 'Arizona CS83 east'; + case 10232: + return 'Arizona CS83 Central'; + case 10233: + return 'Arizona CS83 west'; + case 10301: + return 'Arkansas CS27 North'; + case 10302: + return 'Arkansas CS27 South'; + case 10331: + return 'Arkansas CS83 North'; + case 10332: + return 'Arkansas CS83 South'; + case 10401: + return 'California CS27 I'; + case 10402: + return 'California CS27 II'; + case 10403: + return 'California CS27 III'; + case 10404: + return 'California CS27 IV'; + case 10405: + return 'California CS27 V'; + case 10406: + return 'California CS27 VI'; + case 10407: + return 'California CS27 VII'; + case 10431: + return 'California CS83 1'; + case 10432: + return 'California CS83 2'; + case 10433: + return 'California CS83 3'; + case 10434: + return 'California CS83 4'; + case 10435: + return 'California CS83 5'; + case 10436: + return 'California CS83 6'; + case 10501: + return 'Colorado CS27 North'; + case 10502: + return 'Colorado CS27 Central'; + case 10503: + return 'Colorado CS27 South'; + case 10531: + return 'Colorado CS83 North'; + case 10532: + return 'Colorado CS83 Central'; + case 10533: + return 'Colorado CS83 South'; + case 10600: + return 'Connecticut CS27'; + case 10630: + return 'Connecticut CS83'; + case 10700: + return 'Delaware CS27'; + case 10730: + return 'Delaware CS83'; + case 10901: + return 'Florida CS27 East'; + case 10902: + return 'Florida CS27 West'; + case 10903: + return 'Florida CS27 North'; + case 10931: + return 'Florida CS83 East'; + case 10932: + return 'Florida CS83 West'; + case 10933: + return 'Florida CS83 North'; + case 11001: + return 'Georgia CS27 East'; + case 11002: + return 'Georgia CS27 West'; + case 11031: + return 'Georgia CS83 East'; + case 11032: + return 'Georgia CS83 West'; + case 11101: + return 'Idaho CS27 East'; + case 11102: + return 'Idaho CS27 Central'; + case 11103: + return 'Idaho CS27 West'; + case 11131: + return 'Idaho CS83 East'; + case 11132: + return 'Idaho CS83 Central'; + case 11133: + return 'Idaho CS83 West'; + case 11201: + return 'Illinois CS27 East'; + case 11202: + return 'Illinois CS27 West'; + case 11231: + return 'Illinois CS83 East'; + case 11232: + return 'Illinois CS83 West'; + case 11301: + return 'Indiana CS27 East'; + case 11302: + return 'Indiana CS27 West'; + case 11331: + return 'Indiana CS83 East'; + case 11332: + return 'Indiana CS83 West'; + case 11401: + return 'Iowa CS27 North'; + case 11402: + return 'Iowa CS27 South'; + case 11431: + return 'Iowa CS83 North'; + case 11432: + return 'Iowa CS83 South'; + case 11501: + return 'Kansas CS27 North'; + case 11502: + return 'Kansas CS27 South'; + case 11531: + return 'Kansas CS83 North'; + case 11532: + return 'Kansas CS83 South'; + case 11601: + return 'Kentucky CS27 North'; + case 11602: + return 'Kentucky CS27 South'; + case 11631: + return 'Kentucky CS83 North'; + case 11632: + return 'Kentucky CS83 South'; + case 11701: + return 'Louisiana CS27 North'; + case 11702: + return 'Louisiana CS27 South'; + case 11731: + return 'Louisiana CS83 North'; + case 11732: + return 'Louisiana CS83 South'; + case 11801: + return 'Maine CS27 East'; + case 11802: + return 'Maine CS27 West'; + case 11831: + return 'Maine CS83 East'; + case 11832: + return 'Maine CS83 West'; + case 11900: + return 'Maryland CS27'; + case 11930: + return 'Maryland CS83'; + case 12001: + return 'Massachusetts CS27 Mainland'; + case 12002: + return 'Massachusetts CS27 Island'; + case 12031: + return 'Massachusetts CS83 Mainland'; + case 12032: + return 'Massachusetts CS83 Island'; + case 12101: + return 'Michigan State Plane East'; + case 12102: + return 'Michigan State Plane Old Central'; + case 12103: + return 'Michigan State Plane West'; + case 12111: + return 'Michigan CS27 North'; + case 12112: + return 'Michigan CS27 Central'; + case 12113: + return 'Michigan CS27 South'; + case 12141: + return 'Michigan CS83 North'; + case 12142: + return 'Michigan CS83 Central'; + case 12143: + return 'Michigan CS83 South'; + case 12201: + return 'Minnesota CS27 North'; + case 12202: + return 'Minnesota CS27 Central'; + case 12203: + return 'Minnesota CS27 South'; + case 12231: + return 'Minnesota CS83 North'; + case 12232: + return 'Minnesota CS83 Central'; + case 12233: + return 'Minnesota CS83 South'; + case 12301: + return 'Mississippi CS27 East'; + case 12302: + return 'Mississippi CS27 West'; + case 12331: + return 'Mississippi CS83 East'; + case 12332: + return 'Mississippi CS83 West'; + case 12401: + return 'Missouri CS27 East'; + case 12402: + return 'Missouri CS27 Central'; + case 12403: + return 'Missouri CS27 West'; + case 12431: + return 'Missouri CS83 East'; + case 12432: + return 'Missouri CS83 Central'; + case 12433: + return 'Missouri CS83 West'; + case 12501: + return 'Montana CS27 North'; + case 12502: + return 'Montana CS27 Central'; + case 12503: + return 'Montana CS27 South'; + case 12530: + return 'Montana CS83'; + case 12601: + return 'Nebraska CS27 North'; + case 12602: + return 'Nebraska CS27 South'; + case 12630: + return 'Nebraska CS83'; + case 12701: + return 'Nevada CS27 East'; + case 12702: + return 'Nevada CS27 Central'; + case 12703: + return 'Nevada CS27 West'; + case 12731: + return 'Nevada CS83 East'; + case 12732: + return 'Nevada CS83 Central'; + case 12733: + return 'Nevada CS83 West'; + case 12800: + return 'New Hampshire CS27'; + case 12830: + return 'New Hampshire CS83'; + case 12900: + return 'New Jersey CS27'; + case 12930: + return 'New Jersey CS83'; + case 13001: + return 'New Mexico CS27 East'; + case 13002: + return 'New Mexico CS27 Central'; + case 13003: + return 'New Mexico CS27 West'; + case 13031: + return 'New Mexico CS83 East'; + case 13032: + return 'New Mexico CS83 Central'; + case 13033: + return 'New Mexico CS83 West'; + case 13101: + return 'New York CS27 East'; + case 13102: + return 'New York CS27 Central'; + case 13103: + return 'New York CS27 West'; + case 13104: + return 'New York CS27 Long Island'; + case 13131: + return 'New York CS83 East'; + case 13132: + return 'New York CS83 Central'; + case 13133: + return 'New York CS83 West'; + case 13134: + return 'New York CS83 Long Island'; + case 13200: + return 'North Carolina CS27'; + case 13230: + return 'North Carolina CS83'; + case 13301: + return 'North Dakota CS27 North'; + case 13302: + return 'North Dakota CS27 South'; + case 13331: + return 'North Dakota CS83 North'; + case 13332: + return 'North Dakota CS83 South'; + case 13401: + return 'Ohio CS27 North'; + case 13402: + return 'Ohio CS27 South'; + case 13431: + return 'Ohio CS83 North'; + case 13432: + return 'Ohio CS83 South'; + case 13501: + return 'Oklahoma CS27 North'; + case 13502: + return 'Oklahoma CS27 South'; + case 13531: + return 'Oklahoma CS83 North'; + case 13532: + return 'Oklahoma CS83 South'; + case 13601: + return 'Oregon CS27 North'; + case 13602: + return 'Oregon CS27 South'; + case 13631: + return 'Oregon CS83 North'; + case 13632: + return 'Oregon CS83 South'; + case 13701: + return 'Pennsylvania CS27 North'; + case 13702: + return 'Pennsylvania CS27 South'; + case 13731: + return 'Pennsylvania CS83 North'; + case 13732: + return 'Pennsylvania CS83 South'; + case 13800: + return 'Rhode Island CS27'; + case 13830: + return 'Rhode Island CS83'; + case 13901: + return 'South Carolina CS27 North'; + case 13902: + return 'South Carolina CS27 South'; + case 13930: + return 'South Carolina CS83'; + case 14001: + return 'South Dakota CS27 North'; + case 14002: + return 'South Dakota CS27 South'; + case 14031: + return 'South Dakota CS83 North'; + case 14032: + return 'South Dakota CS83 South'; + case 14100: + return 'Tennessee CS27'; + case 14130: + return 'Tennessee CS83'; + case 14201: + return 'Texas CS27 North'; + case 14202: + return 'Texas CS27 North Central'; + case 14203: + return 'Texas CS27 Central'; + case 14204: + return 'Texas CS27 South Central'; + case 14205: + return 'Texas CS27 South'; + case 14231: + return 'Texas CS83 North'; + case 14232: + return 'Texas CS83 North Central'; + case 14233: + return 'Texas CS83 Central'; + case 14234: + return 'Texas CS83 South Central'; + case 14235: + return 'Texas CS83 South'; + case 14301: + return 'Utah CS27 North'; + case 14302: + return 'Utah CS27 Central'; + case 14303: + return 'Utah CS27 South'; + case 14331: + return 'Utah CS83 North'; + case 14332: + return 'Utah CS83 Central'; + case 14333: + return 'Utah CS83 South'; + case 14400: + return 'Vermont CS27'; + case 14430: + return 'Vermont CS83'; + case 14501: + return 'Virginia CS27 North'; + case 14502: + return 'Virginia CS27 South'; + case 14531: + return 'Virginia CS83 North'; + case 14532: + return 'Virginia CS83 South'; + case 14601: + return 'Washington CS27 North'; + case 14602: + return 'Washington CS27 South'; + case 14631: + return 'Washington CS83 North'; + case 14632: + return 'Washington CS83 South'; + case 14701: + return 'West Virginia CS27 North'; + case 14702: + return 'West Virginia CS27 South'; + case 14731: + return 'West Virginia CS83 North'; + case 14732: + return 'West Virginia CS83 South'; + case 14801: + return 'Wisconsin CS27 North'; + case 14802: + return 'Wisconsin CS27 Central'; + case 14803: + return 'Wisconsin CS27 South'; + case 14831: + return 'Wisconsin CS83 North'; + case 14832: + return 'Wisconsin CS83 Central'; + case 14833: + return 'Wisconsin CS83 South'; + case 14901: + return 'Wyoming CS27 East'; + case 14902: + return 'Wyoming CS27 East Central'; + case 14903: + return 'Wyoming CS27 West Central'; + case 14904: + return 'Wyoming CS27 West'; + case 14931: + return 'Wyoming CS83 East'; + case 14932: + return 'Wyoming CS83 East Central'; + case 14933: + return 'Wyoming CS83 West Central'; + case 14934: + return 'Wyoming CS83 West'; + case 15001: + return 'Alaska CS27 1'; + case 15002: + return 'Alaska CS27 2'; + case 15003: + return 'Alaska CS27 3'; + case 15004: + return 'Alaska CS27 4'; + case 15005: + return 'Alaska CS27 5'; + case 15006: + return 'Alaska CS27 6'; + case 15007: + return 'Alaska CS27 7'; + case 15008: + return 'Alaska CS27 8'; + case 15009: + return 'Alaska CS27 9'; + case 15010: + return 'Alaska CS27 10'; + case 15031: + return 'Alaska CS83 1'; + case 15032: + return 'Alaska CS83 2'; + case 15033: + return 'Alaska CS83 3'; + case 15034: + return 'Alaska CS83 4'; + case 15035: + return 'Alaska CS83 5'; + case 15036: + return 'Alaska CS83 6'; + case 15037: + return 'Alaska CS83 7'; + case 15038: + return 'Alaska CS83 8'; + case 15039: + return 'Alaska CS83 9'; + case 15040: + return 'Alaska CS83 10'; + case 15101: + return 'Hawaii CS27 1'; + case 15102: + return 'Hawaii CS27 2'; + case 15103: + return 'Hawaii CS27 3'; + case 15104: + return 'Hawaii CS27 4'; + case 15105: + return 'Hawaii CS27 5'; + case 15131: + return 'Hawaii CS83 1'; + case 15132: + return 'Hawaii CS83 2'; + case 15133: + return 'Hawaii CS83 3'; + case 15134: + return 'Hawaii CS83 4'; + case 15135: + return 'Hawaii CS83 5'; + case 15201: + return 'Puerto Rico CS27'; + case 15202: + return 'St Croix'; + case 15230: + return 'Puerto Rico Virgin Is'; + case 15302: + return 'Kentucky CS27'; + case 15303: + return 'Kentucky CS83 North'; + case 15914: + return 'BLM 14N feet'; + case 15915: + return 'BLM 15N feet'; + case 15916: + return 'BLM 16N feet'; + case 15917: + return 'BLM 17N feet'; + case 16001: + return 'UTM zone 1N'; + case 16002: + return 'UTM zone 2N'; + case 16003: + return 'UTM zone 3N'; + case 16004: + return 'UTM zone 4N'; + case 16005: + return 'UTM zone 5N'; + case 16006: + return 'UTM zone 6N'; + case 16007: + return 'UTM zone 7N'; + case 16008: + return 'UTM zone 8N'; + case 16009: + return 'UTM zone 9N'; + case 16010: + return 'UTM zone 10N'; + case 16011: + return 'UTM zone 11N'; + case 16012: + return 'UTM zone 12N'; + case 16013: + return 'UTM zone 13N'; + case 16014: + return 'UTM zone 14N'; + case 16015: + return 'UTM zone 15N'; + case 16016: + return 'UTM zone 16N'; + case 16017: + return 'UTM zone 17N'; + case 16018: + return 'UTM zone 18N'; + case 16019: + return 'UTM zone 19N'; + case 16020: + return 'UTM zone 20N'; + case 16021: + return 'UTM zone 21N'; + case 16022: + return 'UTM zone 22N'; + case 16023: + return 'UTM zone 23N'; + case 16024: + return 'UTM zone 24N'; + case 16025: + return 'UTM zone 25N'; + case 16026: + return 'UTM zone 26N'; + case 16027: + return 'UTM zone 27N'; + case 16028: + return 'UTM zone 28N'; + case 16029: + return 'UTM zone 29N'; + case 16030: + return 'UTM zone 30N'; + case 16031: + return 'UTM zone 31N'; + case 16032: + return 'UTM zone 32N'; + case 16033: + return 'UTM zone 33N'; + case 16034: + return 'UTM zone 34N'; + case 16035: + return 'UTM zone 35N'; + case 16036: + return 'UTM zone 36N'; + case 16037: + return 'UTM zone 37N'; + case 16038: + return 'UTM zone 38N'; + case 16039: + return 'UTM zone 39N'; + case 16040: + return 'UTM zone 40N'; + case 16041: + return 'UTM zone 41N'; + case 16042: + return 'UTM zone 42N'; + case 16043: + return 'UTM zone 43N'; + case 16044: + return 'UTM zone 44N'; + case 16045: + return 'UTM zone 45N'; + case 16046: + return 'UTM zone 46N'; + case 16047: + return 'UTM zone 47N'; + case 16048: + return 'UTM zone 48N'; + case 16049: + return 'UTM zone 49N'; + case 16050: + return 'UTM zone 50N'; + case 16051: + return 'UTM zone 51N'; + case 16052: + return 'UTM zone 52N'; + case 16053: + return 'UTM zone 53N'; + case 16054: + return 'UTM zone 54N'; + case 16055: + return 'UTM zone 55N'; + case 16056: + return 'UTM zone 56N'; + case 16057: + return 'UTM zone 57N'; + case 16058: + return 'UTM zone 58N'; + case 16059: + return 'UTM zone 59N'; + case 16060: + return 'UTM zone 60N'; + case 16101: + return 'UTM zone 1S'; + case 16102: + return 'UTM zone 2S'; + case 16103: + return 'UTM zone 3S'; + case 16104: + return 'UTM zone 4S'; + case 16105: + return 'UTM zone 5S'; + case 16106: + return 'UTM zone 6S'; + case 16107: + return 'UTM zone 7S'; + case 16108: + return 'UTM zone 8S'; + case 16109: + return 'UTM zone 9S'; + case 16110: + return 'UTM zone 10S'; + case 16111: + return 'UTM zone 11S'; + case 16112: + return 'UTM zone 12S'; + case 16113: + return 'UTM zone 13S'; + case 16114: + return 'UTM zone 14S'; + case 16115: + return 'UTM zone 15S'; + case 16116: + return 'UTM zone 16S'; + case 16117: + return 'UTM zone 17S'; + case 16118: + return 'UTM zone 18S'; + case 16119: + return 'UTM zone 19S'; + case 16120: + return 'UTM zone 20S'; + case 16121: + return 'UTM zone 21S'; + case 16122: + return 'UTM zone 22S'; + case 16123: + return 'UTM zone 23S'; + case 16124: + return 'UTM zone 24S'; + case 16125: + return 'UTM zone 25S'; + case 16126: + return 'UTM zone 26S'; + case 16127: + return 'UTM zone 27S'; + case 16128: + return 'UTM zone 28S'; + case 16129: + return 'UTM zone 29S'; + case 16130: + return 'UTM zone 30S'; + case 16131: + return 'UTM zone 31S'; + case 16132: + return 'UTM zone 32S'; + case 16133: + return 'UTM zone 33S'; + case 16134: + return 'UTM zone 34S'; + case 16135: + return 'UTM zone 35S'; + case 16136: + return 'UTM zone 36S'; + case 16137: + return 'UTM zone 37S'; + case 16138: + return 'UTM zone 38S'; + case 16139: + return 'UTM zone 39S'; + case 16140: + return 'UTM zone 40S'; + case 16141: + return 'UTM zone 41S'; + case 16142: + return 'UTM zone 42S'; + case 16143: + return 'UTM zone 43S'; + case 16144: + return 'UTM zone 44S'; + case 16145: + return 'UTM zone 45S'; + case 16146: + return 'UTM zone 46S'; + case 16147: + return 'UTM zone 47S'; + case 16148: + return 'UTM zone 48S'; + case 16149: + return 'UTM zone 49S'; + case 16150: + return 'UTM zone 50S'; + case 16151: + return 'UTM zone 51S'; + case 16152: + return 'UTM zone 52S'; + case 16153: + return 'UTM zone 53S'; + case 16154: + return 'UTM zone 54S'; + case 16155: + return 'UTM zone 55S'; + case 16156: + return 'UTM zone 56S'; + case 16157: + return 'UTM zone 57S'; + case 16158: + return 'UTM zone 58S'; + case 16159: + return 'UTM zone 59S'; + case 16160: + return 'UTM zone 60S'; + case 16200: + return 'Gauss Kruger zone 0'; + case 16201: + return 'Gauss Kruger zone 1'; + case 16202: + return 'Gauss Kruger zone 2'; + case 16203: + return 'Gauss Kruger zone 3'; + case 16204: + return 'Gauss Kruger zone 4'; + case 16205: + return 'Gauss Kruger zone 5'; + case 17348: + return 'Map Grid of Australia 48'; + case 17349: + return 'Map Grid of Australia 49'; + case 17350: + return 'Map Grid of Australia 50'; + case 17351: + return 'Map Grid of Australia 51'; + case 17352: + return 'Map Grid of Australia 52'; + case 17353: + return 'Map Grid of Australia 53'; + case 17354: + return 'Map Grid of Australia 54'; + case 17355: + return 'Map Grid of Australia 55'; + case 17356: + return 'Map Grid of Australia 56'; + case 17357: + return 'Map Grid of Australia 57'; + case 17358: + return 'Map Grid of Australia 58'; + case 17448: + return 'Australian Map Grid 48'; + case 17449: + return 'Australian Map Grid 49'; + case 17450: + return 'Australian Map Grid 50'; + case 17451: + return 'Australian Map Grid 51'; + case 17452: + return 'Australian Map Grid 52'; + case 17453: + return 'Australian Map Grid 53'; + case 17454: + return 'Australian Map Grid 54'; + case 17455: + return 'Australian Map Grid 55'; + case 17456: + return 'Australian Map Grid 56'; + case 17457: + return 'Australian Map Grid 57'; + case 17458: + return 'Australian Map Grid 58'; + case 18031: + return 'Argentina 1'; + case 18032: + return 'Argentina 2'; + case 18033: + return 'Argentina 3'; + case 18034: + return 'Argentina 4'; + case 18035: + return 'Argentina 5'; + case 18036: + return 'Argentina 6'; + case 18037: + return 'Argentina 7'; + case 18051: + return 'Colombia 3W'; + case 18052: + return 'Colombia Bogota'; + case 18053: + return 'Colombia 3E'; + case 18054: + return 'Colombia 6E'; + case 18072: + return 'Egypt Red Belt'; + case 18073: + return 'Egypt Purple Belt'; + case 18074: + return 'Extended Purple Belt'; + case 18141: + return 'New Zealand North Island Nat Grid'; + case 18142: + return 'New Zealand South Island Nat Grid'; + case 19900: + return 'Bahrain Grid'; + case 19905: + return 'Netherlands E Indies Equatorial'; + case 19912: + return 'RSO Borneo'; + case 19926: + return 'Stereo 70'; + case 32767: + return 'User Defined'; + default: + return 'Unknown ($value)'; + } + } + + static String getProjCoordinateTransformDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 1: + return 'Transverse Mercator'; + case 2: + return 'Transverse Mercator Modified Alaska'; + case 3: + return 'Oblique Mercator'; + case 4: + return 'Oblique Mercator Laborde'; + case 5: + return 'Oblique Mercator Rosenmund'; + case 6: + return 'Oblique Mercator Spherical'; + case 7: + return 'Mercator'; + case 8: + return 'Lambert Conf Conic 2SP'; + case 9: + return 'Lambert Conf Conic 1SP'; + case 10: + return 'Lambert Azim Equal Area'; + case 11: + return 'Albers Equal Area'; + case 12: + return 'Azimuthal Equidistant'; + case 13: + return 'Equidistant Conic'; + case 14: + return 'Stereographic'; + case 15: + return 'Polar Stereographic'; + case 16: + return 'Oblique Stereographic'; + case 17: + return 'Equirectangular'; + case 18: + return 'Cassini Soldner'; + case 19: + return 'Gnomonic'; + case 20: + return 'Miller Cylindrical'; + case 21: + return 'Orthographic'; + case 22: + return 'Polyconic'; + case 23: + return 'Robinson'; + case 24: + return 'Sinusoidal'; + case 25: + return 'VanDerGrinten'; + case 26: + return 'New Zealand Map Grid'; + case 27: + return 'Transverse Mercator South Orientated'; + case 28: + return 'Cylindrical Equal Area'; + case 32767: + return 'User Defined'; + default: + return 'Unknown ($value)'; + } + } + + static String getGeoTiffUnitsDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 9001: + return 'Linear Meter'; + case 9002: + return 'Linear Foot'; + case 9003: + return 'Linear Foot US Survey'; + case 9004: + return 'Linear Foot Modified American'; + case 9005: + return 'Linear Foot Clarke'; + case 9006: + return 'Linear Foot Indian'; + case 9007: + return 'Linear Link'; + case 9008: + return 'Linear Link Benoit'; + case 9009: + return 'Linear Link Sears'; + case 9010: + return 'Linear Chain Benoit'; + case 9011: + return 'Linear Chain Sears'; + case 9012: + return 'Linear Yard Sears'; + case 9013: + return 'Linear Yard Indian'; + case 9014: + return 'Linear Fathom'; + case 9015: + return 'Linear Mile International Nautical'; + case 9101: + return 'Angular Radian'; + case 9102: + return 'Angular Degree'; + case 9103: + return 'Angular Arc Minute'; + case 9104: + return 'Angular Arc Second'; + case 9105: + return 'Angular Grad'; + case 9106: + return 'Angular Gon'; + case 9107: + return 'Angular DMS'; + case 9108: + return 'Angular DMS Hemisphere'; + case 32767: + return 'User Defined'; + default: + return 'Unknown ($value)'; + } + } +} diff --git a/lib/widgets/viewer/info/metadata/metadata_dir.dart b/lib/widgets/viewer/info/metadata/metadata_dir.dart new file mode 100644 index 0000000..af71770 --- /dev/null +++ b/lib/widgets/viewer/info/metadata/metadata_dir.dart @@ -0,0 +1,41 @@ +import 'dart:collection'; + +import 'package:flutter/material.dart'; + +class MetadataDirectory { + final String name; + final Color? color; + final String? parent; + final int? index; + final SplayTreeMap<String, String> allTags; + final SplayTreeMap<String, String> tags; + + // special directory names + static const exifThumbnailDirectory = 'Exif Thumbnail'; // from metadata-extractor + static const xmpDirectory = 'XMP'; // from metadata-extractor + static const coverDirectory = 'Cover'; // custom + static const geoTiffDirectory = 'GeoTIFF'; // custom + static const mediaDirectory = 'Media'; // custom + static const mpfImageDirectoryPrefix = 'MPF Image #'; // custom + + const MetadataDirectory( + this.name, + this.allTags, { + SplayTreeMap<String, String>? tags, + this.color, + this.parent, + this.index, + }) : tags = tags ?? allTags; + + MetadataDirectory filterKeys(bool Function(String key) testKey) { + final filteredTags = SplayTreeMap.of(Map.fromEntries(allTags.entries.where((kv) => testKey(kv.key)))); + return MetadataDirectory( + name, + tags, + tags: filteredTags, + color: color, + parent: parent, + index: index, + ); + } +} diff --git a/lib/widgets/viewer/info/metadata/metadata_dir_tile.dart b/lib/widgets/viewer/info/metadata/metadata_dir_tile.dart new file mode 100644 index 0000000..28b0d52 --- /dev/null +++ b/lib/widgets/viewer/info/metadata/metadata_dir_tile.dart @@ -0,0 +1,168 @@ +import 'dart:collection'; + +import 'package:aves/model/entry/entry.dart'; +import 'package:aves/ref/brand_colors.dart'; +import 'package:aves/services/metadata/svg_metadata_service.dart'; +import 'package:aves/theme/colors.dart'; +import 'package:aves/widgets/common/extensions/build_context.dart'; +import 'package:aves/widgets/common/identity/aves_expansion_tile.dart'; +import 'package:aves/widgets/common/identity/buttons/outlined_button.dart'; +import 'package:aves/widgets/viewer/info/common.dart'; +import 'package:aves/widgets/viewer/info/embedded/notifications.dart'; +import 'package:aves/widgets/viewer/info/metadata/geotiff.dart'; +import 'package:aves/widgets/viewer/info/metadata/metadata_dir.dart'; +import 'package:aves/widgets/viewer/info/metadata/metadata_thumbnail.dart'; +import 'package:aves/widgets/viewer/info/metadata/xmp_tile.dart'; +import 'package:aves/widgets/viewer/source_viewer_page.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +class MetadataDirTile extends StatelessWidget { + final AvesEntry entry; + final String title; + final MetadataDirectory dir; + final ValueNotifier<String?>? expandedDirectoryNotifier; + final bool initiallyExpanded, showThumbnails; + + const MetadataDirTile({ + super.key, + required this.entry, + required this.title, + required this.dir, + this.expandedDirectoryNotifier, + this.initiallyExpanded = false, + this.showThumbnails = true, + }); + + @override + Widget build(BuildContext context) { + var tags = dir.tags; + if (tags.isEmpty) return const SizedBox(); + + return AvesExpansionTile( + title: title, + highlightColor: getTitleColor(context, dir), + expandedNotifier: expandedDirectoryNotifier, + initiallyExpanded: initiallyExpanded, + children: [ + MetadataDirTileBody( + entry: entry, + dir: dir, + showThumbnails: showThumbnails, + ), + ], + ); + } + + static Color getTitleColor(BuildContext context, MetadataDirectory dir) { + final dirName = dir.name; + if (dirName == MetadataDirectory.xmpDirectory) { + return context.select<AvesColorsData, Color>((v) => v.xmp); + } else { + final colors = context.watch<AvesColorsData>(); + return dir.color ?? colors.fromBrandColor(BrandColors.get(dirName)) ?? colors.fromString(dirName); + } + } +} + +class MetadataDirTileBody extends StatelessWidget { + final AvesEntry entry; + final MetadataDirectory dir; + final bool showThumbnails; + + const MetadataDirTileBody({ + super.key, + required this.entry, + required this.dir, + this.showThumbnails = true, + }); + + @override + Widget build(BuildContext context) { + var tags = dir.tags; + + late final List<Widget> children; + final dirName = dir.name; + if (dirName == MetadataDirectory.xmpDirectory) { + children = [ + Padding( + padding: const EdgeInsets.only(left: 8, right: 8, bottom: 8), + child: XmpDirTileBody( + allTags: dir.allTags, + tags: tags, + ), + ), + ]; + } else { + Map<String, InfoValueSpanBuilder>? linkHandlers; + switch (dirName) { + case SvgMetadataService.metadataDirectory: + linkHandlers = getSvgLinkHandlers(tags); + case MetadataDirectory.coverDirectory: + linkHandlers = getVideoCoverLinkHandlers(tags); + case MetadataDirectory.geoTiffDirectory: + tags = SplayTreeMap.from(tags.map((name, value) { + final tag = GeoTiffDirectory.tagForName(name); + return MapEntry(name, GeoTiffDirectory.formatValue(tag, value)); + })); + } + + children = [ + if (showThumbnails && dirName == MetadataDirectory.exifThumbnailDirectory) MetadataThumbnails(entry: entry), + if (dirName.startsWith(MetadataDirectory.mpfImageDirectoryPrefix)) + Padding( + padding: const EdgeInsets.symmetric(horizontal: 8), + child: AvesOutlinedButton( + label: context.l10n.viewerInfoOpenLinkText, + onPressed: () { + final id = int.tryParse(dirName.substring(MetadataDirectory.mpfImageDirectoryPrefix.length)); + if (id != null) { + OpenEmbeddedDataNotification.mpf(id).dispatch(context); + } + }, + ), + ), + Padding( + padding: const EdgeInsets.only(left: 8, right: 8, bottom: 8), + child: InfoRowGroup( + info: tags, + spanBuilders: linkHandlers, + ), + ), + ]; + } + + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: children, + ); + } + + static Map<String, InfoValueSpanBuilder> getSvgLinkHandlers(SplayTreeMap<String, String> tags) { + return { + 'Metadata': InfoRowGroup.linkSpanBuilder( + linkText: (context) => context.l10n.viewerInfoViewXmlLinkText, + onTap: (context) { + Navigator.maybeOf(context)?.push( + MaterialPageRoute( + settings: const RouteSettings(name: SourceViewerPage.routeName), + builder: (context) => SourceViewerPage( + loader: () => SynchronousFuture(tags['Metadata'] ?? ''), + ), + ), + ); + }, + ), + }; + } + + static Map<String, InfoValueSpanBuilder> getVideoCoverLinkHandlers(SplayTreeMap<String, String> tags) { + return { + 'Image': InfoRowGroup.linkSpanBuilder( + linkText: (context) => context.l10n.viewerInfoOpenLinkText, + onTap: (context) => OpenEmbeddedDataNotification.videoCover().dispatch(context), + ), + }; + } +} diff --git a/lib/widgets/viewer/info/metadata/metadata_section.dart b/lib/widgets/viewer/info/metadata/metadata_section.dart new file mode 100644 index 0000000..00f24d5 --- /dev/null +++ b/lib/widgets/viewer/info/metadata/metadata_section.dart @@ -0,0 +1,152 @@ +import 'dart:async'; + +import 'package:aves/model/entry/entry.dart'; +import 'package:aves/model/entry/extensions/info.dart'; +import 'package:aves/model/settings/settings.dart'; +import 'package:aves/theme/durations.dart'; +import 'package:aves/theme/icons.dart'; +import 'package:aves/widgets/common/identity/buttons/outlined_button.dart'; +import 'package:aves/widgets/viewer/info/common.dart'; +import 'package:aves/widgets/viewer/info/metadata/metadata_dir.dart'; +import 'package:aves/widgets/viewer/info/metadata/metadata_dir_tile.dart'; +import 'package:aves/widgets/viewer/info/metadata/tv_page.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/scheduler.dart'; +import 'package:flutter_staggered_animations/flutter_staggered_animations.dart'; +import 'package:provider/provider.dart'; + +class MetadataSectionSliver extends StatefulWidget { + final AvesEntry entry; + final ValueNotifier<Map<String, MetadataDirectory>> metadataNotifier; + + const MetadataSectionSliver({ + super.key, + required this.entry, + required this.metadataNotifier, + }); + + @override + State<StatefulWidget> createState() => _MetadataSectionSliverState(); +} + +class _MetadataSectionSliverState extends State<MetadataSectionSliver> { + final ValueNotifier<String?> _expandedDirectoryNotifier = ValueNotifier(null); + + AvesEntry get entry => widget.entry; + + ValueNotifier<Map<String, MetadataDirectory>> get metadataNotifier => widget.metadataNotifier; + + @override + void initState() { + super.initState(); + _registerWidget(widget); + metadataNotifier.value = {}; + _getMetadata(); + } + + @override + void didUpdateWidget(covariant MetadataSectionSliver oldWidget) { + super.didUpdateWidget(oldWidget); + _unregisterWidget(oldWidget); + _registerWidget(widget); + _getMetadata(); + } + + @override + void dispose() { + _unregisterWidget(widget); + _expandedDirectoryNotifier.dispose(); + super.dispose(); + } + + void _registerWidget(MetadataSectionSliver widget) { + widget.entry.metadataChangeNotifier.addListener(_onMetadataChanged); + } + + void _unregisterWidget(MetadataSectionSliver widget) { + widget.entry.metadataChangeNotifier.removeListener(_onMetadataChanged); + } + + @override + Widget build(BuildContext context) { + // use a `Column` inside a `SliverToBoxAdapter`, instead of a `SliverList`, + // so that we can have the metadata-dependent `AnimationLimiter` inside the metadata section + // warning: placing the `AnimationLimiter` as a parent to the `ScrollView` + // triggers dispose & reinitialization of other sections, including heavy widgets like maps + return SliverToBoxAdapter( + child: NotificationListener<ScrollNotification>( + // cancel notification bubbling so that the info page + // does not misinterpret content scrolling for page scrolling + onNotification: (notification) => true, + child: ValueListenableBuilder<Map<String, MetadataDirectory>>( + valueListenable: metadataNotifier, + builder: (context, metadata, child) { + Widget content; + if (metadata.isEmpty) { + content = const SizedBox(); + } else { + final durations = context.watch<DurationsData>(); + content = Column( + children: AnimationConfiguration.toStaggeredList( + duration: durations.staggeredAnimation, + delay: durations.staggeredAnimationDelay * timeDilation, + childAnimationBuilder: (child) => SlideAnimation( + verticalOffset: 50.0, + child: FadeInAnimation( + child: child, + ), + ), + children: settings.useTvLayout + ? [ + const SizedBox(height: 16), + AvesOutlinedButton( + label: MaterialLocalizations.of(context).moreButtonTooltip, + onPressed: () { + Navigator.maybeOf(context)?.push( + MaterialPageRoute( + settings: const RouteSettings(name: TvMetadataPage.routeName), + builder: (context) => TvMetadataPage( + entry: entry, + metadata: metadata, + ), + ), + ); + }, + ), + ] + : [ + const SectionRow(icon: AIcons.info), + ...metadata.entries.map((kv) => MetadataDirTile( + entry: entry, + title: kv.key, + dir: kv.value, + expandedDirectoryNotifier: _expandedDirectoryNotifier, + )), + ], + ), + ); + } + + return AnimationLimiter( + // we update the limiter key after fetching the metadata of a new entry, + // in order to restart the staggered animation of the metadata section + key: ValueKey(metadata.length), + child: content, + ); + }), + ), + ); + } + + void _onMetadataChanged() { + metadataNotifier.value = {}; + _getMetadata(); + } + + Future<void> _getMetadata() async { + final titledDirectories = await entry.getMetadataDirectories(context); + if (!mounted) return; + metadataNotifier.value = Map.fromEntries(titledDirectories); + _expandedDirectoryNotifier.value = null; + } +} diff --git a/lib/widgets/viewer/info/metadata/metadata_thumbnail.dart b/lib/widgets/viewer/info/metadata/metadata_thumbnail.dart new file mode 100644 index 0000000..5eac1f1 --- /dev/null +++ b/lib/widgets/viewer/info/metadata/metadata_thumbnail.dart @@ -0,0 +1,59 @@ +import 'dart:async'; +import 'dart:ui' as ui; + +import 'package:aves/image_providers/descriptor_provider.dart'; +import 'package:aves/model/entry/entry.dart'; +import 'package:aves/services/common/services.dart'; +import 'package:flutter/material.dart'; + +class MetadataThumbnails extends StatefulWidget { + final AvesEntry entry; + + const MetadataThumbnails({ + super.key, + required this.entry, + }); + + @override + State<MetadataThumbnails> createState() => _MetadataThumbnailsState(); +} + +class _MetadataThumbnailsState extends State<MetadataThumbnails> { + late Future<List<ui.ImageDescriptor?>> _loader; + + AvesEntry get entry => widget.entry; + + String get uri => entry.uri; + + @override + void initState() { + super.initState(); + _loader = embeddedDataService.getExifThumbnails(entry); + } + + @override + Widget build(BuildContext context) { + return FutureBuilder<List<ui.ImageDescriptor?>>( + future: _loader, + builder: (context, snapshot) { + if (!snapshot.hasError && snapshot.connectionState == ConnectionState.done && snapshot.data!.isNotEmpty) { + return Container( + alignment: AlignmentDirectional.topStart, + padding: const EdgeInsets.only(left: 8, top: 8, right: 8, bottom: 4), + child: Wrap( + children: snapshot.data!.map((descriptor) { + if (descriptor == null) return const SizedBox(); + return Image( + image: DescriptorImageProvider( + descriptor, + scale: MediaQuery.devicePixelRatioOf(context), + ), + ); + }).toList(), + ), + ); + } + return const SizedBox(); + }); + } +} diff --git a/lib/widgets/viewer/info/metadata/tv_page.dart b/lib/widgets/viewer/info/metadata/tv_page.dart new file mode 100644 index 0000000..0cfbae5 --- /dev/null +++ b/lib/widgets/viewer/info/metadata/tv_page.dart @@ -0,0 +1,122 @@ +import 'package:aves/model/entry/entry.dart'; +import 'package:aves/theme/icons.dart'; +import 'package:aves/widgets/common/basic/scaffold.dart'; +import 'package:aves/widgets/common/behaviour/intents.dart'; +import 'package:aves/widgets/common/extensions/build_context.dart'; +import 'package:aves/widgets/navigation/tv_rail.dart'; +import 'package:aves/widgets/viewer/info/metadata/metadata_dir.dart'; +import 'package:aves/widgets/viewer/info/metadata/metadata_dir_tile.dart'; +import 'package:collection/collection.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; + +class TvMetadataPage extends StatefulWidget { + static const routeName = '/info/metadata'; + + final AvesEntry entry; + final Map<String, MetadataDirectory> metadata; + + const TvMetadataPage({ + super.key, + required this.entry, + required this.metadata, + }); + + @override + State<TvMetadataPage> createState() => _TvMetadataPageState(); +} + +class _TvMetadataPageState extends State<TvMetadataPage> { + final ValueNotifier<int> _railIndexNotifier = ValueNotifier(0); + final FocusNode _railFocusNode = FocusNode(); + final ScrollController _detailsScrollController = ScrollController(); + + Map<String, MetadataDirectory> get metadata => widget.metadata; + + @override + void initState() { + super.initState(); + WidgetsBinding.instance.addPostFrameCallback((_) { + _railFocusNode.children.firstOrNull?.requestFocus(); + }); + } + + @override + void dispose() { + _railIndexNotifier.dispose(); + _railFocusNode.dispose(); + _detailsScrollController.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return AvesScaffold( + appBar: AppBar( + automaticallyImplyLeading: false, + title: Text(context.l10n.viewerInfoPageTitle), + ), + body: ValueListenableBuilder<int>( + valueListenable: _railIndexNotifier, + builder: (context, selectedIndex, child) { + final titles = metadata.keys.toList(); + final selectedDir = metadata[titles[selectedIndex]]; + if (selectedDir == null) return const SizedBox(); + + final rail = NavigationRail( + extended: true, + destinations: titles.mapIndexed((i, title) { + final dir = metadata[titles[i]]!; + final color = MetadataDirTile.getTitleColor(context, dir); + return NavigationRailDestination( + icon: Icon(AIcons.circle, fill: 1, color: color), + label: Text(title), + ); + }).toList(), + selectedIndex: selectedIndex, + onDestinationSelected: (index) => _railIndexNotifier.value = index, + minExtendedWidth: TvRail.minExtendedWidth, + ); + + return SafeArea( + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const SizedBox(width: 16), + Focus( + focusNode: _railFocusNode, + skipTraversal: true, + canRequestFocus: false, + child: SingleChildScrollView( + child: IntrinsicHeight( + child: rail, + ), + ), + ), + Expanded( + child: FocusableActionDetector( + shortcuts: const { + SingleActivator(LogicalKeyboardKey.arrowUp): ScrollIntent(direction: AxisDirection.up, type: ScrollIncrementType.page), + SingleActivator(LogicalKeyboardKey.arrowDown): ScrollIntent(direction: AxisDirection.down, type: ScrollIncrementType.page), + }, + actions: { + ScrollIntent: ScrollControllerAction(scrollController: _detailsScrollController), + }, + child: SingleChildScrollView( + controller: _detailsScrollController, + padding: const EdgeInsets.all(16), + child: MetadataDirTileBody( + entry: widget.entry, + dir: selectedDir, + ), + ), + ), + ), + ], + ), + ); + }, + ), + ); + } +} diff --git a/lib/widgets/viewer/info/metadata/xmp_card.dart b/lib/widgets/viewer/info/metadata/xmp_card.dart new file mode 100644 index 0000000..ba46bb1 --- /dev/null +++ b/lib/widgets/viewer/info/metadata/xmp_card.dart @@ -0,0 +1,158 @@ +import 'dart:math'; + +import 'package:aves/theme/durations.dart'; +import 'package:aves/theme/icons.dart'; +import 'package:aves/widgets/common/basic/multi_cross_fader.dart'; +import 'package:aves/widgets/common/extensions/build_context.dart'; +import 'package:aves/widgets/common/identity/highlight_title.dart'; +import 'package:aves/widgets/viewer/info/common.dart'; +import 'package:aves/widgets/viewer/info/metadata/xmp_namespaces.dart'; +import 'package:flutter/material.dart'; + +typedef XmpExtractedCard = (Map<String, XmpProp>, List<XmpCardData>?); + +class XmpCard extends StatefulWidget { + final String title; + late final XmpExtractedCard? directStruct; + late final List<XmpExtractedCard>? indexedStructs; + final String Function(XmpProp prop) formatValue; + final Map<String, InfoValueSpanBuilder> Function(int? index)? spanBuilders; + + XmpCard({ + super.key, + required this.title, + required Map<int?, XmpExtractedCard> structByIndex, + required this.formatValue, + this.spanBuilders, + }) { + directStruct = structByIndex[null]; + + final length = structByIndex.keys.nonNulls.fold(0, max); + indexedStructs = length > 0 ? [for (var i = 0; i < length; i++) structByIndex[i + 1] ?? const ({}, null)] : null; + } + + @override + State<XmpCard> createState() => _XmpCardState(); +} + +class _XmpCardState extends State<XmpCard> { + final ValueNotifier<int> _indexNotifier = ValueNotifier(0); + + List<XmpExtractedCard>? get indexedStructs => widget.indexedStructs; + + bool get isIndexed => indexedStructs != null; + + int get indexedStructCount => indexedStructs?.length ?? 0; + + @override + void initState() { + super.initState(); + if (isIndexed) { + _indexNotifier.value = indexedStructCount - 1; + } + } + + @override + void didUpdateWidget(covariant XmpCard oldWidget) { + super.didUpdateWidget(oldWidget); + if (isIndexed && _indexNotifier.value >= indexedStructCount) { + _indexNotifier.value = indexedStructCount - 1; + } + } + + @override + void dispose() { + _indexNotifier.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + final _isIndexed = isIndexed; + + return Container( + decoration: BoxDecoration( + border: Border.all( + color: Theme.of(context).dividerColor, + ), + borderRadius: const BorderRadius.all(Radius.circular(4)), + ), + child: ValueListenableBuilder<int>( + valueListenable: _indexNotifier, + builder: (context, index, child) { + final data = _isIndexed ? indexedStructs![index] : widget.directStruct!; + final props = data.$1.entries.map((kv) => XmpProp(kv.key, kv.value.value)).toList()..sort(); + final cards = data.$2; + + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.only(left: 8, top: 8, right: 8), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + child: HighlightTitle( + title: widget.title, + showHighlight: false, + ), + ), + if (_isIndexed) ...[ + IconButton( + visualDensity: VisualDensity.compact, + icon: const Icon(AIcons.previous), + onPressed: index > 0 ? () => _setIndex(index - 1) : null, + tooltip: context.l10n.previousTooltip, + ), + HighlightTitle( + title: '${index + 1}', + showHighlight: false, + ), + IconButton( + visualDensity: VisualDensity.compact, + icon: const Icon(AIcons.next), + onPressed: index < indexedStructCount - 1 ? () => _setIndex(index + 1) : null, + tooltip: context.l10n.nextTooltip, + ), + ] + ], + ), + ), + MultiCrossFader( + duration: ADurations.xmpStructArrayCardTransition, + sizeCurve: Curves.easeOutBack, + alignment: AlignmentDirectional.topStart, + child: Padding( + // add padding at this level (instead of the column level) + // so that the crossfader can animate the content size + // without clipping the text + padding: const EdgeInsets.only(left: 8, right: 8, bottom: 8), + child: InfoRowGroup( + info: Map.fromEntries(props.map((prop) => MapEntry(prop.displayKey, widget.formatValue(prop)))), + spanBuilders: widget.spanBuilders?.call(_isIndexed ? index + 1 : null), + ), + ), + ), + if (cards != null) + ...cards.where((v) => !v.isEmpty).map((card) { + final spanBuilders = card.spanBuilders; + return Padding( + padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 8), + child: XmpCard( + title: card.title, + structByIndex: card.data, + formatValue: widget.formatValue, + spanBuilders: spanBuilders != null ? (index) => spanBuilders(index, card.data[index]!.$1) : null, + ), + ); + }), + ], + ); + }, + ), + ); + } + + void _setIndex(int index) => _indexNotifier.value = index.clamp(0, indexedStructCount - 1); +} diff --git a/lib/widgets/viewer/info/metadata/xmp_namespaces.dart b/lib/widgets/viewer/info/metadata/xmp_namespaces.dart new file mode 100644 index 0000000..f16f266 --- /dev/null +++ b/lib/widgets/viewer/info/metadata/xmp_namespaces.dart @@ -0,0 +1,247 @@ +import 'package:aves/ref/brand_colors.dart'; +import 'package:aves/ref/metadata/xmp.dart'; +import 'package:aves/theme/colors.dart'; +import 'package:aves/utils/string_utils.dart'; +import 'package:aves/utils/xmp_utils.dart'; +import 'package:aves/view/view.dart'; +import 'package:aves/widgets/common/identity/highlight_title.dart'; +import 'package:aves/widgets/viewer/info/common.dart'; +import 'package:aves/widgets/viewer/info/metadata/xmp_card.dart'; +import 'package:aves/widgets/viewer/info/metadata/xmp_ns/crs.dart'; +import 'package:aves/widgets/viewer/info/metadata/xmp_ns/exif.dart'; +import 'package:aves/widgets/viewer/info/metadata/xmp_ns/google.dart'; +import 'package:aves/widgets/viewer/info/metadata/xmp_ns/misc.dart'; +import 'package:aves/widgets/viewer/info/metadata/xmp_ns/photoshop.dart'; +import 'package:aves/widgets/viewer/info/metadata/xmp_ns/tiff.dart'; +import 'package:aves/widgets/viewer/info/metadata/xmp_ns/xmp.dart'; +import 'package:collection/collection.dart'; +import 'package:equatable/equatable.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +@immutable +class XmpNamespace extends Equatable { + final Map<String, String> schemaRegistryPrefixes; + final String nsUri, nsPrefix; + final Map<String, String> rawProps; + + @override + List<Object?> get props => [nsUri, nsPrefix]; + + XmpNamespace({ + required this.nsUri, + required this.schemaRegistryPrefixes, + required this.rawProps, + }) : nsPrefix = prefixForUri(schemaRegistryPrefixes, nsUri); + + factory XmpNamespace.create(Map<String, String> schemaRegistryPrefixes, String nsPrefix, Map<String, String> rawProps) { + final nsUri = schemaRegistryPrefixes[nsPrefix] ?? ''; + switch (nsUri) { + case XmpNamespaces.creatorAtom: + return XmpCreatorAtom(schemaRegistryPrefixes: schemaRegistryPrefixes, rawProps: rawProps); + case XmpNamespaces.crs: + return XmpCrsNamespace(schemaRegistryPrefixes: schemaRegistryPrefixes, rawProps: rawProps); + case XmpNamespaces.darktable: + return XmpDarktableNamespace(schemaRegistryPrefixes: schemaRegistryPrefixes, rawProps: rawProps); + case XmpNamespaces.dwc: + return XmpDwcNamespace(schemaRegistryPrefixes: schemaRegistryPrefixes, rawProps: rawProps); + case XmpNamespaces.exif: + return XmpExifNamespace(schemaRegistryPrefixes: schemaRegistryPrefixes, rawProps: rawProps); + case XmpNamespaces.gAudio: + return XmpGAudioNamespace(schemaRegistryPrefixes: schemaRegistryPrefixes, rawProps: rawProps); + case XmpNamespaces.gCamera: + return XmpGCameraNamespace(schemaRegistryPrefixes: schemaRegistryPrefixes, rawProps: rawProps); + case XmpNamespaces.gContainer: + return XmpGContainer(schemaRegistryPrefixes: schemaRegistryPrefixes, rawProps: rawProps); + case XmpNamespaces.gDepth: + return XmpGDepthNamespace(schemaRegistryPrefixes: schemaRegistryPrefixes, rawProps: rawProps); + case XmpNamespaces.gDevice: + return XmpGDeviceNamespace(schemaRegistryPrefixes: schemaRegistryPrefixes, rawProps: rawProps); + case XmpNamespaces.gImage: + return XmpGImageNamespace(schemaRegistryPrefixes: schemaRegistryPrefixes, rawProps: rawProps); + case XmpNamespaces.iptc4xmpCore: + return XmpIptcCoreNamespace(schemaRegistryPrefixes: schemaRegistryPrefixes, rawProps: rawProps); + case XmpNamespaces.iptc4xmpExt: + return XmpIptc4xmpExtNamespace(schemaRegistryPrefixes: schemaRegistryPrefixes, rawProps: rawProps); + case XmpNamespaces.mwgrs: + return XmpMgwRegionsNamespace(schemaRegistryPrefixes: schemaRegistryPrefixes, rawProps: rawProps); + case XmpNamespaces.mp: + return XmpMPNamespace(schemaRegistryPrefixes: schemaRegistryPrefixes, rawProps: rawProps); + case XmpNamespaces.photoshop: + return XmpPhotoshopNamespace(schemaRegistryPrefixes: schemaRegistryPrefixes, rawProps: rawProps); + case XmpNamespaces.plus: + return XmpPlusNamespace(schemaRegistryPrefixes: schemaRegistryPrefixes, rawProps: rawProps); + case XmpNamespaces.tiff: + return XmpTiffNamespace(schemaRegistryPrefixes: schemaRegistryPrefixes, rawProps: rawProps); + case XmpNamespaces.xmp: + return XmpBasicNamespace(schemaRegistryPrefixes: schemaRegistryPrefixes, rawProps: rawProps); + case XmpNamespaces.xmpMM: + return XmpMMNamespace(schemaRegistryPrefixes: schemaRegistryPrefixes, rawProps: rawProps); + case XmpNamespaces.xperiaCamera: + return XmpXperiaCameraNamespace(schemaRegistryPrefixes: schemaRegistryPrefixes, rawProps: rawProps); + default: + return XmpNamespace(nsUri: nsUri, schemaRegistryPrefixes: schemaRegistryPrefixes, rawProps: rawProps); + } + } + + String get displayTitle => XmpNamespaceView.nsTitles[nsUri] ?? (nsPrefix.isEmpty ? nsUri : '${nsPrefix.substring(0, nsPrefix.length - 1)} ($nsUri)'); + + List<Widget> buildNamespaceSection(BuildContext context) { + final props = rawProps.entries + .map((kv) { + final key = kv.key; + if (skippedProps.any((pattern) => pattern.allMatches(key).isNotEmpty)) { + return null; + } + final prop = XmpProp(key, kv.value); + var extracted = false; + cards.forEach((card) => extracted |= card.extract(prop)); + return extracted ? null : prop; + }) + .nonNulls + .toList() + ..sort(); + + final content = [ + if (props.isNotEmpty) + InfoRowGroup( + info: Map.fromEntries(props.map((v) => MapEntry(v.displayKey, formatValue(v)))), + spanBuilders: linkifyValues(props), + ), + ...cards.where((v) => !v.isEmpty).map((card) { + final spanBuilders = card.spanBuilders; + return Padding( + padding: const EdgeInsets.only(top: 8), + child: XmpCard( + title: card.title, + structByIndex: card.data, + formatValue: formatValue, + spanBuilders: spanBuilders != null ? (index) => spanBuilders(index, card.data[index]!.$1) : null, + ), + ); + }), + ]; + + return content.isNotEmpty + ? [ + if (displayTitle.isNotEmpty) + Padding( + padding: const EdgeInsets.only(top: 8, bottom: 4), + child: HighlightTitle( + title: displayTitle, + color: context.select<AvesColorsData, Color?>((v) => v.fromBrandColor(BrandColors.get(displayTitle))), + ), + ), + ...content + ] + : []; + } + + Set<RegExp> get skippedProps => {}; + + List<XmpCardData> get cards => []; + + String formatValue(XmpProp prop) => prop.value; + + Map<String, InfoValueSpanBuilder> linkifyValues(List<XmpProp> props) => {}; + + static String prefixForUri(Map<String, String> schemaRegistryPrefixes, String nsUri) => schemaRegistryPrefixes.entries.firstWhereOrNull((kv) => kv.value == nsUri)?.key ?? ''; +} + +class XmpProp implements Comparable<XmpProp> { + final String path, value; + final String displayKey; + + XmpProp(this.path, this.value) : displayKey = formatKey(path); + + static String formatKey(String propPath) { + return propPath.splitMapJoin(XMP.structFieldSeparator, + onMatch: (match) => ' ${match.group(0)} ', + onNonMatch: (s) { + // strip namespace + final key = s.split(XMP.propNamespaceSeparator).last; + // format + return key.replaceAll('_', ' ').toSentenceCase(); + }); + } + + @override + int compareTo(XmpProp other) => compareAsciiUpperCaseNatural(displayKey, other.displayKey); + + @override + String toString() => '$runtimeType#${shortHash(this)}{path=$path, value=$value}'; +} + +class XmpCardData { + final String title; + final RegExp pattern; + final bool indexed; + final Map<String, InfoValueSpanBuilder> Function(int?, Map<String, XmpProp> data)? spanBuilders; + final List<XmpCardData>? cards; + final Map<int?, XmpExtractedCard> data = {}; + + bool get isEmpty => data.isEmpty && (cards?.every((card) => card.isEmpty) ?? true); + + static final titlePattern = RegExp(r'(.*?)[\\/]'); + + XmpCardData( + this.pattern, { + String? title, + this.spanBuilders, + this.cards, + }) : indexed = pattern.pattern.contains(r'\[(\d+)\]'), + title = title ?? XmpProp.formatKey(titlePattern.firstMatch(pattern.pattern)!.group(1)!); + + XmpCardData cloneEmpty() { + return XmpCardData( + pattern, + title: title, + spanBuilders: spanBuilders, + cards: cards?.map((v) => v.cloneEmpty()).toList(), + ); + } + + bool extract(XmpProp prop) => indexed ? _extractIndexedStruct(prop) : _extractDirectStruct(prop); + + bool _extractDirectStruct(XmpProp prop) { + final matches = pattern.allMatches(prop.path); + if (matches.isEmpty) return false; + + final match = matches.first; + final field = match.group(1)!; + + final fields = data.putIfAbsent(null, () => (<String, XmpProp>{}, cards?.map((v) => v.cloneEmpty()).toList())); + final _cards = fields.$2; + if (_cards != null) { + final fieldProp = XmpProp(field, prop.value); + if (_cards.any((v) => v.extract(fieldProp))) { + return true; + } + } + + fields.$1[field] = prop; + return true; + } + + bool _extractIndexedStruct(XmpProp prop) { + final matches = pattern.allMatches(prop.path); + if (matches.isEmpty) return false; + + final match = matches.first; + final index = int.parse(match.group(1)!); + final field = match.group(2)!; + + final fields = data.putIfAbsent(index, () => (<String, XmpProp>{}, cards?.map((v) => v.cloneEmpty()).toList())); + final _cards = fields.$2; + if (_cards != null) { + final fieldProp = XmpProp(field, prop.value); + if (_cards.any((v) => v.extract(fieldProp))) { + return true; + } + } + + fields.$1[field] = prop; + return true; + } +} diff --git a/lib/widgets/viewer/info/metadata/xmp_ns/crs.dart b/lib/widgets/viewer/info/metadata/xmp_ns/crs.dart new file mode 100644 index 0000000..15e987d --- /dev/null +++ b/lib/widgets/viewer/info/metadata/xmp_ns/crs.dart @@ -0,0 +1,50 @@ +import 'package:aves/ref/metadata/xmp.dart'; +import 'package:aves/widgets/viewer/info/metadata/xmp_namespaces.dart'; + +class XmpCrsNamespace extends XmpNamespace { + XmpCrsNamespace({required super.schemaRegistryPrefixes, required super.rawProps}) : super(nsUri: XmpNamespaces.crs); + + @override + late final List<XmpCardData> cards = [ + XmpCardData(RegExp(nsPrefix + r'CircularGradientBasedCorrections\[(\d+)\]/(.*)')), + XmpCardData( + RegExp(nsPrefix + r'GradientBasedCorrections\[(\d+)\]/(.*)'), + cards: [ + XmpCardData(RegExp(nsPrefix + r'CorrectionMasks\[(\d+)\]/(.*)')), + XmpCardData(RegExp(nsPrefix + r'CorrectionRangeMask/(.*)')), + ], + ), + XmpCardData( + RegExp(nsPrefix + r'Look/(.*)'), + cards: [ + XmpCardData(RegExp(nsPrefix + r'Parameters/(.*)')), + ], + ), + XmpCardData( + RegExp(nsPrefix + r'MaskGroupBasedCorrections\[(\d+)\]/(.*)'), + cards: [ + XmpCardData( + RegExp(nsPrefix + r'CorrectionMasks\[(\d+)\]/(.*)'), + cards: [ + XmpCardData(RegExp(nsPrefix + r'CorrectionRangeMask/(.*)')), + XmpCardData(RegExp(nsPrefix + r'Masks\[(\d+)\]/(.*)')), + ], + ), + ], + ), + XmpCardData( + RegExp(nsPrefix + r'PaintBasedCorrections\[(\d+)\]/(.*)'), + cards: [ + XmpCardData(RegExp(nsPrefix + r'CorrectionMasks\[(\d+)\]/(.*)')), + XmpCardData(RegExp(nsPrefix + r'CorrectionRangeMask/(.*)')), + ], + ), + XmpCardData( + RegExp(nsPrefix + r'RetouchAreas\[(\d+)\]/(.*)'), + cards: [ + XmpCardData(RegExp(nsPrefix + r'Masks\[(\d+)\]/(.*)')), + ], + ), + XmpCardData(RegExp(nsPrefix + r'RangeMaskMapInfo/' + nsPrefix + r'RangeMaskMapInfo/(.*)')), + ]; +} diff --git a/lib/widgets/viewer/info/metadata/xmp_ns/exif.dart b/lib/widgets/viewer/info/metadata/xmp_ns/exif.dart new file mode 100644 index 0000000..bbbf677 --- /dev/null +++ b/lib/widgets/viewer/info/metadata/xmp_ns/exif.dart @@ -0,0 +1,75 @@ +import 'package:aves/ref/metadata/exif.dart'; +import 'package:aves/ref/metadata/xmp.dart'; +import 'package:aves/widgets/viewer/info/metadata/xmp_namespaces.dart'; + +// cf https://github.com/adobe/xmp-docs/blob/master/XMPNamespaces/exif.md +class XmpExifNamespace extends XmpNamespace { + XmpExifNamespace({required super.schemaRegistryPrefixes, required super.rawProps}) : super(nsUri: XmpNamespaces.exif); + + @override + String formatValue(XmpProp prop) { + final v = prop.value; + final field = prop.path.replaceAll(nsPrefix, ''); + switch (field) { + case 'ColorSpace': + return Exif.getColorSpaceDescription(v); + case 'Contrast': + return Exif.getContrastDescription(v); + case 'CustomRendered': + return Exif.getCustomRenderedDescription(v); + case 'ExifVersion': + case 'FlashpixVersion': + return Exif.getExifVersionDescription(v); + case 'ExposureMode': + return Exif.getExposureModeDescription(v); + case 'ExposureProgram': + return Exif.getExposureProgramDescription(v); + case 'FileSource': + return Exif.getFileSourceDescription(v); + case 'Flash/Mode': + return Exif.getFlashModeDescription(v); + case 'Flash/Return': + return Exif.getFlashReturnDescription(v); + case 'FocalPlaneResolutionUnit': + return Exif.getResolutionUnitDescription(v); + case 'GainControl': + return Exif.getGainControlDescription(v); + case 'LightSource': + return Exif.getLightSourceDescription(v); + case 'MeteringMode': + return Exif.getMeteringModeDescription(v); + case 'Saturation': + return Exif.getSaturationDescription(v); + case 'SceneCaptureType': + return Exif.getSceneCaptureTypeDescription(v); + case 'SceneType': + return Exif.getSceneTypeDescription(v); + case 'SensingMethod': + return Exif.getSensingMethodDescription(v); + case 'Sharpness': + return Exif.getSharpnessDescription(v); + case 'SubjectDistanceRange': + return Exif.getSubjectDistanceRangeDescription(v); + case 'WhiteBalance': + return Exif.getWhiteBalanceDescription(v); + case 'GPSAltitudeRef': + return Exif.getGPSAltitudeRefDescription(v); + case 'GPSDestBearingRef': + case 'GPSImgDirectionRef': + case 'GPSTrackRef': + return Exif.getGPSDirectionRefDescription(v); + case 'GPSDestDistanceRef': + return Exif.getGPSDestDistanceRefDescription(v); + case 'GPSDifferential': + return Exif.getGPSDifferentialDescription(v); + case 'GPSMeasureMode': + return Exif.getGPSMeasureModeDescription(v); + case 'GPSSpeedRef': + return Exif.getGPSSpeedRefDescription(v); + case 'GPSStatus': + return Exif.getGPSStatusDescription(v); + default: + return v; + } + } +} diff --git a/lib/widgets/viewer/info/metadata/xmp_ns/google.dart b/lib/widgets/viewer/info/metadata/xmp_ns/google.dart new file mode 100644 index 0000000..28e4f86 --- /dev/null +++ b/lib/widgets/viewer/info/metadata/xmp_ns/google.dart @@ -0,0 +1,175 @@ +import 'package:aves/ref/metadata/xmp.dart'; +import 'package:aves/widgets/common/extensions/build_context.dart'; +import 'package:aves/widgets/viewer/info/common.dart'; +import 'package:aves/widgets/viewer/info/embedded/notifications.dart'; +import 'package:aves/widgets/viewer/info/metadata/xmp_namespaces.dart'; +import 'package:collection/collection.dart'; + +abstract class XmpGoogleNamespace extends XmpNamespace { + XmpGoogleNamespace({ + required super.nsUri, + required super.schemaRegistryPrefixes, + required super.rawProps, + }); + + List<(String, String)> get dataProps; + + @override + Map<String, InfoValueSpanBuilder> linkifyValues(List<XmpProp> props) { + return Map.fromEntries(dataProps.map((t) { + final (dataPropPath, mimePropPath) = t; + final dataProp = props.firstWhereOrNull((prop) => prop.path == dataPropPath); + final mimeProp = props.firstWhereOrNull((prop) => prop.path == mimePropPath); + return (dataProp != null && mimeProp != null) + ? MapEntry( + dataProp.displayKey, + InfoRowGroup.linkSpanBuilder( + linkText: (context) => context.l10n.viewerInfoOpenLinkText, + onTap: (context) { + final pattern = RegExp(r'(.+):(.+)([(\d)])?'); + final props = dataProp.path.split('/').expand((part) { + var match = pattern.firstMatch(part); + if (match == null) return []; + + // ignore namespace prefix + final propName = match.group(2); + final prop = [nsUri, propName]; + + final indexString = match.groupCount >= 4 ? match.group(4) : null; + final index = indexString != null ? int.tryParse(indexString) : null; + if (index != null) { + return [prop, index]; + } else { + return [prop]; + } + }).toList(); + return OpenEmbeddedDataNotification.xmp( + props: props, + mimeType: mimeProp.value, + ).dispatch(context); + }, + )) + : null; + }).nonNulls); + } +} + +class XmpGAudioNamespace extends XmpGoogleNamespace { + XmpGAudioNamespace({required super.schemaRegistryPrefixes, required super.rawProps}) : super(nsUri: XmpNamespaces.gAudio); + + @override + List<(String, String)> get dataProps => [ + ('${nsPrefix}Data', '${nsPrefix}Mime'), + ]; +} + +class XmpGCameraNamespace extends XmpGoogleNamespace { + XmpGCameraNamespace({required super.schemaRegistryPrefixes, required super.rawProps}) : super(nsUri: XmpNamespaces.gCamera); + + @override + List<(String, String)> get dataProps => [ + ('${nsPrefix}RelitInputImageData', '${nsPrefix}RelitInputImageMime'), + ]; +} + +class XmpGContainer extends XmpNamespace { + late final String _gContainerItemNsPrefix; + late final String _rdfNsPrefix; + + XmpGContainer({required super.schemaRegistryPrefixes, required super.rawProps}) : super(nsUri: XmpNamespaces.gContainer) { + _gContainerItemNsPrefix = XmpNamespace.prefixForUri(schemaRegistryPrefixes, XmpNamespaces.gContainerItem); + _rdfNsPrefix = XmpNamespace.prefixForUri(schemaRegistryPrefixes, XmpNamespaces.rdf); + } + + @override + late final Set<RegExp> skippedProps = { + // variant of `Container:Item` with `<rdf:li>` + RegExp(nsPrefix + r'Directory\[(\d+)\]/' + _rdfNsPrefix + r'type'), + }; + + @override + late final List<XmpCardData> cards = [ + // variant of `Container:Item` with `<rdf:li rdf:parseType="Resource">` + XmpCardData(RegExp(nsPrefix + r'Directory\[(\d+)\]/' + nsPrefix + r'Item/(.*)'), title: 'Directory Item'), + // variant of `Container:Item` with `<rdf:li>` + XmpCardData(RegExp(nsPrefix + r'Directory\[(\d+)\]/(' + _gContainerItemNsPrefix + r'.*)'), title: 'Directory Item'), + ]; +} + +class XmpGDepthNamespace extends XmpGoogleNamespace { + XmpGDepthNamespace({required super.schemaRegistryPrefixes, required super.rawProps}) : super(nsUri: XmpNamespaces.gDepth); + + @override + List<(String, String)> get dataProps => [ + ('${nsPrefix}Data', '${nsPrefix}Mime'), + ('${nsPrefix}Confidence', '${nsPrefix}ConfidenceMime'), + ]; +} + +class XmpGDeviceNamespace extends XmpNamespace { + late final String _cameraNsPrefix; + late final String _containerNsPrefix; + late final String _itemNsPrefix; + + XmpGDeviceNamespace({required super.schemaRegistryPrefixes, required super.rawProps}) : super(nsUri: XmpNamespaces.gDevice) { + _cameraNsPrefix = XmpNamespace.prefixForUri(schemaRegistryPrefixes, XmpNamespaces.gDeviceCamera); + _containerNsPrefix = XmpNamespace.prefixForUri(schemaRegistryPrefixes, XmpNamespaces.gDeviceContainer); + _itemNsPrefix = XmpNamespace.prefixForUri(schemaRegistryPrefixes, XmpNamespaces.gDeviceItem); + + final mimePattern = RegExp(nsPrefix + r'Container/' + _containerNsPrefix + r'Directory\[(\d+)\]/' + _itemNsPrefix + r'Mime'); + final originalProps = rawProps.entries.toList(); + originalProps.forEach((kv) { + final path = kv.key; + final match = mimePattern.firstMatch(path); + if (match != null) { + final indexString = match.group(1); + if (indexString != null) { + final index = int.tryParse(indexString); + if (index != null) { + final dataPath = '${nsPrefix}Container/${_containerNsPrefix}Directory[$index]/${_itemNsPrefix}Data'; + rawProps[dataPath] = '[skipped]'; + } + } + } + }); + } + + @override + late final List<XmpCardData> cards = [ + XmpCardData( + RegExp(nsPrefix + r'Cameras\[(\d+)\]/(.*)'), + cards: [ + XmpCardData(RegExp(_cameraNsPrefix + r'DepthMap/(.*)')), + XmpCardData(RegExp(_cameraNsPrefix + r'Image/(.*)')), + XmpCardData(RegExp(_cameraNsPrefix + r'ImagingModel/(.*)')), + ], + ), + XmpCardData( + RegExp(nsPrefix + r'Container/' + _containerNsPrefix + r'Directory\[(\d+)\]/(.*)'), + spanBuilders: (index, struct) { + if (struct.containsKey('${_itemNsPrefix}Data') && struct.containsKey('${_itemNsPrefix}DataURI')) { + final dataUriProp = struct['${_itemNsPrefix}DataURI']; + if (dataUriProp != null) { + return { + 'Data': InfoRowGroup.linkSpanBuilder( + linkText: (context) => context.l10n.viewerInfoOpenLinkText, + onTap: (context) => OpenEmbeddedDataNotification.googleDevice(dataUri: dataUriProp.value).dispatch(context), + ), + }; + } + } + return {}; + }, + ), + XmpCardData(RegExp(nsPrefix + r'Profiles\[(\d+)\]/(.*)')), + ]; +} + +class XmpGImageNamespace extends XmpGoogleNamespace { + XmpGImageNamespace({required super.schemaRegistryPrefixes, required super.rawProps}) : super(nsUri: XmpNamespaces.gImage); + + @override + List<(String, String)> get dataProps => [ + ('${nsPrefix}Data', '${nsPrefix}Mime'), + ]; +} diff --git a/lib/widgets/viewer/info/metadata/xmp_ns/misc.dart b/lib/widgets/viewer/info/metadata/xmp_ns/misc.dart new file mode 100644 index 0000000..168d92d --- /dev/null +++ b/lib/widgets/viewer/info/metadata/xmp_ns/misc.dart @@ -0,0 +1,113 @@ +import 'package:aves/ref/metadata/xmp.dart'; +import 'package:aves/widgets/viewer/info/metadata/xmp_namespaces.dart'; + +class XmpCreatorAtom extends XmpNamespace { + XmpCreatorAtom({required super.schemaRegistryPrefixes, required super.rawProps}) : super(nsUri: XmpNamespaces.creatorAtom); + + @override + late final List<XmpCardData> cards = [ + XmpCardData(RegExp(nsPrefix + r'aeProjectLink/(.*)'), title: 'AE Project Link'), + ]; +} + +class XmpDarktableNamespace extends XmpNamespace { + XmpDarktableNamespace({required super.schemaRegistryPrefixes, required super.rawProps}) : super(nsUri: XmpNamespaces.darktable); + + @override + late final List<XmpCardData> cards = [ + XmpCardData(RegExp(nsPrefix + r'history\[(\d+)\]/(.*)')), + ]; +} + +class XmpDwcNamespace extends XmpNamespace { + XmpDwcNamespace({required super.schemaRegistryPrefixes, required super.rawProps}) : super(nsUri: XmpNamespaces.dwc); + + @override + late final List<XmpCardData> cards = [ + XmpCardData(RegExp(nsPrefix + r'dctermsLocation/(.*)'), title: 'DC Terms Location'), + XmpCardData(RegExp(nsPrefix + r'Event/(.*)')), + XmpCardData(RegExp(nsPrefix + r'GeologicalContext/(.*)')), + XmpCardData(RegExp(nsPrefix + r'Identification/(.*)')), + XmpCardData(RegExp(nsPrefix + r'MeasurementOrFact/(.*)')), + XmpCardData(RegExp(nsPrefix + r'Occurrence/(.*)')), + XmpCardData(RegExp(nsPrefix + r'Record/(.*)')), + XmpCardData(RegExp(nsPrefix + r'ResourceRelationship/(.*)')), + XmpCardData(RegExp(nsPrefix + r'Taxon/(.*)')), + ]; +} + +class XmpIptcCoreNamespace extends XmpNamespace { + XmpIptcCoreNamespace({required super.schemaRegistryPrefixes, required super.rawProps}) : super(nsUri: XmpNamespaces.iptc4xmpCore); + + @override + late final List<XmpCardData> cards = [ + XmpCardData(RegExp(nsPrefix + r'CreatorContactInfo/(.*)')), + ]; +} + +class XmpIptc4xmpExtNamespace extends XmpNamespace { + XmpIptc4xmpExtNamespace({required super.schemaRegistryPrefixes, required super.rawProps}) : super(nsUri: XmpNamespaces.iptc4xmpExt); + + @override + late final List<XmpCardData> cards = [ + XmpCardData(RegExp(nsPrefix + r'ArtworkOrObject\[(\d+)\]/(.*)')), + ]; +} + +class XmpMPNamespace extends XmpNamespace { + XmpMPNamespace({required super.schemaRegistryPrefixes, required super.rawProps}) : super(nsUri: XmpNamespaces.mp); + + @override + late final List<XmpCardData> cards = [ + XmpCardData(RegExp(nsPrefix + r'RegionInfo/MPRI:Regions\[(\d+)\]/(.*)'), title: 'Regions'), + ]; +} + +// cf www.metadataworkinggroup.org/pdf/mwg_guidance.pdf (down, as of 2021/02/15) +class XmpMgwRegionsNamespace extends XmpNamespace { + XmpMgwRegionsNamespace({required super.schemaRegistryPrefixes, required super.rawProps}) : super(nsUri: XmpNamespaces.mwgrs); + + @override + late final List<XmpCardData> cards = [ + XmpCardData(RegExp(nsPrefix + r'Regions/mwg-rs:AppliedToDimensions/(.*)'), title: 'Applied to Dimensions'), + XmpCardData(RegExp(nsPrefix + r'Regions/mwg-rs:RegionList\[(\d+)\]/(.*)'), title: 'Region List'), + ]; +} + +class XmpPlusNamespace extends XmpNamespace { + XmpPlusNamespace({required super.schemaRegistryPrefixes, required super.rawProps}) : super(nsUri: XmpNamespaces.plus); + + @override + late final List<XmpCardData> cards = [ + XmpCardData(RegExp(nsPrefix + r'CopyrightOwner\[(\d+)\]/(.*)')), + XmpCardData(RegExp(nsPrefix + r'ImageCreator\[(\d+)\]/(.*)')), + XmpCardData(RegExp(nsPrefix + r'Licensor\[(\d+)\]/(.*)')), + ]; +} + +class XmpMMNamespace extends XmpNamespace { + XmpMMNamespace({required super.schemaRegistryPrefixes, required super.rawProps}) : super(nsUri: XmpNamespaces.xmpMM); + + @override + late final List<XmpCardData> cards = [ + XmpCardData(RegExp(nsPrefix + r'DerivedFrom/(.*)')), + XmpCardData(RegExp(nsPrefix + r'History\[(\d+)\]/(.*)')), + XmpCardData(RegExp(nsPrefix + r'Ingredients\[(\d+)\]/(.*)')), + XmpCardData( + RegExp(nsPrefix + r'Pantry\[(\d+)\]/(.*)'), + cards: [ + XmpCardData(RegExp(nsPrefix + r'DerivedFrom/(.*)')), + XmpCardData(RegExp(nsPrefix + r'History\[(\d+)\]/(.*)')), + ], + ), + ]; +} + +class XmpXperiaCameraNamespace extends XmpNamespace { + XmpXperiaCameraNamespace({required super.schemaRegistryPrefixes, required super.rawProps}) : super(nsUri: XmpNamespaces.xperiaCamera); + + @override + late final List<XmpCardData> cards = [ + XmpCardData(RegExp(nsPrefix + r'Face\[(\d+)\]/(.*)')), + ]; +} diff --git a/lib/widgets/viewer/info/metadata/xmp_ns/photoshop.dart b/lib/widgets/viewer/info/metadata/xmp_ns/photoshop.dart new file mode 100644 index 0000000..5449a89 --- /dev/null +++ b/lib/widgets/viewer/info/metadata/xmp_ns/photoshop.dart @@ -0,0 +1,53 @@ +import 'package:aves/ref/metadata/xmp.dart'; +import 'package:aves/widgets/viewer/info/metadata/xmp_namespaces.dart'; + +// cf https://github.com/adobe/xmp-docs/blob/master/XMPNamespaces/photoshop.md +class XmpPhotoshopNamespace extends XmpNamespace { + XmpPhotoshopNamespace({required super.schemaRegistryPrefixes, required super.rawProps}) : super(nsUri: XmpNamespaces.photoshop); + + @override + late final List<XmpCardData> cards = [ + XmpCardData( + RegExp(nsPrefix + r'CameraProfiles\[(\d+)\]/(.*)'), + cards: [ + XmpCardData(RegExp(r'crlcp:PerspectiveModel/(.*)')), + ], + ), + XmpCardData(RegExp(nsPrefix + r'TextLayers\[(\d+)\]/(.*)')), + ]; + + @override + String formatValue(XmpProp prop) { + final value = prop.value; + switch (prop.path) { + case 'photoshop:ColorMode': + return getColorModeDescription(value); + } + return value; + } + + static String getColorModeDescription(String valueString) { + final value = int.tryParse(valueString); + if (value == null) return valueString; + switch (value) { + case 0: + return 'Bitmap'; + case 1: + return 'Gray scale'; + case 2: + return 'Indexed colour'; + case 3: + return 'RGB colour'; + case 4: + return 'CMYK colour'; + case 7: + return 'Multi-channel'; + case 8: + return 'Duotone'; + case 9: + return 'LAB colour'; + default: + return 'Unknown ($value)'; + } + } +} diff --git a/lib/widgets/viewer/info/metadata/xmp_ns/tiff.dart b/lib/widgets/viewer/info/metadata/xmp_ns/tiff.dart new file mode 100644 index 0000000..b67df3a --- /dev/null +++ b/lib/widgets/viewer/info/metadata/xmp_ns/tiff.dart @@ -0,0 +1,28 @@ +import 'package:aves/ref/metadata/exif.dart'; +import 'package:aves/ref/metadata/xmp.dart'; +import 'package:aves/widgets/viewer/info/metadata/xmp_namespaces.dart'; + +// cf https://github.com/adobe/xmp-docs/blob/master/XMPNamespaces/tiff.md +class XmpTiffNamespace extends XmpNamespace { + XmpTiffNamespace({required super.schemaRegistryPrefixes, required super.rawProps}) : super(nsUri: XmpNamespaces.tiff); + + @override + String formatValue(XmpProp prop) { + final value = prop.value; + switch (prop.path) { + case 'tiff:Compression': + return Exif.getCompressionDescription(value); + case 'tiff:Orientation': + return Exif.getOrientationDescription(value); + case 'tiff:PhotometricInterpretation': + return Exif.getPhotometricInterpretationDescription(value); + case 'tiff:PlanarConfiguration': + return Exif.getPlanarConfigurationDescription(value); + case 'tiff:ResolutionUnit': + return Exif.getResolutionUnitDescription(value); + case 'tiff:YCbCrPositioning': + return Exif.getYCbCrPositioningDescription(value); + } + return value; + } +} diff --git a/lib/widgets/viewer/info/metadata/xmp_ns/xmp.dart b/lib/widgets/viewer/info/metadata/xmp_ns/xmp.dart new file mode 100644 index 0000000..655a8fe --- /dev/null +++ b/lib/widgets/viewer/info/metadata/xmp_ns/xmp.dart @@ -0,0 +1,33 @@ +import 'package:aves/ref/metadata/xmp.dart'; +import 'package:aves/ref/mime_types.dart'; +import 'package:aves/widgets/common/extensions/build_context.dart'; +import 'package:aves/widgets/viewer/info/common.dart'; +import 'package:aves/widgets/viewer/info/embedded/notifications.dart'; +import 'package:aves/widgets/viewer/info/metadata/xmp_namespaces.dart'; + +class XmpBasicNamespace extends XmpNamespace { + XmpBasicNamespace({required super.schemaRegistryPrefixes, required super.rawProps}) : super(nsUri: XmpNamespaces.xmp); + + @override + late final List<XmpCardData> cards = [ + XmpCardData( + RegExp(nsPrefix + r'Thumbnails\[(\d+)\]/(.*)'), + spanBuilders: (index, struct) { + return { + if (struct.containsKey('xmpGImg:image')) + 'Image': InfoRowGroup.linkSpanBuilder( + linkText: (context) => context.l10n.viewerInfoOpenLinkText, + onTap: (context) => OpenEmbeddedDataNotification.xmp( + props: [ + const [XmpNamespaces.xmp, 'Thumbnails'], + index, + const [XmpNamespaces.xmpGImg, 'image'], + ], + mimeType: MimeTypes.jpeg, + ).dispatch(context), + ), + }; + }, + ), + ]; +} diff --git a/lib/widgets/viewer/info/metadata/xmp_tile.dart b/lib/widgets/viewer/info/metadata/xmp_tile.dart new file mode 100644 index 0000000..fd3ced9 --- /dev/null +++ b/lib/widgets/viewer/info/metadata/xmp_tile.dart @@ -0,0 +1,55 @@ +import 'dart:collection'; +import 'dart:convert'; + +import 'package:aves/utils/xmp_utils.dart'; +import 'package:aves/widgets/viewer/info/metadata/xmp_namespaces.dart'; +import 'package:collection/collection.dart'; +import 'package:flutter/material.dart'; + +class XmpDirTileBody extends StatefulWidget { + final SplayTreeMap<String, String> allTags, tags; + + const XmpDirTileBody({ + super.key, + required this.allTags, + required this.tags, + }); + + @override + State<XmpDirTileBody> createState() => _XmpDirTileBodyState(); +} + +class _XmpDirTileBodyState extends State<XmpDirTileBody> { + late final Map<String, String> _schemaRegistryPrefixes, _tags; + + static const schemaRegistryPrefixesKey = 'schemaRegistryPrefixes'; + + @override + void initState() { + super.initState(); + _tags = Map.from(widget.tags)..remove(schemaRegistryPrefixesKey); + final prefixesJson = widget.allTags[schemaRegistryPrefixesKey]; + final Map<String, dynamic> prefixesDecoded = prefixesJson != null ? jsonDecode(prefixesJson) : {}; + _schemaRegistryPrefixes = Map.fromEntries(prefixesDecoded.entries.map((kv) => MapEntry(kv.key, kv.value as String))); + } + + @override + Widget build(BuildContext context) { + final sections = groupBy<MapEntry<String, String>, String>(_tags.entries, (kv) { + final fullKey = kv.key; + final i = fullKey.indexOf(XMP.propNamespaceSeparator); + final nsPrefix = i == -1 ? '' : fullKey.substring(0, i + 1); + return nsPrefix; + }).entries.map((kv) { + final nsPrefix = kv.key; + final rawProps = Map.fromEntries(kv.value); + return XmpNamespace.create(_schemaRegistryPrefixes, nsPrefix, rawProps); + }).toList() + ..sort((a, b) => compareAsciiUpperCase(a.displayTitle, b.displayTitle)); + + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: sections.expand((section) => section.buildNamespaceSection(context)).toList(), + ); + } +} |
