Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding measurement widget #196

Merged
merged 3 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions samples/dymaptic.GeoBlazor.Core.Sample.Shared/Pages/Widgets.razor
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
<div class="form-group">
<label>Compass: <input type="checkbox" class="form-check-input" @onchange="@(() => ToggleWidget(nameof(CompassWidget)))"></label>
</div>
<div class="form-group">
<label>Measurement: <input type="checkbox" class="form-check-input" @onchange="@(() => ToggleWidget(nameof(MeasurementWidget)))"></label>
</div>
<div id="gallery-box"></div>
</div>
</div>
Expand Down Expand Up @@ -76,6 +79,10 @@
{
<CompassWidget Position="OverlayPosition.TopLeft" />
}
@if (_showMeasurement)
{
<MeasurementWidget ActiveTool="ActiveTool.Distance" Label="asdasdasdsds" LinearUnit="LinearUnit.NauticalMiles" AreaUnit="AreaUnit.SquareInches" Position="OverlayPosition.TopLeft" />
}
</MapView>

@code {
Expand Down Expand Up @@ -109,6 +116,9 @@
case nameof(CompassWidget):
_showCompass = !_showCompass;
break;
case nameof(MeasurementWidget):
_showMeasurement = !_showMeasurement;
break;
}
}

Expand All @@ -120,4 +130,5 @@
private bool _showLegend;
private bool _showHome;
private bool _showCompass;
private bool _showMeasurement;
}
19 changes: 19 additions & 0 deletions src/dymaptic.GeoBlazor.Core/Components/ActiveTool.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using dymaptic.GeoBlazor.Core.Components.Widgets;
using dymaptic.GeoBlazor.Core.Serialization;
using System.Text.Json.Serialization;


namespace dymaptic.GeoBlazor.Core.Components;

/// <summary>
/// A collection of possible positions for setting a <see cref="Widget" /> or <see cref="CustomOverlay" />
/// </summary>
[JsonConverter(typeof(EnumToKebabCaseStringConverter<ActiveTool>))]
public enum ActiveTool
{
#pragma warning disable CS1591
Area,
Distance,
DirectLine
#pragma warning restore CS1591
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using dymaptic.GeoBlazor.Core.Objects;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using System.Text.Json.Serialization;


namespace dymaptic.GeoBlazor.Core.Components.Widgets;

/// <summary>
/// The Image Measurement widget allows you to perform measurements on image services with mensuration capability.
/// Mensuration is a method of applying geometric rules to find length of lines, area of surfaces, or volume using information obtained
/// from lines and angles. It can also include measuring the height and absolute location of a feature.
/// <a target="_blank" href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Measurement.html">
/// ArcGIS
/// JS API
/// </a>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you were right about this formatting, I solved it another way by fixing it in docCopy.ps1, so we can let the XML formatter do its thing.

/// </summary>
public class MeasurementWidget : Widget
{
/// <inheritdoc />
[JsonPropertyName("type")]
public override string WidgetType => "measurement";

/// <summary>
/// A .NET object reference for calling this class from JavaScript.
/// </summary>
public DotNetObjectReference<MeasurementWidget> MeasurementWidgetObjectReference => DotNetObjectReference.Create(this);

[Parameter]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need xml comments on all public types for the doc generation.

[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ActiveTool? ActiveTool { get; set; }

[Parameter]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public AreaUnit? AreaUnit { get; set; }

[Parameter]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public LinearUnit? LinearUnit { get; set; }


[Parameter]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Label { get; set; }



}
8 changes: 8 additions & 0 deletions src/dymaptic.GeoBlazor.Core/Components/Widgets/Widget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ public abstract class Widget : MapComponent
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? ContainerId { get; set; }

/// <summary>
/// Icon which represents the widget. It is typically used when the widget is controlled by another one (e.g. in the Expand widget).
/// <a href="https://developers.arcgis.com/calcite-design-system/icons/">Calcite Icons</a>
/// </summary>
[Parameter]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Icon { get; set; }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be in the MeasurementWidget.cs? I saw that the both have Icon properties. Just wanted to verify.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be removed from the measurement widget and inherited from the widget class


/// <summary>
/// The type of widget
/// </summary>
Expand Down
57 changes: 55 additions & 2 deletions src/dymaptic.GeoBlazor.Core/Objects/ArealUnit.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using dymaptic.GeoBlazor.Core.Serialization;
using dymaptic.GeoBlazor.Core.Components;
using dymaptic.GeoBlazor.Core.Serialization;
using System.Text.Json.Serialization;


Expand All @@ -22,6 +23,58 @@ public enum ArealUnit
SquareFeet,
SquareMeters,
SquareYards,
SquareKilometers
SquareKilometers,
SquareMiles
#pragma warning restore CS1591
}

/// <summary>
/// Units for area measurement. Use one of the possible values listed below or any of the numeric codes for area units.
/// <a target="_blank" href="https://developers.arcgis.com/javascript/latest/api-reference/esri-core-units.htm">
/// ArcGIS
/// JS API
/// </a>
/// </summary>
[JsonConverter(typeof(EnumToKebabCaseStringConverter<AreaUnit>))]
public enum AreaUnit
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a better way to identify the units used in GeometryEngine vs. the ones used in the new widget. Since they changed the names on me anyways, could we create a new GeometryEngineAreaUnit, create overloads in GeometryEngine.cs that take those instead, and mark the ones that take ArealUnit as [Obsolete]?

{
#pragma warning disable CS1591
Metric,
Imperial,
Acres,
Ares,
Hectares,
SquareFeet,
SquareMeters,
SquareYards,
SquareKilometers,
SquareMiles,
SquareInches,
SquareUSFeet,
#pragma warning restore CS1591
}

/// <summary>
/// Units for linear measurement. Use one of the possible values listed below or any of the numeric codes for linear units.
/// <a target="_blank" href="https://developers.arcgis.com/javascript/latest/api-reference/esri-core-units.htm">
/// ArcGIS
/// JS API
/// </a>`
/// </summary>
[JsonConverter(typeof(EnumToKebabCaseStringConverter<LengthUnit>))]
public enum LengthUnit
{
#pragma warning disable CS1591
Millimeters,
Centimeters,
Decimeters,
Meters,
Kilometers,
Inches,
Feet,
Yards,
Miles,
NauticalMiles,
USFeet
#pragma warning restore CS1591
}
Loading