Ejemplo n.º 1
0
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            // Overflow is fine, just wrap
            unchecked
            {
                var hashCode = 41;

                // Suitable nullity checks etc, of course :)
#pragma warning disable CA1307 // Specify StringComparison

                // ReSharper disable once NonReadonlyMemberInGetHashCode
                if (Name != null)
                {
                    // ReSharper disable once NonReadonlyMemberInGetHashCode
                    hashCode = (hashCode * 59) + Name.GetHashCode();
                }

                // ReSharper disable once NonReadonlyMemberInGetHashCode
                if (Address != null)
                {
                    // ReSharper disable once NonReadonlyMemberInGetHashCode
                    hashCode = (hashCode * 59) + Address.GetHashCode();
                }

                // ReSharper disable once NonReadonlyMemberInGetHashCode
                if (MapUrl != null)
                {
                    // ReSharper disable once NonReadonlyMemberInGetHashCode
                    hashCode = (hashCode * 59) + MapUrl.GetHashCode();
                }

                // ReSharper disable once NonReadonlyMemberInGetHashCode
                if (MeetupIds != null)
                {
                    // ReSharper disable once NonReadonlyMemberInGetHashCode
                    hashCode = (hashCode * 59) + MeetupIds.GetHashCode();
                }

                // ReSharper disable once NonReadonlyMemberInGetHashCode
                if (SpeakerIds != null)
                {
                    // ReSharper disable once NonReadonlyMemberInGetHashCode
                    hashCode = (hashCode * 59) + SpeakerIds.GetHashCode();
                }

                // ReSharper disable once NonReadonlyMemberInGetHashCode
                if (TalkIds != null)
                {
                    // ReSharper disable once NonReadonlyMemberInGetHashCode
                    hashCode = (hashCode * 59) + TalkIds.GetHashCode();
                }
#pragma warning restore CA1307 // Specify StringComparison
                return(hashCode);
            }
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        /// <summary>
        /// Returns true if UpdateVenueDraftParameters instances are equal
        /// </summary>
        /// <param name="other">Instance of UpdateVenueDraftParameters to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(UpdateVenueDraftParameters other)
        {
#pragma warning disable IDE0041 // Use 'is null' check
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

#pragma warning disable CA1309                  // Use ordinal stringcomparison
#pragma warning disable CA1307                  // Specify StringComparison
#pragma warning disable SA1515                  // Single-line comment must be preceded by blank line
#pragma warning disable SA1009                  // Closing parenthesis must be spaced correctly
            return
                (#pragma warning disable SA1119 // Statement must not use unnecessary parenthesis
                 (
                     // ReSharper disable once RedundantNameQualifier
                     string.Equals(Name, other.Name) ||
                     (Name != null && Name.Equals(other.Name))
                 ) &&
                 (
                     // ReSharper disable once RedundantNameQualifier
                     string.Equals(Address, other.Address) ||
                     (Address != null && Address.Equals(other.Address))
                 ) &&
                 (
                     // ReSharper disable once RedundantNameQualifier
                     string.Equals(MapUrl, other.MapUrl) ||
                     (MapUrl != null && MapUrl.Equals(other.MapUrl))
                 ) &&
                 (
                     MeetupIds == other.MeetupIds ||
                     (MeetupIds != null && MeetupIds.SequenceEqual(other.MeetupIds))
                 ) &&
                 (
                     SpeakerIds == other.SpeakerIds ||
                     (SpeakerIds != null && SpeakerIds.SequenceEqual(other.SpeakerIds))
                 ) &&
                 (
                     TalkIds == other.TalkIds ||
                     (TalkIds != null && TalkIds.SequenceEqual(other.TalkIds))
                 ));

#pragma warning restore SA1119 // Statement must not use unnecessary parenthesis
#pragma warning restore SA1009 // Closing parenthesis must be spaced correctly
#pragma warning restore SA1515 // Single-line comment must be preceded by blank line
#pragma warning restore CA1307 // Specify StringComparison
#pragma warning restore CA1309 // Use ordinal stringcomparison
        }
