public static LayerGeoJson GetTransectLineLayerGeoJson(this OnlandVisualTrashAssessment onlandVisualTrashAssessment) { LayerGeoJson transsectLineLayerGeoJson; if (onlandVisualTrashAssessment.OnlandVisualTrashAssessmentArea?.TransectLine != null) { transsectLineLayerGeoJson = onlandVisualTrashAssessment.OnlandVisualTrashAssessmentArea .GetTransectLineLayerGeoJson(); } else { var featureCollection = new FeatureCollection(); var dbGeometry = onlandVisualTrashAssessment.GetTransect(); if (dbGeometry == null) { return(null); } var feature = DbGeometryToGeoJsonHelper.FromDbGeometryWithReprojectionCheck(dbGeometry.ToSqlGeometry().MakeValid().ToDbGeometry()); featureCollection.Features.AddRange(new List <Feature> { feature }); transsectLineLayerGeoJson = new LayerGeoJson("transectLine", featureCollection, "#000000", 1, LayerInitialVisibility.Show); } return(transsectLineLayerGeoJson); }
/// <summary> /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible /// </summary> public OnlandVisualTrashAssessmentPreliminarySourceIdentificationType(OnlandVisualTrashAssessment onlandVisualTrashAssessment, PreliminarySourceIdentificationType preliminarySourceIdentificationType) : this() { // Mark this as a new object by setting primary key with special value this.OnlandVisualTrashAssessmentPreliminarySourceIdentificationTypeID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue(); this.OnlandVisualTrashAssessmentID = onlandVisualTrashAssessment.OnlandVisualTrashAssessmentID; this.OnlandVisualTrashAssessment = onlandVisualTrashAssessment; onlandVisualTrashAssessment.OnlandVisualTrashAssessmentPreliminarySourceIdentificationTypes.Add(this); this.PreliminarySourceIdentificationTypeID = preliminarySourceIdentificationType.PreliminarySourceIdentificationTypeID; }
public static FeatureCollection GetAssessmentAreaFeatureCollection(this OnlandVisualTrashAssessment ovta) { var featureCollection = new FeatureCollection(); var parcelGeoms = ovta.GetParcelsViaTransect().Select(x => x.ParcelGeometry4326).ToList(); var feature = DbGeometryToGeoJsonHelper.FromDbGeometryWithNoReproject(parcelGeoms.UnionListGeometries()); featureCollection.Features.Add(feature); return(featureCollection); }
/// <summary> /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible /// </summary> public OnlandVisualTrashAssessmentObservation(OnlandVisualTrashAssessment onlandVisualTrashAssessment, DbGeometry locationPoint, DateTime observationDatetime) : this() { // Mark this as a new object by setting primary key with special value this.OnlandVisualTrashAssessmentObservationID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue(); this.OnlandVisualTrashAssessmentID = onlandVisualTrashAssessment.OnlandVisualTrashAssessmentID; this.OnlandVisualTrashAssessment = onlandVisualTrashAssessment; onlandVisualTrashAssessment.OnlandVisualTrashAssessmentObservations.Add(this); this.LocationPoint = locationPoint; this.ObservationDatetime = observationDatetime; }
public static HtmlString GetDetailUrlForGrid(this OnlandVisualTrashAssessment onlandVisualTrashAssessment, Person currentPerson) { if (onlandVisualTrashAssessment.OnlandVisualTrashAssessmentStatus == OnlandVisualTrashAssessmentStatus.Complete) { return(new HtmlString( $"<a class='gridButton' href='{DetailUrlTemplate.ParameterReplace(onlandVisualTrashAssessment.OnlandVisualTrashAssessmentID)}'>View</a>")); } return(new HtmlString("")); }
public HtmlString SectionCompletionStatusIndicator(OnlandVisualTrashAssessment ovta) { if (!HasCompletionStatus || ovta == null) // all menu items are disabled if ovta hasn't been created yet, so don't display an indicator { return(new HtmlString(string.Empty)); } return(IsSectionComplete(ovta) ? new HtmlString( "<span class='glyphicon glyphicon-ok field-validation-success text-left'></span>") : new HtmlString( "<span class='glyphicon glyphicon-exclamation-sign field-validation-warning text-left'></span>")); }
public static IQueryable <Parcel> GetParcelsViaTransect(this OnlandVisualTrashAssessment ovta) { if (!ovta.OnlandVisualTrashAssessmentObservations.Any()) { return(new List <Parcel>().AsQueryable()); } var transect = ovta.OnlandVisualTrashAssessmentObservations.Count == 1 ? ovta.OnlandVisualTrashAssessmentObservations.Single().LocationPoint // don't attempt to calculate the transect : ovta.GetTransect(); return(HttpRequestStorage.DatabaseEntities.Parcels.Where(x => x.ParcelGeometry.Intersects(transect))); }
public static List <PreliminarySourceIdentificationSimple> GetPreliminarySourceIdentificationSimples( this OnlandVisualTrashAssessment onlandVisualTrashAssessment) { var presentGuys = onlandVisualTrashAssessment .OnlandVisualTrashAssessmentPreliminarySourceIdentificationTypes.ToList() .Select(x => new PreliminarySourceIdentificationSimple(x)).ToList(); var missingGuys = PreliminarySourceIdentificationType.All.Except(onlandVisualTrashAssessment.OnlandVisualTrashAssessmentPreliminarySourceIdentificationTypes.Select(x => x.PreliminarySourceIdentificationType)).Select(x => new PreliminarySourceIdentificationSimple(x)); presentGuys.AddRange(missingGuys); return(presentGuys); }
public static DbGeometry GetTransect(this OnlandVisualTrashAssessment ovta) { if (ovta.OnlandVisualTrashAssessmentObservations.Count > 1) { var points = Join(",", ovta.OnlandVisualTrashAssessmentObservations.OrderBy(x => x.ObservationDatetime) .Select(x => x.LocationPoint).ToList().Select(x => $"{x.XCoordinate} {x.YCoordinate}") .ToList()); var linestring = $"LINESTRING ({points})"; // the transect is going to be in 2771 because it was generated from points in 2771 return(DbGeometry.LineFromText(linestring, CoordinateSystemHelper.NAD_83_HARN_CA_ZONE_VI_SRID)); } return(null); }
public static List <int> GetParcelIDsForAddOrRemoveParcels(this OnlandVisualTrashAssessment onlandVisualTrashAssessment) { if (onlandVisualTrashAssessment.IsDraftGeometryManuallyRefined.GetValueOrDefault()) { return(new List <int>()); } // NP 8/22 these are supposed to be in 2771 already, but due to a b*g somewhere, some of them have 4326 as their SRID even though the coords are 2771... var draftGeometry = onlandVisualTrashAssessment.DraftGeometry.FixSrid(CoordinateSystemHelper.NAD_83_HARN_CA_ZONE_VI_SRID); // ... and the wrong SRID would cause this next lookup to fail bigly var parcelIDs = draftGeometry == null ? onlandVisualTrashAssessment.GetParcelsViaTransect().Select(x => x.ParcelID) : HttpRequestStorage.DatabaseEntities.Parcels .Where(x => draftGeometry.Contains(x.ParcelGeometry)).Select(x => x.ParcelID); return(parcelIDs.ToList()); }
public static LayerGeoJson GetAssessmentAreaLayerGeoJson(this OnlandVisualTrashAssessment onlandVisualTrashAssessment, bool reduce) { FeatureCollection geoJsonFeatureCollection; if (onlandVisualTrashAssessment.OnlandVisualTrashAssessmentArea != null) { geoJsonFeatureCollection = new List <OnlandVisualTrashAssessmentArea> { onlandVisualTrashAssessment.OnlandVisualTrashAssessmentArea } .ToGeoJsonFeatureCollection(); } else if (onlandVisualTrashAssessment.DraftGeometry != null) { var draftGeometry = onlandVisualTrashAssessment.DraftGeometry; geoJsonFeatureCollection = new FeatureCollection(); // Leaflet.Draw does not support multipolgyon editing because its dev team decided it wasn't necessary. // Unless https://github.com/Leaflet/Leaflet.draw/issues/268 is resolved, we have to break into separate polys. // On an unrelated note, DbGeometry.ElementAt is 1-indexed instead of 0-indexed, which is terrible. for (var i = 1; i <= draftGeometry.ElementCount.GetValueOrDefault(); i++) { var dbGeometry = draftGeometry.ElementAt(i); if (reduce) { // Reduce is SQL Server's implementation of the Douglas–Peucker downsampling algorithm dbGeometry = dbGeometry.ToSqlGeometry().Reduce(.0000025).ToDbGeometry().FixSrid(CoordinateSystemHelper.NAD_83_HARN_CA_ZONE_VI_SRID); } var feature = DbGeometryToGeoJsonHelper.FromDbGeometryWithReprojectionCheck(dbGeometry); geoJsonFeatureCollection.Features.Add(feature); } } else { geoJsonFeatureCollection = new FeatureCollection(); } var assessmentAreaLayerGeoJson = new LayerGeoJson("parcels", geoJsonFeatureCollection, "#ffff00", .5m, LayerInitialVisibility.Show); return(assessmentAreaLayerGeoJson); }
public static HtmlString GetEditUrlForGrid(this OnlandVisualTrashAssessment onlandVisualTrashAssessment, Person currentPerson) { var userCanEdit = new OnlandVisualTrashAssessmentEditStatusFeature() .HasPermission(currentPerson, onlandVisualTrashAssessment) .HasPermission; if (!userCanEdit) { return(new HtmlString(Empty)); } return(onlandVisualTrashAssessment.OnlandVisualTrashAssessmentStatus == OnlandVisualTrashAssessmentStatus.Complete ? ModalDialogFormHelper.ModalDialogFormLink("Return to Edit", GetEditStatusToAllowEditUrl(onlandVisualTrashAssessment), $"Return to Edit On-land Visual Trash Assessment for {onlandVisualTrashAssessment.OnlandVisualTrashAssessmentArea.OnlandVisualTrashAssessmentAreaName}", 500, "Continue", "Cancel", new List <string> { "gridButton" }, null, null) : DhtmlxGridHtmlHelpers.MakeEditIconAsHyperlinkBootstrap(GetEditUrl(onlandVisualTrashAssessment))); }
public static string GetEditStatusToAllowEditUrl(this OnlandVisualTrashAssessment ovta) { return(EditStatusToAllowEditUrlTemplate.ParameterReplace(ovta.OnlandVisualTrashAssessmentID)); }
public override OVTASection GetNextSection(OnlandVisualTrashAssessment ovta) { throw new InvalidOperationException("Finalize OVTA is the final step; cannot get next section"); }
public static string GetDeleteUrl(this OnlandVisualTrashAssessment ovta) { return(DeleteUrlTemplate.ParameterReplace(ovta.OnlandVisualTrashAssessmentID)); }
public override bool IsSectionEnabled(OnlandVisualTrashAssessment ovta) { return(InitiateOVTA.IsSectionComplete(ovta) && RecordObservations.IsSectionComplete(ovta) && AddOrRemoveParcels.IsSectionComplete(ovta)); }
public override string GetSectionUrl(OnlandVisualTrashAssessment ovta) { return(ovta == null ? SitkaRoute <OnlandVisualTrashAssessmentController> .BuildUrlFromExpression(x => x.InitiateOVTA(null)) : SitkaRoute <OnlandVisualTrashAssessmentController> .BuildUrlFromExpression(x => x.InitiateOVTA(ovta.OnlandVisualTrashAssessmentID))); }
public abstract bool IsSectionEnabled(OnlandVisualTrashAssessment ovta);
public override string GetSectionUrl(OnlandVisualTrashAssessment ovta) { return(ovta == null ? null : SitkaRoute <OnlandVisualTrashAssessmentController> .BuildUrlFromExpression(x => x.FinalizeOVTA(ovta))); }
public abstract bool IsSectionRelevant(OnlandVisualTrashAssessment ovta);
public override bool IsSectionEnabled(OnlandVisualTrashAssessment ovta) { return(true); }
public override bool IsSectionComplete(OnlandVisualTrashAssessment ovta) { var viewModel = new InitiateOVTAViewModel(ovta); return(!viewModel.GetValidationResults().Any()); }
public override OVTASection GetNextSection(OnlandVisualTrashAssessment ovta) { return(RecordObservations); }
public static string ToBaselineProgress(this OnlandVisualTrashAssessment onlandVisualTrashAssessment) { return(onlandVisualTrashAssessment.IsProgressAssessment ? "Progress" : "Baseline"); }
public override bool IsSectionComplete(OnlandVisualTrashAssessment ovta) { throw new InvalidOperationException("Instructions does not have a completness status; cannot check completeness"); }
public override bool IsSectionRelevant(OnlandVisualTrashAssessment ovta) { return(true); }
/// <summary> /// Creates a "blank" object of this type and populates primitives with defaults /// </summary> public static OnlandVisualTrashAssessmentPreliminarySourceIdentificationType CreateNewBlank(OnlandVisualTrashAssessment onlandVisualTrashAssessment, PreliminarySourceIdentificationType preliminarySourceIdentificationType) { return(new OnlandVisualTrashAssessmentPreliminarySourceIdentificationType(onlandVisualTrashAssessment, preliminarySourceIdentificationType)); }
public override OVTASection GetNextSection(OnlandVisualTrashAssessment ovta) { return(InitiateOVTA); }
/// <summary> /// Creates a "blank" object of this type and populates primitives with defaults /// </summary> public static OnlandVisualTrashAssessmentObservation CreateNewBlank(OnlandVisualTrashAssessment onlandVisualTrashAssessment) { return(new OnlandVisualTrashAssessmentObservation(onlandVisualTrashAssessment, default(DbGeometry), default(DateTime))); }
public override bool IsSectionRelevant(OnlandVisualTrashAssessment ovta) { return(ovta?.AssessingNewArea.GetValueOrDefault() ?? false); }