Exemplo n.º 1
0
        private PFD MapField(Field field, Dictionary <int, string> keyToIsoId, int fieldIndex, Catalog setupCatalog)
        {
            var isoField = new PFD
            {
                C = field.Description,
                D = (ulong)Math.Round(field.Area.Value.Value, 0)
            };

            isoField.A = isoField.GetIsoId(fieldIndex);
            if (field.FarmId != null)
            {
                isoField.F = keyToIsoId[field.FarmId.Value];
                var farm = setupCatalog.Farms.First(f => f.Id.ReferenceId == field.FarmId.Value);
                if (farm.GrowerId != null)
                {
                    isoField.E = keyToIsoId[farm.GrowerId.Value];
                }
            }
            if (field.ActiveBoundaryId != null)
            {
                var boundary = setupCatalog.FieldBoundaries.Single(b => b.Id.ReferenceId == field.ActiveBoundaryId.Value);
                isoField.Items = new IWriter[] { _boundaryMapper.Map(boundary.SpatialData, BoundaryType.Field, boundary.Description) };
            }

            keyToIsoId.Add(field.Id.ReferenceId, isoField.A);
            return(isoField);
        }
Exemplo n.º 2
0
        private PFD Map(CropZone cropZone, Dictionary <int, string> keyToIsoId, int cropZoneIndex, Catalog setupCatalog)
        {
            var pfd = new PFD
            {
                C = cropZone.Description,
                D = (ulong)Math.Round(cropZone.Area.Value.Value, 0)
            };

            pfd.A = pfd.GetIsoId(cropZoneIndex);
            if (cropZone.CropId != null)
            {
                pfd.G = keyToIsoId[cropZone.CropId.Value];
            }
            pfd.I = keyToIsoId[cropZone.FieldId];
            var field = setupCatalog.Fields.First(f => f.Id.ReferenceId == cropZone.FieldId);

            if (field.FarmId != null)
            {
                pfd.F = keyToIsoId[field.FarmId.Value];
                var farm = setupCatalog.Farms.First(f => f.Id.ReferenceId == field.FarmId.Value);
                if (farm.GrowerId != null)
                {
                    pfd.E = keyToIsoId[farm.GrowerId.Value];
                }
            }
            if (cropZone.BoundingRegion != null)
            {
                pfd.Items = new IWriter[] { _boundaryMapper.Map(cropZone.BoundingRegion, BoundaryType.CropZone, cropZone.Description) };
            }

            keyToIsoId.Add(cropZone.Id.ReferenceId, pfd.A);
            return(pfd);
        }