Ejemplo n.º 3
0
        public override byte[] GetTileBytes(int level, int row, int col)
        {
            string subdomain = string.Empty;
            string uri       = string.Empty;
            //calculate the bbox
            double xmin, ymin, xmax, ymax;

            Utility.CalculateBBox(TilingScheme.TileOrigin, TilingScheme.LODs[level].Resolution, TilingScheme.TileRows, TilingScheme.TileCols, row, col, out xmin, out ymin, out xmax, out ymax);
            int    tileRows = this.TilingScheme.TileRows;
            int    tileCols = this.TilingScheme.TileCols;
            string format   = this.TilingScheme.CacheTileFormat.ToString().ToUpper().Contains("PNG") ? "png" : "jpg";
            //http://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer?VERSION=1.3.0&REQUEST=GetMap&CRS=CRS:84&BBOX=-178.217598,18.924782,-66.969271,71.406235&WIDTH=765&HEIGHT=360&LAYERS=0,1,2&STYLES=,,&FORMAT=image/png
            //subdomain = _serviceInstaces[(level + col + row) % _serviceInstaces.Length];

            StringBuilder queryString = new StringBuilder();

            if (!MapUrl.EndsWith("?"))
            {
                MapUrl += "?";
            }
            queryString.Append("SERVICE=WMS&REQUEST=GetMap");
            queryString.AppendFormat("&WIDTH={0}", tileCols);
            queryString.AppendFormat("&HEIGHT={0}", tileRows);
            queryString.AppendFormat("&FORMAT={0}", "image" + "/" + format);
            queryString.AppendFormat("&LAYERS={0}", LayerList.Count == 0 ? "" : String.Join("%2C", GetVisibleLayers(LayerList).ToArray()));
            queryString.Append("&STYLES=");
            queryString.AppendFormat("&BGCOLOR={0}", "0xFFFFFF");
            queryString.AppendFormat("&TRANSPARENT={0}", "TRUE");
            queryString.AppendFormat("&VERSION={0}", GetValidVersionNumber());
            //If one of the WebMercator codes, change to a WKID supported by the service
            if (SupportedSpatialReferenceIDs != null &&
                (TilingScheme.WKID == 102100 || TilingScheme.WKID == 102113 || TilingScheme.WKID == 3857 || TilingScheme.WKID == 900913))
            {
                if (!SupportedSpatialReferenceIDs.Contains(TilingScheme.WKID))
                {
                    if (SupportedSpatialReferenceIDs.Contains(3857))
                    {
                        TilingScheme.WKID = 3857;
                    }
                    else if (SupportedSpatialReferenceIDs.Contains(102100))
                    {
                        TilingScheme.WKID = 102100;
                    }
                    else if (SupportedSpatialReferenceIDs.Contains(102113))
                    {
                        TilingScheme.WKID = 102113;
                    }
                    else if (SupportedSpatialReferenceIDs.Contains(900913))
                    {
                        TilingScheme.WKID = 900913;
                    }
                }
            }
            if (LowerThan13Version())
            {
                queryString.AppendFormat("&SRS=EPSG%3A{0}", TilingScheme.WKID);
                queryString.AppendFormat(CultureInfo.InvariantCulture,
                                         "&bbox={0}%2C{1}%2C{2}%2C{3}", xmin, ymin, xmax, ymax);
            }
            else
            {
                queryString.AppendFormat("&CRS=EPSG%3A{0}", TilingScheme.WKID);
                if (UseLatLon(TilingScheme.WKID))
                {
                    queryString.AppendFormat(CultureInfo.InvariantCulture,
                                             "&BBOX={0}%2C{1}%2C{2}%2C{3}", ymin, xmin, ymax, xmax);
                }
                else
                {
                    queryString.AppendFormat(CultureInfo.InvariantCulture,
                                             "&BBOX={0}%2C{1}%2C{2}%2C{3}", xmin, ymin, xmax, ymax);
                }
            }
            uri = MapUrl + queryString;
            //not asynchronize, to ensure only return result until download complete
            try
            {
                if (uri.Length < 2048)
                {
                    return(HttpGetTileBytes(uri));
                }
                else
                {
                    throw new Exception("PBS does not support to send POST request to WMS service currently.");
                    //if (MapUrl.Contains("ArcGIS/services"))
                    //    throw new Exception("ArcGIS Server does not allow to post request to WMS service.");
                    //return HttpPostTileBytes(MapUrl, queryString.ToString());
                }
            }
            catch (Exception e)
            {
                string suffix = this.TilingScheme.CacheTileFormat.ToString().Contains("PNG") ? "png" : "jpg";
                Stream stream = this.GetType().Assembly.GetManifestResourceStream("PBS.Assets.badrequest" + this.TilingScheme.TileCols + "." + suffix);
                byte[] bytes  = new byte[stream.Length];
                stream.Read(bytes, 0, bytes.Length);
                return(bytes);
            }
        }