protected void Page_Load(object sender, EventArgs e) { GLatLng latlng = new GLatLng(46, 21); GMap1.setCenter(latlng, 4); List<GLatLng> puntos = new List<GLatLng>(); puntos.Add(latlng + new GLatLng(0, 8)); puntos.Add(latlng + new GLatLng(-0.5, 4.2)); puntos.Add(latlng); puntos.Add(latlng + new GLatLng(3.5, -4)); puntos.Add(latlng + new GLatLng(4.79, +2.6)); GPolygon poligono = new GPolygon(puntos, "557799", 3, 0.5, "237464", 0.5); poligono.close(); GMap1.Add(poligono); List<GLatLng> puntos2 = new List<GLatLng>(); puntos2.Add(latlng + new GLatLng(5, -8)); puntos2.Add(latlng + new GLatLng(5, -6)); puntos2.Add(latlng + new GLatLng(5, -4)); puntos2.Add(latlng); puntos2.Add(latlng + new GLatLng(-5, 0)); GPolygon poligono2 = new GPolygon(puntos2, "000000", 3, 1, "654321", 1); GMap1.Add(poligono2); GPolygon poligono3 = new GPolygon(new List<GLatLng>(), "00ff00", 3, 1, "ff0044", 1); poligono3.createPolygon(latlng + new GLatLng(-6, -7.5), 7, 4, Math.PI / 3); GMap1.Add(poligono3); }
protected void Page_Load(object sender, EventArgs e) { GLatLng latlon = new GLatLng(10.2, 22); GMap1.setCenter(latlon, 4); GMarker icono = new GMarker(latlon); GInfoWindow window = new GInfoWindow(icono, "Ejemplo de <b>infoWindow</b>", false, GListener.Event.mouseover); GMap1.Add(window); GPolygon polygon = new GPolygon(); polygon.points.Add(new GLatLng(9, 25)); polygon.points.Add(new GLatLng(3, 22)); polygon.points.Add(new GLatLng(1, 26)); polygon.close(); GPolyline polyline = new GPolyline(polygon); GInfoWindow window2 = new GInfoWindow(); //window2.gPolygon = polygon; //window2.html = "GPolygon"; window2.gPolyline = polyline; window2.html = "polyline"; window2.opened = true; window2.sourceEvent = GListener.Event.click; GMap1.Add(window2); }
void Read(MIFRegion mp, GType gType) { for (int p = 0; p < mp.parts; p++) { Point[] pnt = new Point[mp.points[p].Length]; for (int i = 0; i < mp.points[p].Length; i++) { pnt[i].X = (int)(mp.points[p][i].X * 100.0); pnt[i].Y = (int)(mp.points[p][i].Y * 100.0); UpdateBounds(pnt[i]); } if (mp.points[p].Length > 2) { GPolygon gobj = new GPolygon(gType, pnt); SetCaption(gobj); SetName(gobj); // 02.06.09 ¬ременное ¤вление!!! _setBuildToAddr(gobj); cnt++; } } }
protected void Page_Load(object sender, EventArgs e) { GLatLng latlng = new GLatLng(46, 21); GMap1.setCenter(latlng, 4); List <GLatLng> puntos = new List <GLatLng>(); puntos.Add(latlng + new GLatLng(0, 8)); puntos.Add(latlng + new GLatLng(-0.5, 4.2)); puntos.Add(latlng); puntos.Add(latlng + new GLatLng(3.5, -4)); puntos.Add(latlng + new GLatLng(4.79, +2.6)); GPolygon poligono = new GPolygon(puntos, "557799", 3, 0.5, "237464", 0.5); poligono.close(); GMap1.Add(poligono); List <GLatLng> puntos2 = new List <GLatLng>(); puntos2.Add(latlng + new GLatLng(5, -8)); puntos2.Add(latlng + new GLatLng(5, -6)); puntos2.Add(latlng + new GLatLng(5, -4)); puntos2.Add(latlng); puntos2.Add(latlng + new GLatLng(-5, 0)); GPolygon poligono2 = new GPolygon(puntos2, "000000", 3, 1, "654321", 1); GMap1.Add(poligono2); GPolygon poligono3 = new GPolygon(new List <GLatLng>(), "00ff00", 3, 1, "ff0044", 1); poligono3.createPolygon(latlng + new GLatLng(-6, -7.5), 7, 4, Math.PI / 3); GMap1.Add(poligono3); }
void Read(ShapePolygon sp) { for (int p = 0; p < sp.numParts; p++) { uint max = sp.numPoints; if (p < sp.numParts - 1) { max = sp.parts[p + 1]; } uint len = sp.numPoints; if (p < sp.numParts - 1) { len = sp.parts[p + 1] - sp.parts[p]; } else { len = sp.numPoints - sp.parts[p]; } Point[] pnt = new Point[len]; int j = 0; for (uint i = sp.parts[p]; i < max; i++) { pnt[j].X = XTransform(sp.points[i].X); pnt[j].Y = YTransform(sp.points[i].Y); j++; } GPolygon gobj = new GPolygon(curType, pnt); } }
public GObject Create() { GObject obj = null; switch (type.GeomType) { case GeomType.Point: obj = new GPoint(type, Points[0]); break; case GeomType.Caption: obj = new GCaption(type, Points[0]); break; case GeomType.Polyline: obj = new GPolyline(type, Points); break; case GeomType.Polygon: obj = new GPolygon(type, Points); break; } if (obj != null) { app.ShowProperties(obj); } app.Lib.Selection.Clear(); app.CheckRepaint(this); app.UpdateControls(); return(obj); }
private void _setBuildToAddr(GPolygon gobj) { if (gobj.Type.Name == "BuildingsRegion") { foreach (GType gtype in lib.AllTypes) { if (gtype.Name == "addrsText") { if (gtype.Ranges != null) { foreach (GRange range in gtype.Ranges) { foreach (GObject gobj1 in range.Objects) { if (gobj.Contains(gobj1.Center)) { gobj.Caption = gobj1.Caption; gobj.Name = gobj1.Name; return; } } } } } } } }
protected void Page_Load(object sender, EventArgs e) { GLatLng latlng = new GLatLng(41, -3.2); GMap1.setCenter(latlng, 5, GMapType.GTypes.Satellite); GMarkerOptions mOpts = new GMarkerOptions(); mOpts.draggable = true; GMarker marker = new GMarker(latlng, mOpts); GMap1.Add(marker); GListener listener = new GListener(marker.ID, GListener.Event.dragend, "alertame"); GMap1.Add(listener); GMarker mkr = new GMarker(); mkr.options = mOpts; mkr.javascript_GLatLng = "mouseEvent.latLng"; listener = new GListener(mkr.ID, GListener.Event.dragend, "alertame"); System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("function(mouseEvent) {"); sb.Append(mkr.ToString(GMap1.GMap_Id)); sb.Append(listener.ToString()); sb.Append("}"); GListener listener2 = new GListener(GMap1.GMap_Id, GListener.Event.click, sb.ToString()); GMap1.Add(listener2); GMap1.Add(new GListener(GMap1.GMap_Id, GListener.Event.moveend, "function() {alert('I Love Elvis :9P');}")); GPolygon polygon = new GPolygon(); polygon.Add(latlng + new GLatLng(1, 1)); polygon.Add(latlng + new GLatLng(2, 3)); polygon.Add(latlng + new GLatLng(4, 4)); polygon.close(); GMap1.Add(polygon); GListener listener3 = new GListener(polygon.PolygonID, GListener.Event.click, "function(mouseEvent) {alert('Polygon clicked');}"); GMap1.Add(listener3); }
void WriteLine(GPolygon obj, Map map) { Point[] pp = (Point[])obj.Points.Clone(); map.WToG(pp); string objName = ToHtmlString(obj.Name); Write("<AREA href=javascript:onareaclick('{0}') onmouseover=showtip('{0}') onmouseout=hidetip() shape=POLY coords=", objName); for (int i = 0; i < pp.Length; i++) { if (i > 0) { Write(","); } Point p = pp[i]; Write("{0},{1}", p.X, p.Y); } WriteLine(">", objName); }
private void ReadPolygon(DXFObject dxf, GType gType) { Point[] pnt = new Point[dxf.points.Count]; for (int i = 0; i < dxf.points.Count; i++) { pnt[i].X = (int)(dxf.points[i].X * 100.0); pnt[i].Y = (int)(dxf.points[i].Y * 100.0); pointcount++; UpdateBounds(pnt[i]); } unitcount++; if (dxf.points.Count > 2) { GPolygon gobj = new GPolygon(gType, pnt); } }
/// <summary> /// Initialize the map /// </summary> public void InitializeMapData() { // populate map data var db = Sitecore.Context.Database; if (DataSource == null || DataSource.TemplateName != Settings.GoogleMapTemplateName) { Log.Error("Google Maps Module - could not find the data source to display the map", Settings.LoggingOwner); return; } try { // get map settings CurrentMap = new GMap(); CurrentMap.CanvasID = "map_canvas" + ClientID; // EnsureField checks whether a field is present on an item and logs errors Utilities.EnsureField(DataSource, "Latitude", true); Utilities.EnsureField(DataSource, "Longitude", true); CurrentMap.Center = new GLatLng(DataSource.Fields["Latitude"].Value, DataSource.Fields["Longitude"].Value); Utilities.EnsureField(DataSource, "Initial Zoom Level", false); CurrentMap.Zoom = int.Parse(DataSource.Fields["Initial Zoom Level"].Value); Utilities.EnsureField(DataSource, "Width", false); Utilities.EnsureField(DataSource, "Height", false); CurrentMap.Width = int.Parse(DataSource.Fields["Width"].Value); CurrentMap.Height = int.Parse(DataSource.Fields["Height"].Value); Utilities.EnsureField(DataSource, "Map Types", false); CurrentMap.MapTypes = new List <string>(); MultilistField mapTypes = ((MultilistField)DataSource.Fields["Map Types"]); foreach (ID mapTypeId in mapTypes.TargetIDs) { Item mapTypeItem = db.GetItem(mapTypeId); Utilities.EnsureField(mapTypeItem, "Type", true); CurrentMap.MapTypes.Add(mapTypeItem.Fields["Type"].Value); } Utilities.EnsureField(DataSource, "Draggable Cursor", false); CurrentMap.DraggableCursor = DataSource.Fields["Draggable Cursor"].Value; Utilities.EnsureField(DataSource, "Dragging Cursor", false); CurrentMap.DraggingCursor = DataSource.Fields["Dragging Cursor"].Value; int tmpval; Utilities.EnsureField(DataSource, "Min Zoom Level", false); if (int.TryParse(DataSource.Fields["Min Zoom Level"].Value, out tmpval)) { CurrentMap.MinZoomLevel = tmpval; } else { CurrentMap.MinZoomLevel = null; } Utilities.EnsureField(DataSource, "Max Zoom Level", false); if (int.TryParse(DataSource.Fields["Max Zoom Level"].Value, out tmpval)) { CurrentMap.MaxZoomLevel = tmpval; } else { CurrentMap.MaxZoomLevel = null; } Utilities.EnsureField(DataSource, "Enable Double Click Zoom", false); CurrentMap.EnableDoubleClickZoom = ((CheckboxField)DataSource.Fields["Enable Double Click Zoom"]).Checked; Utilities.EnsureField(DataSource, "Enable Dragging", false); CurrentMap.EnableDragging = ((CheckboxField)DataSource.Fields["Enable Dragging"]).Checked; Utilities.EnsureField(DataSource, "Enable Scroll Wheel Zoom", false); CurrentMap.EnableScrollWheelZoom = ((CheckboxField)DataSource.Fields["Enable Scroll Wheel Zoom"]).Checked; Utilities.EnsureField(DataSource, "Enable Keyboard Functionality", false); CurrentMap.EnableKeyboardFunctionality = ((CheckboxField)DataSource.Fields["Enable Keyboard Functionality"]).Checked; Utilities.EnsureField(DataSource, "Disable All Default UI Elements", false); CurrentMap.DisableAllDefaultUIElements = ((CheckboxField)DataSource.Fields["Disable All Default UI Elements"]).Checked; Utilities.EnsureField(DataSource, "Enable Overview", false); CurrentMap.EnableOverview = ((CheckboxField)DataSource.Fields["Enable Overview"]).Checked; Utilities.EnsureField(DataSource, "Enable Pan Control", false); CurrentMap.EnablePanControl = ((CheckboxField)DataSource.Fields["Enable Pan Control"]).Checked; Utilities.EnsureField(DataSource, "Enable Scale Control", false); CurrentMap.EnableScaleControl = ((CheckboxField)DataSource.Fields["Enable Scale Control"]).Checked; Utilities.EnsureField(DataSource, "Enable Street View Control", false); CurrentMap.EnableStreetViewControl = ((CheckboxField)DataSource.Fields["Enable Street View Control"]).Checked; Utilities.EnsureField(DataSource, "Enable Zoom Control", false); CurrentMap.EnableZoomControl = ((CheckboxField)DataSource.Fields["Enable Zoom Control"]).Checked; // get all markers CurrentMap.Markers = new List <GMarker>(); CurrentMap.Lines = new List <GLine>(); CurrentMap.Polygons = new List <GPolygon>(); if (DataSource.HasChildren) { foreach (Item childElement in DataSource.Children) { if (childElement.TemplateName == Settings.LocationTemplateName) { GMarker marker = new GMarker(); Utilities.EnsureField(childElement, "Latitude", true); Utilities.EnsureField(childElement, "Longitude", true); marker.Position = new GLatLng(childElement.Fields["Latitude"].Value, childElement.Fields["Longitude"].Value); marker.Title = childElement.Name; Utilities.EnsureField(childElement, "Text", false); marker.InfoWindow = childElement.Fields["Text"].Value; // check if marker has a custom icon if (childElement.Fields["Custom Icon"] != null && childElement.Fields["Custom Icon"].HasValue && ((ReferenceField)childElement.Fields["Custom Icon"]).TargetItem != null) { Item customIcon = ((ReferenceField)childElement.Fields["Custom Icon"]).TargetItem; GIcon icon = new GIcon(); Utilities.EnsureField(customIcon, "Image", true); icon.ImageURL = Sitecore.StringUtil.EnsurePrefix('/', MediaManager.GetMediaUrl(((Sitecore.Data.Fields.ImageField)customIcon.Fields["Image"]).MediaItem)); icon.ImageDimensions = Utilities.GetMediaItemSize((Sitecore.Data.Fields.ImageField)customIcon.Fields["Image"]); Utilities.EnsureField(customIcon, "Anchor", false); icon.Anchor = Utilities.StringToPoint(customIcon.Fields["Anchor"].Value); Utilities.EnsureField(customIcon, "Shadow Image", false); if (customIcon.Fields["Shadow Image"].HasValue && ((Sitecore.Data.Fields.ImageField)customIcon.Fields["Shadow Image"]).MediaItem != null) { icon.ShadowURL = Sitecore.StringUtil.EnsurePrefix('/', MediaManager.GetMediaUrl(((Sitecore.Data.Fields.ImageField)customIcon.Fields["Shadow Image"]).MediaItem)); icon.ShadowDimensions = Utilities.GetMediaItemSize((Sitecore.Data.Fields.ImageField)customIcon.Fields["Shadow Image"]); Utilities.EnsureField(customIcon, "Shadow Anchor", false); icon.ShadowAnchor = Utilities.StringToPoint(customIcon.Fields["Shadow Anchor"].Value); } Utilities.EnsureField(customIcon, "Clickable Polygon", false); if (customIcon.Fields["Clickable Polygon"].HasValue && !string.IsNullOrEmpty(customIcon.Fields["Clickable Polygon"].Value)) { icon.ClickablePolygon = customIcon.Fields["Clickable Polygon"].Value; } marker.CustomIcon = icon; } CurrentMap.Markers.Add(marker); } else if (childElement.TemplateName == Settings.LineTemplateName) { GLine line = new GLine(); Utilities.EnsureField(childElement, "Stroke Color", false); line.StrokeColor = childElement.Fields["Stroke Color"].Value; Utilities.EnsureField(childElement, "Stroke Opacity", false); line.StrokeOpacity = Utilities.EnsureOpacity(childElement.Fields["Stroke Opacity"].Value); Utilities.EnsureField(childElement, "Stroke Weight", false); line.StrokeWeight = Utilities.EnsureWeight(childElement.Fields["Stroke Weight"].Value); Utilities.EnsureField(childElement, "Points", false); var points = ((MultilistField)childElement.Fields["Points"]).Items; line.Points = Utilities.ArrayToLatLngList(points); CurrentMap.Lines.Add(line); } else if (childElement.TemplateName == Settings.PolygonTemplateName) { GPolygon poly = new GPolygon(); Utilities.EnsureField(childElement, "Stroke Color", false); poly.StrokeColor = childElement.Fields["Stroke Color"].Value; Utilities.EnsureField(childElement, "Stroke Opacity", false); poly.StrokeOpacity = Utilities.EnsureOpacity(childElement.Fields["Stroke Opacity"].Value); Utilities.EnsureField(childElement, "Stroke Weight", false); poly.StrokeWeight = Utilities.EnsureWeight(childElement.Fields["Stroke Weight"].Value); Utilities.EnsureField(childElement, "Points", false); var points = ((MultilistField)childElement.Fields["Points"]).Items; poly.Points = Utilities.ArrayToLatLngList(points); Utilities.EnsureField(childElement, "Fill Color", false); poly.FillColor = childElement.Fields["Fill Color"].Value; Utilities.EnsureField(childElement, "Fill Opacity", false); poly.FillOpacity = Utilities.EnsureOpacity(childElement.Fields["Fill Opacity"].Value); Utilities.EnsureField(childElement, "Is Clickable", false); poly.Clickable = ((CheckboxField)childElement.Fields["Is Clickable"]).Checked; Utilities.EnsureField(childElement, "Text", false); poly.InfoWindow = childElement.Fields["Text"].Value; CurrentMap.Polygons.Add(poly); } } } } catch (FieldValidationException) { // this has been logged already - nothing to do here. } catch (Exception ex) { Log.Error("Google Maps Module - could not initialize the map", ex, Settings.LoggingOwner); } }
private void constructMap(string chosenLoc, int code) { List<List<Point>> cornersList = new List<List<Point>>(); List<GPolygon> rectangles = new List<GPolygon>(); List<string> seHoods = new List<string>(); List<string> allHoods = new List<string>(); List<Point> corners = new List<Point>(); List<Point> cornersChosenLoc = new List<Point>(); GPolygon target = new GPolygon(); cornersChosenLoc = Globals.RectangleCoords["Metromix" + "/" + chosenLoc]; cornersList.Add(cornersChosenLoc); rectangles = constructRectangles(cornersList, Rectangle.TARGET); target = rectangles[0]; PolygonWrapper N = new PolygonWrapper(); N.Polygon = target; N.HoodName = chosenLoc; N.Area = getArea(cornersChosenLoc); rectangles.Clear(); cornersList.Clear(); GLatLng center = new GLatLng((cornersChosenLoc[0].y + cornersChosenLoc[1].y) / 2, (cornersChosenLoc[0].x + cornersChosenLoc[1].x) / 2); if (code == 0) { GMap2.enableDragging = true; GMap2.enableGoogleBar = true; GMap2.enableHookMouseWheelToZoom = true; GMap2.Language = "eng"; GMap2.BackColor = Color.White; GMap2.Add(target); placeMarkers(code); GMap2.setCenter(center, 12); } if (code == 1) { seHoods = Globals.getLocations(chosenLoc, Globals.searchEngines[code].getCode); allHoods = Globals.getLocationsAllIntersections(chosenLoc, Globals.searchEngines[code].getCode); List<PolygonWrapper> polygons = new List<PolygonWrapper>(); foreach (string hood in seHoods) { PolygonWrapper rectangle = new PolygonWrapper(); corners = Globals.RectangleCoords["DexKnows" + "/" + hood]; rectangle.Area = getArea(corners); rectangle.HoodName = hood; rectangle.Polygon = constructRectangle(corners, Rectangle.CHOSEN); polygons.Add(rectangle); Globals.cornersAllSelectedLocs.Add(corners); } foreach (string hood in allHoods) { if (!seHoods.Contains(hood)) { PolygonWrapper rectangle = new PolygonWrapper(); corners = Globals.RectangleCoords["DexKnows" + "/" + hood]; rectangle.Area = getArea(corners); rectangle.HoodName = hood; rectangle.Polygon = constructRectangle(corners, Rectangle.NOTCHOSEN); polygons.Add(rectangle); } } polygons.Add(N); MergeResults.orderPolygonsByArea(polygons); foreach (PolygonWrapper r in polygons) { GMap3.Add(r.Polygon); string name = r.HoodName; name = "\"" + name + "\""; GMap3.addListener(new GListener(r.Polygon.PolygonID, GListener.Event.click, "function(center) { var myHtml =" + name + "; subgurim_GMap3.openInfoWindowHtml(center, myHtml); }")); } GMap3.enableDragging = true; GMap3.enableHookMouseWheelToZoom = true; GMap3.Language = "eng"; GMap3.BackColor = Color.White; placeMarkers(code); GMap3.setCenter(center, 12); } if (code == 2) { seHoods = Globals.getLocations(chosenLoc, Globals.searchEngines[code].getCode); allHoods = Globals.getLocationsAllIntersections(chosenLoc, Globals.searchEngines[code].getCode); List<PolygonWrapper> polygons = new List<PolygonWrapper>(); foreach (string hood in seHoods) { PolygonWrapper rectangle = new PolygonWrapper(); corners = Globals.RectangleCoords["Yelp" + "/" + hood]; rectangle.Area = getArea(corners); rectangle.HoodName = hood; rectangle.Polygon = constructRectangle(corners, Rectangle.CHOSEN); polygons.Add(rectangle); Globals.cornersAllSelectedLocs.Add(corners); } foreach (string hood in allHoods) { if (!seHoods.Contains(hood)) { PolygonWrapper rectangle = new PolygonWrapper(); corners = Globals.RectangleCoords["Yelp" + "/" + hood]; rectangle.Area = getArea(corners); rectangle.HoodName = hood; rectangle.Polygon = constructRectangle(corners, Rectangle.NOTCHOSEN); polygons.Add(rectangle); } } polygons.Add(N); MergeResults.orderPolygonsByArea(polygons); foreach (PolygonWrapper r in polygons) { GMap4.Add(r.Polygon); string name = r.HoodName; name = "\"" + name + "\""; GMap4.addListener(new GListener(r.Polygon.PolygonID, GListener.Event.click, "function(center) { var myHtml =" + name + "; subgurim_GMap4.openInfoWindowHtml(center, myHtml); }")); } GMap4.enableDragging = true; //GMap4.enableGoogleBar = true; GMap4.enableHookMouseWheelToZoom = true; GMap4.Language = "eng"; GMap4.BackColor = Color.White; placeMarkers(code); GMap4.setCenter(center, 12); } if (code == 3) { seHoods = Globals.getLocations(chosenLoc, Globals.searchEngines[code].getCode); allHoods = Globals.getLocationsAllIntersections(chosenLoc, Globals.searchEngines[code].getCode); List<PolygonWrapper> polygons = new List<PolygonWrapper>(); foreach (string hood in seHoods) { PolygonWrapper rectangle = new PolygonWrapper(); corners = Globals.RectangleCoords["ChicagoReader" + "/" + hood]; rectangle.Area = getArea(corners); rectangle.HoodName = hood; rectangle.Polygon = constructRectangle(corners, Rectangle.CHOSEN); polygons.Add(rectangle); Globals.cornersAllSelectedLocs.Add(corners); } foreach (string hood in allHoods) { if (!seHoods.Contains(hood)) { PolygonWrapper rectangle = new PolygonWrapper(); corners = Globals.RectangleCoords["ChicagoReader" + "/" + hood]; rectangle.Area = getArea(corners); rectangle.HoodName = hood; rectangle.Polygon = constructRectangle(corners, Rectangle.NOTCHOSEN); polygons.Add(rectangle); } } polygons.Add(N); MergeResults.orderPolygonsByArea(polygons); foreach (PolygonWrapper r in polygons) { GMap5.Add(r.Polygon); string name = r.HoodName; name = "\"" + name + "\""; GMap5.addListener(new GListener(r.Polygon.PolygonID, GListener.Event.click, "function(center) { var myHtml =" + name + "; subgurim_GMap5.openInfoWindowHtml(center, myHtml); }")); } GMap5.enableDragging = true; GMap5.enableHookMouseWheelToZoom = true; GMap5.Language = "eng"; GMap5.BackColor = Color.White; placeMarkers(code); GMap5.setCenter(center, 12); } if (code == 4) { seHoods = Globals.getLocations(chosenLoc, Globals.searchEngines[code].getCode); allHoods = Globals.getLocationsAllIntersections(chosenLoc, Globals.searchEngines[code].getCode); List<PolygonWrapper> polygons = new List<PolygonWrapper>(); foreach (string hood in seHoods) { PolygonWrapper rectangle = new PolygonWrapper(); corners = Globals.RectangleCoords["Menuism" + "/" + hood]; rectangle.Area = getArea(corners); rectangle.HoodName = hood; rectangle.Polygon = constructRectangle(corners, Rectangle.CHOSEN); polygons.Add(rectangle); Globals.cornersAllSelectedLocs.Add(corners); } foreach (string hood in allHoods) { if (!seHoods.Contains(hood)) { PolygonWrapper rectangle = new PolygonWrapper(); corners = Globals.RectangleCoords["Menuism" + "/" + hood]; rectangle.Area = getArea(corners); rectangle.HoodName = hood; rectangle.Polygon = constructRectangle(corners, Rectangle.NOTCHOSEN); polygons.Add(rectangle); } } polygons.Add(N); MergeResults.orderPolygonsByArea(polygons); foreach (PolygonWrapper r in polygons) { GMap6.Add(r.Polygon); string name = r.HoodName; name = "\"" + name + "\""; GMap6.addListener(new GListener(r.Polygon.PolygonID, GListener.Event.click, "function(center) { var myHtml =" + name + "; subgurim_GMap6.openInfoWindowHtml(center, myHtml); }")); } GMap6.enableDragging = true; GMap6.enableHookMouseWheelToZoom = true; GMap6.Language = "eng"; GMap6.BackColor = Color.White; placeMarkers(code); GMap6.setCenter(center, 12); } if (code == 5) { seHoods = Globals.getLocations(chosenLoc, Globals.searchEngines[code].getCode); allHoods = Globals.getLocationsAllIntersections(chosenLoc, Globals.searchEngines[code].getCode); List<PolygonWrapper> polygons = new List<PolygonWrapper>(); foreach (string hood in seHoods) { PolygonWrapper rectangle = new PolygonWrapper(); corners = Globals.RectangleCoords["MenuPages" + "/" + hood]; rectangle.Area = getArea(corners); rectangle.HoodName = hood; rectangle.Polygon = constructRectangle(corners, Rectangle.CHOSEN); polygons.Add(rectangle); Globals.cornersAllSelectedLocs.Add(corners); } foreach (string hood in allHoods) { if (!seHoods.Contains(hood)) { PolygonWrapper rectangle = new PolygonWrapper(); corners = Globals.RectangleCoords["MenuPages" + "/" + hood]; rectangle.Area = getArea(corners); rectangle.HoodName = hood; rectangle.Polygon = constructRectangle(corners, Rectangle.NOTCHOSEN); polygons.Add(rectangle); } } polygons.Add(N); MergeResults.orderPolygonsByArea(polygons); foreach (PolygonWrapper r in polygons) { GMap7.Add(r.Polygon); string name = r.HoodName; name = "\"" + name + "\""; GMap7.addListener(new GListener(r.Polygon.PolygonID, GListener.Event.click, "function(center) { var myHtml =" + name + "; subgurim_GMap7.openInfoWindowHtml(center, myHtml); }")); } GMap7.enableDragging = true; GMap7.enableHookMouseWheelToZoom = true; GMap7.Language = "eng"; GMap7.BackColor = Color.White; placeMarkers(code); GMap7.setCenter(center, 12); } if (code == 6) { seHoods = Globals.getLocations(chosenLoc, Globals.searchEngines[code].getCode); allHoods = Globals.getLocationsAllIntersections(chosenLoc, Globals.searchEngines[code].getCode); List<PolygonWrapper> polygons = new List<PolygonWrapper>(); foreach (string hood in seHoods) { PolygonWrapper rectangle = new PolygonWrapper(); corners = Globals.RectangleCoords["Yahoo" + "/" + hood]; rectangle.Area = getArea(corners); rectangle.HoodName = hood; rectangle.Polygon = constructRectangle(corners, Rectangle.CHOSEN); polygons.Add(rectangle); Globals.cornersAllSelectedLocs.Add(corners); } foreach (string hood in allHoods) { if (!seHoods.Contains(hood)) { PolygonWrapper rectangle = new PolygonWrapper(); corners = Globals.RectangleCoords["Yahoo" + "/" + hood]; rectangle.Area = getArea(corners); rectangle.HoodName = hood; rectangle.Polygon = constructRectangle(corners, Rectangle.NOTCHOSEN); polygons.Add(rectangle); } } polygons.Add(N); MergeResults.orderPolygonsByArea(polygons); foreach (PolygonWrapper r in polygons) { GMap8.Add(r.Polygon); string name = r.HoodName; name = "\"" + name + "\""; GMap8.addListener(new GListener(r.Polygon.PolygonID, GListener.Event.click, "function(center) { var myHtml =" + name + "; subgurim_GMap8.openInfoWindowHtml(center, myHtml); }")); } GMap8.enableDragging = true; GMap8.enableHookMouseWheelToZoom = true; GMap8.Language = "eng"; GMap8.BackColor = Color.White; placeMarkers(code); GMap8.setCenter(center, 12); } if (code == 7) { seHoods = Globals.getLocations(chosenLoc, Globals.searchEngines[code].getCode); allHoods = Globals.getLocationsAllIntersections(chosenLoc, Globals.searchEngines[code].getCode); List<PolygonWrapper> polygons = new List<PolygonWrapper>(); foreach (string hood in seHoods) { PolygonWrapper rectangle = new PolygonWrapper(); corners = Globals.RectangleCoords["YellowPages" + "/" + hood]; rectangle.Area = getArea(corners); rectangle.HoodName = hood; rectangle.Polygon = constructRectangle(corners, Rectangle.CHOSEN); polygons.Add(rectangle); Globals.cornersAllSelectedLocs.Add(corners); } foreach (string hood in allHoods) { if (!seHoods.Contains(hood)) { PolygonWrapper rectangle = new PolygonWrapper(); corners = Globals.RectangleCoords["YellowPages" + "/" + hood]; rectangle.Area = getArea(corners); rectangle.HoodName = hood; rectangle.Polygon = constructRectangle(corners, Rectangle.NOTCHOSEN); polygons.Add(rectangle); } } polygons.Add(N); MergeResults.orderPolygonsByArea(polygons); foreach (PolygonWrapper r in polygons) { GMap9.Add(r.Polygon); string name = r.HoodName; name = "\"" + name + "\""; GMap9.addListener(new GListener(r.Polygon.PolygonID, GListener.Event.click, "function(center) { var myHtml =" + name + "; subgurim_GMap9.openInfoWindowHtml(center, myHtml); }")); } GMap9.enableDragging = true; GMap9.enableHookMouseWheelToZoom = true; GMap9.Language = "eng"; GMap9.BackColor = Color.White; placeMarkers(code); GMap9.setCenter(center, 12); } if (code == 8) { seHoods = Globals.getLocations(chosenLoc, Globals.searchEngines[code].getCode); allHoods = Globals.getLocationsAllIntersections(chosenLoc, Globals.searchEngines[code].getCode); List<PolygonWrapper> polygons = new List<PolygonWrapper>(); foreach (string hood in seHoods) { PolygonWrapper rectangle = new PolygonWrapper(); corners = Globals.RectangleCoords["CitySearch" + "/" + hood]; rectangle.Area = getArea(corners); rectangle.HoodName = hood; rectangle.Polygon = constructRectangle(corners, Rectangle.CHOSEN); polygons.Add(rectangle); Globals.cornersAllSelectedLocs.Add(corners); } foreach (string hood in allHoods) { if (!seHoods.Contains(hood)) { PolygonWrapper rectangle = new PolygonWrapper(); corners = Globals.RectangleCoords["CitySearch" + "/" + hood]; rectangle.Area = getArea(corners); rectangle.HoodName = hood; rectangle.Polygon = constructRectangle(corners, Rectangle.NOTCHOSEN); polygons.Add(rectangle); } } polygons.Add(N); MergeResults.orderPolygonsByArea(polygons); foreach (PolygonWrapper r in polygons) { GMap10.Add(r.Polygon); string name = r.HoodName; name = "\"" + name + "\""; GMap10.addListener(new GListener(r.Polygon.PolygonID, GListener.Event.click, "function(center) { var myHtml =" + name + "; subgurim_GMap10.openInfoWindowHtml(center, myHtml); }")); } GMap10.enableDragging = true; GMap10.enableHookMouseWheelToZoom = true; GMap10.Language = "eng"; GMap10.BackColor = Color.White; placeMarkers(code); GMap10.setCenter(center, 12); } if (code == 10) { GMap1.enableDragging = true; GMap1.enableGoogleBar = true; GMap1.enableHookMouseWheelToZoom = true; GMap1.Language = "eng"; GMap1.BackColor = Color.White; GPolygon yumiTarget = new GPolygon(); corners = Globals.RectangleCoords["Metromix" + "/" + chosenLoc]; cornersList.Add(corners); rectangles = constructRectangles(cornersList, Rectangle.TARGET); yumiTarget = rectangles[0]; rectangles.Clear(); cornersList.Clear(); GMap1.Add(yumiTarget); Globals.cornersAllSelectedLocs = Globals.cornersAllSelectedLocs.Distinct(new PointListComparer()).ToList(); rectangles.AddRange(constructRectangles(Globals.cornersAllSelectedLocs, Rectangle.CHOSEN)); foreach (GPolygon polygon in rectangles) { GMap1.Add(polygon); } placeMarkers(code); GMap1.setCenter(center, 12); } }
protected void Button1_Click(object sender, EventArgs e) { //from here u need to remove comments CheckBoxList1.Style["display"] = "none"; Table1.Rows.Clear(); Table2.Rows.Clear(); Table3.Rows.Clear(); Table4.Rows.Clear(); Table5.Rows.Clear(); Table6.Rows.Clear(); Table7.Rows.Clear(); Table8.Rows.Clear(); Table9.Rows.Clear(); Table10.Rows.Clear(); Table11.Rows.Clear(); Table12.Rows.Clear(); Table13.Rows.Clear(); Table14.Rows.Clear(); Table15.Rows.Clear(); Table16.Rows.Clear(); Table17.Rows.Clear(); Table18.Rows.Clear(); Table19.Rows.Clear(); Table20.Rows.Clear(); Globals.metromixLocalDataAllRuns.Clear(); Globals.metromixLocalDataMerged.Clear(); Globals.metromixLocalDataMergedSorted.Clear(); Globals.dexknowsLocalDataAllRuns.Clear(); Globals.dexknowsLocalDataMerged.Clear(); Globals.dexknowsLocalDataMergedSorted.Clear(); Globals.yelpLocalDataAllRuns.Clear(); Globals.yelpLocalDataMerged.Clear(); Globals.yelpLocalDataMergedSorted.Clear(); Globals.chicagoreaderLocalDataAllRuns.Clear(); Globals.chicagoreaderLocalDataMerged.Clear(); Globals.chicagoreaderLocalDataMergedSorted.Clear(); Globals.menuismLocalDataAllRuns.Clear(); Globals.menuismLocalDataMerged.Clear(); Globals.menuismLocalDataMergedSorted.Clear(); Globals.menupagesLocalDataAllRuns.Clear(); Globals.menupagesLocalDataMerged.Clear(); Globals.menupagesLocalDataMergedSorted.Clear(); Globals.yahooLocalDataAllRuns.Clear(); Globals.yahooLocalDataMerged.Clear(); Globals.yahooLocalDataMergedSorted.Clear(); Globals.yellowpagesLocalDataAllRuns.Clear(); Globals.yellowpagesLocalDataMerged.Clear(); Globals.yellowpagesLocalDataMergedSorted.Clear(); Globals.citysearchLocalDataAllRuns.Clear(); Globals.citysearchLocalDataMerged.Clear(); Globals.citysearchLocalDataMergedSorted.Clear(); Globals.zagatData.Clear(); Globals.results.Clear(); Globals.cornersAllSelectedLocs.Clear(); Globals.closedRestaurants.Clear(); Globals.mergeList.Clear(); Globals.metromixTotalQueries = 0; Globals.dexknowsTotalQueries = 0; Globals.yelpTotalQueries = 0; Globals.chicagoreaderTotalQueries = 0; Globals.menuismTotalQueries = 0; Globals.menupagesTotalQueries = 0; Globals.yahooTotalQueries = 0; Globals.yellowpagesTotalQueries = 0; Globals.citysearchTotalQueries = 0; Globals.zagatTotalQueries = 0; Globals.metromixSpan = 0; Globals.dexknowsSpan = 0; Globals.yelpSpan = 0; Globals.chicagoreaderSpan = 0; Globals.menuismSpan = 0; ; Globals.menupagesSpan = 0; ; Globals.yahooSpan = 0; Globals.yellowpagesSpan = 0; Globals.citysearchSpan = 0; Globals.zagatSpan = 0; GMap1.reset(); GMap2.reset(); GMap3.reset(); GMap4.reset(); GMap4.reset(); GMap5.reset(); GMap6.reset(); GMap7.reset(); GMap8.reset(); GMap9.reset(); GMap10.reset(); MultiView1.ActiveViewIndex = 0; Menu1.Items[0].ImageUrl = "/images/yumiselectedtab.gif"; Menu1.Items[0].Selected = true; for (int i = 1; i < Menu1.Items.Count; i++) { if (i == 1) this.Menu1.Items[i].ImageUrl = "/images/metromixunselectedtab.gif"; else if (i == 2) this.Menu1.Items[i].ImageUrl = "/images/dexknowsunselectedtab.gif"; else if (i == 3) this.Menu1.Items[i].ImageUrl = "/images/yelpunselectedtab.gif"; else if (i == 4) this.Menu1.Items[i].ImageUrl = "/images/chicagoreaderunselectedtab.gif"; else if (i == 5) this.Menu1.Items[i].ImageUrl = "/images/menuismunselectedtab.gif"; else if (i == 6) this.Menu1.Items[i].ImageUrl = "/images/menupagesunselectedtab.gif"; else if (i == 7) this.Menu1.Items[i].ImageUrl = "/images/yahoounselectedtab.gif"; else if (i == 8) this.Menu1.Items[i].ImageUrl = "/images/yellowpagesunselectedtab.gif"; else if (i == 9) this.Menu1.Items[i].ImageUrl = "/images/citysearchunselectedtab.gif"; Menu1.Items[i].Selected = false; } Globals.queryConstraints = 0; Globals.allData.Clear(); for (int i = 0; i < 9; i++) { Globals.allData.Add(new List<Restaurant>()); } Globals.allDataEngineTables.Clear(); for (int i = 0; i < 9; i++) { Globals.allDataEngineTables.Add(new List<Restaurant>()); } if (Globals.selected == false) { for (int i = 0; i < Globals.shortListedNeighborHoods.Count(); i++) { List<Point> chosenLoc = Globals.RectangleCoords["Metromix" + "/" + Globals.shortListedNeighborHoods[i].getName()]; if (Contains(chosenLoc, latlong)) { Globals.location = Globals.shortListedNeighborHoods[i].getName(); break; } else { Globals.location = Globals.shortListedNeighborHoods[0].getName(); } } } else { //Label1.Text = "entered into " + Globals.selected.ToString(); Globals.location = DropDownList1.SelectedValue; } string price = DropDownList2.SelectedValue; string cuisine = DropDownList3.SelectedValue; string keyword = TextBox1.Text; if (Globals.location.Equals("All") && cuisine.Equals("All") && price.Equals("") && keyword.Equals("")) { TableRow header = new TableRow(); TableCell cell = new TableCell(); cell.Text = "Invalid query. Please choose at least one constraint."; cell.Font.Bold = true; header.HorizontalAlign = HorizontalAlign.Center; header.Cells.Add(cell); MultiView1.ActiveViewIndex = 0; Table1.Rows.Add(header); Table1.Visible = true; } else { divImg.Visible = true; Globals.startTime = DateTime.Now; //get enabled searchengines Globals.enabledSE.Clear(); for (int x = 0; x < CheckBoxList1.Items.Count; x++) { if (CheckBoxList1.Items[x].Selected) Globals.enabledSE.Add(x + 1); } //execute query if (!Globals.location.Equals("All")) Globals.queryConstraints = Globals.queryConstraints | (int)Constraints.LOCATION; if (!cuisine.Equals("All")) Globals.queryConstraints = Globals.queryConstraints | (int)Constraints.CUISINE; if (!price.Equals("")) Globals.queryConstraints = Globals.queryConstraints | (int)Constraints.PRICE; Globals.cuisine = cuisine; Globals.results = executeQuery(Globals.location, cuisine, price, keyword); string looooo = Globals.location; if (Globals.location.Equals("All")) { GLatLng centerNoLoc = new GLatLng(42, -87.5); GMap1.setCenter(centerNoLoc, 9); placeMarkers(10); GMap1.enableHookMouseWheelToZoom = true; GMap2.setCenter(centerNoLoc, 9); placeMarkers(0); GMap2.enableHookMouseWheelToZoom = true; GMap3.setCenter(centerNoLoc, 9); placeMarkers(1); GMap3.enableHookMouseWheelToZoom = true; GMap4.setCenter(centerNoLoc, 9); placeMarkers(2); GMap4.enableHookMouseWheelToZoom = true; GMap5.setCenter(centerNoLoc, 9); placeMarkers(3); GMap5.enableHookMouseWheelToZoom = true; GMap6.setCenter(centerNoLoc, 9); placeMarkers(4); GMap6.enableHookMouseWheelToZoom = true; GMap7.setCenter(centerNoLoc, 9); placeMarkers(5); GMap7.enableHookMouseWheelToZoom = true; GMap8.setCenter(centerNoLoc, 9); placeMarkers(6); GMap8.enableHookMouseWheelToZoom = true; GMap9.setCenter(centerNoLoc, 9); placeMarkers(7); GMap9.enableHookMouseWheelToZoom = true; GMap10.setCenter(centerNoLoc, 9); placeMarkers(8); GMap10.enableHookMouseWheelToZoom = true; } else if (Globals.getLevel(Globals.location) == 1) { List<List<Point>> cornersList = new List<List<Point>>(); List<GPolygon> rectangles = new List<GPolygon>(); List<Point> corners = new List<Point>(); List<Point> cornersChosenLoc = new List<Point>(); GPolygon target = new GPolygon(); cornersChosenLoc = Globals.RectangleCoords["Metromix" + "/" + Globals.location]; cornersList.Add(cornersChosenLoc); rectangles = constructRectangles(cornersList, Rectangle.TARGET); target = rectangles[0]; GLatLng center = new GLatLng((cornersChosenLoc[0].y + cornersChosenLoc[1].y) / 2, (cornersChosenLoc[0].x + cornersChosenLoc[1].x) / 2); GMap1.setCenter(center, 10); GMap1.Add(target); placeMarkers(10); GMap1.enableHookMouseWheelToZoom = true; GMap2.setCenter(center, 10); GMap2.Add(target); placeMarkers(0); GMap2.enableHookMouseWheelToZoom = true; GMap3.setCenter(center, 10); GMap3.Add(target); placeMarkers(1); GMap3.enableHookMouseWheelToZoom = true; GMap4.setCenter(center, 10); GMap4.Add(target); placeMarkers(2); GMap4.enableHookMouseWheelToZoom = true; GMap5.setCenter(center, 10); GMap5.Add(target); placeMarkers(3); GMap5.enableHookMouseWheelToZoom = true; GMap6.setCenter(center, 10); GMap6.Add(target); placeMarkers(4); GMap6.enableHookMouseWheelToZoom = true; GMap7.setCenter(center, 10); GMap7.Add(target); placeMarkers(5); GMap7.enableHookMouseWheelToZoom = true; GMap8.setCenter(center, 10); GMap8.Add(target); placeMarkers(6); GMap8.enableHookMouseWheelToZoom = true; GMap9.setCenter(center, 10); GMap9.Add(target); placeMarkers(7); GMap9.enableHookMouseWheelToZoom = true; GMap10.setCenter(center, 10); GMap10.Add(target); placeMarkers(8); GMap10.enableHookMouseWheelToZoom = true; } else { constructMap(Globals.location, 0); constructMap(Globals.location, 1); constructMap(Globals.location, 2); constructMap(Globals.location, 3); constructMap(Globals.location, 4); constructMap(Globals.location, 5); constructMap(Globals.location, 6); constructMap(Globals.location, 7); constructMap(Globals.location, 8); constructMap(Globals.location, 10); } DateTime EndTime = DateTime.Now; TimeSpan span = EndTime.Subtract(Globals.startTime); Globals.results_header = "Found " + Globals.finalResultsCount + " restaurants for " + cuisine + " in " + " (" + span.Minutes + " minutes " + span.Seconds + " seconds)"+"in the radius of "+dist+"miles"; Globals.finalResultsCountTotal = Globals.finalResultsCountTotal + Globals.finalResultsCount; ///////////////////////////////Testing - Timing////////////////////////////////////////////// //if (Globals.getLevel(Globals.location) == 1) // Globals.WriteOutput(Globals.location + "," + Globals.metromixSpan + "," + Globals.dexknowsSpan + "," + Globals.yelpSpan + "," + Globals.chicagoreaderSpan + "," + Globals.menuismSpan + "," + Globals.menupagesSpan + "," + Globals.yahooSpan + "," + Globals.yellowpagesSpan + "," + Globals.citysearchSpan + "," + Globals.zagatSpan + "," + span.Seconds + ",Large Area"); //else // Globals.WriteOutput(Globals.location + "," + Globals.metromixSpan + "," + Globals.dexknowsSpan + "," + Globals.yelpSpan + "," + Globals.chicagoreaderSpan + "," + Globals.menuismSpan + "," + Globals.menupagesSpan + "," + Globals.yahooSpan + "," + Globals.yellowpagesSpan + "," + Globals.citysearchSpan + "," + Globals.zagatSpan + "," + span.Seconds); ///////////////////////////////////////////////////////////////////////////////////////////// constructTable(Globals.results, 10); constructTable(Globals.zagatData, 9); if (Globals.getLevel(Globals.location) == 1) { Globals.requestsArea++; Globals.totalSecondsArea = Globals.totalSecondsArea + span.Seconds; } if (Globals.getLevel(Globals.location) == 0) { Globals.requestsNeighborhood++; Globals.totalSecondsNeighborhood = Globals.totalSecondsNeighborhood + span.Seconds; } /////////////////////////////////Testing - Verbose Timings & Google Requests////////////////////////////////// //try //{ // Globals.WriteOutput("Query location was " + Globals.location + " cuisine was " + cuisine + " done in " + span.Seconds); // Globals.WriteOutput(" Metromix " + Globals.metromixLocalDataAllRuns[0].City); // Globals.WriteOutput(" " + Globals.metromixLocalDataAllRuns[0].Address); // Globals.WriteOutput(" DexKnows " + Globals.dexknowsLocalDataAllRuns[0].City); // Globals.WriteOutput(" " + Globals.dexknowsLocalDataAllRuns[0].Address); // Globals.WriteOutput(" Yelp " + Globals.yelpLocalDataAllRuns[0].City); // Globals.WriteOutput(" " + Globals.yelpLocalDataAllRuns[0].Address); // Globals.WriteOutput(" ChicagoReader " + Globals.chicagoreaderLocalDataAllRuns[0].City); // Globals.WriteOutput(" " + Globals.chicagoreaderLocalDataAllRuns[0].Address); // Globals.WriteOutput(" Menuism " + Globals.menuismLocalDataAllRuns[0].City); // Globals.WriteOutput(" " + Globals.menuismLocalDataAllRuns[0].Address); // Globals.WriteOutput(" MenuPages " + Globals.menupagesLocalDataAllRuns[0].City); // Globals.WriteOutput(" " + Globals.menupagesLocalDataAllRuns[0].Address); // Globals.WriteOutput(" Yahoo " + Globals.yahooLocalDataAllRuns[0].City); // Globals.WriteOutput(" " + Globals.yahooLocalDataAllRuns[0].Address); // //Globals.WriteOutput(" Zagat " + Globals.zagatData[0].City); // //Globals.WriteOutput(" " + Globals.zagatData[0].Address); // try // { // Globals.WriteOutput(" YellowPages " + Globals.yellowpagesLocalDataAllRuns[0].City); // Globals.WriteOutput(" " + Globals.yellowpagesLocalDataAllRuns[0].Address); // } // catch (Exception) // { // //expected exception if yellowpages thread aborted // } // Globals.WriteOutput(" CitySearch " + Globals.citysearchLocalDataAllRuns[0].City); // Globals.WriteOutput(" " + Globals.citysearchLocalDataAllRuns[0].Address); // Globals.WriteOutput(" google requests " + Globals.numberGoogleRequests); //} //catch (Exception ex) //{ // Response.Write("<script>alert('WriteOutput error')</script>"); // Globals.WriteOutput("THREAD ERROR"); //} ////////////////////////////////////////////////////////////////////////////////////////////////// var d2r = Math.PI / 180; // degrees to radians var r2d = 180 / Math.PI; // radians to degrees var earthsradius = 3963; // 3963 is the radius of the earth in miles var points = 32; //var radius = 10; double rlat = ((double)dist / earthsradius) * r2d; double rlng = rlat / Math.Cos(latitude * d2r); List<GLatLng> extp = new List<GLatLng>(); for (var i = 0; i < points + 1; i++) { double theta = Math.PI * (i / (double)(points / 2)); double ex = longitude + (rlng * Math.Cos(theta)); double ey = latitude + (rlat * Math.Sin(theta)); extp.Add(new GLatLng(ey, ex)); } GIcon icon1 = new GIcon(); icon1.image = "/images/urhere2.png"; //icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png"; icon1.iconSize = new GSize(30, 30); icon1.shadowSize = new GSize(22, 20); icon1.iconAnchor = new GPoint(6, 20); icon1.infoWindowAnchor = new GPoint(5, 1); GMarkerOptions mOpts1 = new GMarkerOptions(); mOpts1.clickable = false; mOpts1.icon = icon1; GMarker marker1 = new GMarker(latlong, mOpts1); this.GMap1.addPolygon(new GPolygon(extp, "#00FF00", 0.3)); GMap1.addGMarker(marker1); this.GMap2.addPolygon(new GPolygon(extp, "#00FF00", 0.3)); GMap2.addGMarker(marker1); this.GMap3.addPolygon(new GPolygon(extp, "#00FF00", 0.3)); GMap3.addGMarker(marker1); this.GMap4.addPolygon(new GPolygon(extp, "#00FF00", 0.3)); GMap4.addGMarker(marker1); this.GMap5.addPolygon(new GPolygon(extp, "#00FF00", 0.3)); GMap5.addGMarker(marker1); this.GMap6.addPolygon(new GPolygon(extp, "#00FF00", 0.3)); GMap6.addGMarker(marker1); this.GMap7.addPolygon(new GPolygon(extp, "#00FF00", 0.3)); GMap7.addGMarker(marker1); this.GMap8.addPolygon(new GPolygon(extp, "#00FF00", 0.3)); GMap8.addGMarker(marker1); this.GMap9.addPolygon(new GPolygon(extp, "#00FF00", 0.3)); GMap9.addGMarker(marker1); this.GMap10.addPolygon(new GPolygon(extp, "#00FF00", 0.3)); GMap10.addGMarker(marker1); GMap1.Visible = true; GMap2.Visible = true; GMap3.Visible = true; GMap4.Visible = true; GMap5.Visible = true; GMap6.Visible = true; GMap7.Visible = true; GMap8.Visible = true; GMap9.Visible = true; GMap10.Visible = true; Table1.Visible = true; Table2.Visible = true; //clear form DropDownList1.SelectedIndex = 0; DropDownList3.SelectedIndex = 0; }//till here //*/ }
private void drawCircle2(double lat, double lng, double radius) { // globals //drawing the circle with the latitude and longitude var d2r = Math.PI / 180; // degrees to radians var r2d = 180 / Math.PI; // radians to degrees var earthsradius = 3963; // 3963 is the radius of the earth in miles var points = 32; //var radius = 10; double rlat = ((double)radius / earthsradius) * r2d; double rlng = rlat / Math.Cos(lat * d2r); List<GLatLng> extp = new List<GLatLng>(); for (var i = 0; i < points + 1; i++) { double theta = Math.PI * (i / (double)(points / 2)); double ex = lng + (rlng * Math.Cos(theta)); double ey = lat + (rlat * Math.Sin(theta)); extp.Add(new GLatLng(ey, ex)); } GIcon icon1 = new GIcon(); icon1.image = "/images/urhere2.png"; //icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png"; icon1.iconSize = new GSize(30, 30); icon1.shadowSize = new GSize(22, 20); icon1.iconAnchor = new GPoint(6, 20); icon1.infoWindowAnchor = new GPoint(5, 1); GMarkerOptions mOpts1 = new GMarkerOptions(); mOpts1.clickable = false; mOpts1.icon = icon1; GMarker marker1 = new GMarker(latlong, mOpts1); this.GMap11.addPolygon(new GPolygon(extp, "##FF0000", 0.3)); GMap11.addGMarker(marker1); //end of code for drawing circle with given lat long and radius //code for XML Retrieval using (reader1 = XmlReader.Create("C:/Users/Dheeraj Rampally/Desktop/dheeraj/SEM 2 ebooks/Query Processing/Project/yumi_web/yumi/xml/XMLFile1.xml")) { while (reader1.Read() && i1 <= l && j < l && k < l) { if (reader1.IsStartElement()) { switch (reader1.Name) { case "dictionary": break; case "item": break; case "key": break; case "string": if (reader1.Read()) { if (reader1.Value.Trim().Contains("Metromix")) { nn[k] = reader1.Value.Trim(); //Label1.Text = Label1.Text + reader.Value.Trim() + " "+"<br/>"; k++; } } break; case "value": break; case "ArrayOfPoint": break; case "Point": break; case "x": if (reader1.Read()) { xcoordinates[i1] = reader1.Value.Trim(); //Label2.Text += "xcoordinates[" + i1 + "]=" + reader.Value.Trim() + " " +"<br/>"; i1++; } break; case "y": if (reader1.Read()) { ycoordinates[j] = reader1.Value.Trim(); //Label3.Text += "ycoordinates[" + j + "]=" + reader.Value.Trim() + " " + "<br/>"; j++; } break; } } } }//end of code for the retrieval of XML coordinates //code snippet to draw a rectangle for (int z = 0; z <= 422; z=z+2)//looping through all the neighborhoods <=452 { for (int j2 = 0; j2 < 4; j2++)//looping through all the edges within a neighborhood { d2r = Math.PI / 180D; if (j2 == 0) { //Haversine's Formula dlong = (lng-double.Parse(xcoordinates[z])) * d2r; dlat = (lat-double.Parse(ycoordinates[z])) * d2r; a = Math.Pow(Math.Sin(dlat / 2.0), 2) + Math.Cos(lat * d2r) * Math.Cos(double.Parse(ycoordinates[z]) * d2r) * Math.Pow(Math.Sin(dlong / 2.0), 2); c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a)); d = 3956 * c;//3956 is radius of earth in miles } else if (j2 == 1) { //Haversine's Formula dlong = (lng-double.Parse(xcoordinates[z + 1])) * d2r; dlat = (lat-double.Parse(ycoordinates[z])) * d2r; a = Math.Pow(Math.Sin(dlat / 2.0), 2) + Math.Cos(lat * d2r) * Math.Cos(double.Parse(ycoordinates[z]) * d2r) * Math.Pow(Math.Sin(dlong / 2.0), 2); c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a)); d = 3956 * c; } else if (j2 == 2) { //Haversine's Formula dlong = (lng-double.Parse(xcoordinates[z])) * d2r; dlat = (lat-double.Parse(ycoordinates[z+1])) * d2r; a = Math.Pow(Math.Sin(dlat / 2.0), 2) + Math.Cos(lat * d2r) * Math.Cos(double.Parse(ycoordinates[z]) * d2r) * Math.Pow(Math.Sin(dlong / 2.0), 2); c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a)); d = 3956 * c; } else if (j2 == 3) { //Haversine's Formula dlong = (lng-double.Parse(xcoordinates[z+1])) * d2r; dlat = (lat-double.Parse(ycoordinates[z + 1])) * d2r; a = Math.Pow(Math.Sin(dlat / 2.0), 2) + Math.Cos(lat * d2r) * Math.Cos(double.Parse(ycoordinates[z]) * d2r) * Math.Pow(Math.Sin(dlong / 2.0), 2); c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a)); d = 3956 * c; } distance[j2] = d; //Label1.Text += distance[j2].ToString()+"<br/>"; } maxElement = distance[0];//code for retriving the min element in an array for (int i3 = 0; i3 < 4; i3++) { if (distance[i3] <maxElement) { maxElement = distance[i3]; //Label1.Text += "The minimum element is in loop" + x1 + "<br/>"; } } //x1 y2 x2 y1 x1 = double.Parse(ycoordinates[z]); //Label1.Text += x1+" "; x3=lat; //Label1.Text += x2+" "; x2 = double.Parse(ycoordinates[z + 1]); //Label1.Text += x3 + "<br/>"; if(x2<x3&&x3<x1) { c1=true; // Label1.Text+="c1"; } y1=(double.Parse(xcoordinates[z])); //Label1.Text += c2l + " "; y3=lng; //Label1.Text += c2m + " "; y2=(double.Parse(xcoordinates[z+1])); //Label1.Text += c2r +"<br/>"; if((y1>y3)&&(y3>y2)) { c2=true; // Label1.Text += "c2"; } //vertex falling under circle if (radius >= maxElement) { //code snippet to draw a rectangle if (z == 0) { //Label1.Text += nn[0]; neighborhood[0] = nn[0]; } else { //Label1.Text += nn[z / 2]; neighborhood[z / 2] = nn[z / 2]; } GPolygon rectangle = new GPolygon(); List<GLatLng> rectanglePts = new List<GLatLng>(); rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z]), double.Parse(xcoordinates[z + 1]))); rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z]), double.Parse(xcoordinates[z]))); rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z + 1]), double.Parse(xcoordinates[z]))); rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z + 1]), double.Parse(xcoordinates[z + 1]))); rectangle = new GPolygon(rectanglePts, "0000CD", 2, 2, "FCD116", 0.3); rectangle.clickable = true; rectangle.close(); GMap11.Add(rectangle); continue; } //circle lying inside neighborhood else if ((x2 < x3 && x3 < x1) && (y1 > y3 && y3 > y2)) { if (z == 0) { //Label1.Text += nn[0]; neighborhood[0] = nn[0]; } else { //Label1.Text += nn[z / 2]; neighborhood[z / 2] = nn[z / 2]; } GPolygon rectangle = new GPolygon(); List<GLatLng> rectanglePts = new List<GLatLng>(); rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z]), double.Parse(xcoordinates[z + 1]))); rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z]), double.Parse(xcoordinates[z]))); rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z + 1]), double.Parse(xcoordinates[z]))); rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z + 1]), double.Parse(xcoordinates[z + 1]))); rectangle = new GPolygon(rectanglePts, "0000CD", 2, 2, "FCD116", 0.3); rectangle.clickable = true; rectangle.close(); GMap11.Add(rectangle); continue; } // the circle and line intersection with vertex lying outside circle for (int j3 = 0; j3 < 4; j3++) { if (j3 == 0) { x4 = double.Parse(ycoordinates[z]); y4 = double.Parse(xcoordinates[z]); x5 = double.Parse(ycoordinates[z + 1]); y5 = double.Parse(xcoordinates[z]); } if (j3 == 1) { x4 = double.Parse(ycoordinates[z + 1]); y4 = double.Parse(xcoordinates[z]); x5 = double.Parse(ycoordinates[z + 1]); y5 = double.Parse(xcoordinates[z + 1]); } if (j3 == 2) { x4 = double.Parse(ycoordinates[z + 1]); y4 = double.Parse(xcoordinates[z + 1]); x5 = double.Parse(ycoordinates[z]); y5 = double.Parse(xcoordinates[z + 1]); } if (j3 == 3) { x4 = double.Parse(ycoordinates[z]); y4 = double.Parse(xcoordinates[z + 1]); x5 = double.Parse(ycoordinates[z]); y5 = double.Parse(xcoordinates[z]); } dx = x5 - x4; dy = y5 - y4; A = dx * dx + dy * dy; B = 2 * (dx * (x4 - lat) + dy * (y4 - lng)); C = (x4 - lat) * (x4 - lat) + (y4 - lng) * (y4 - lng) - Math.Pow(0.014513788,2)*radius * radius; det = B * B - 4 * A * C; double t, ix1, iy1,ix2,iy2; if ((A <= 0.0000001) || (det < 0)) { } else if(det==0) { t = -B / (2 * A); ix1 = x4 + t * dx; iy1 = y4 + t * dy; if ((x4 >= ix1 && ix1 >= x5) && (y4 <= iy1 && iy1 <= y5) || (x4 <= ix1 && ix1 <= x5) && (y4 >= iy1 && iy1 >= y5)) { if (z == 0) { //Label1.Text += nn[0]; neighborhood[0] = nn[0]; } else { //Label1.Text += nn[z / 2]; neighborhood[z / 2] = nn[z / 2]; } GPolygon rectangle = new GPolygon(); List<GLatLng> rectanglePts = new List<GLatLng>(); rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z]), double.Parse(xcoordinates[z + 1]))); rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z]), double.Parse(xcoordinates[z]))); rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z + 1]), double.Parse(xcoordinates[z]))); rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z + 1]), double.Parse(xcoordinates[z + 1]))); rectangle = new GPolygon(rectanglePts, "0000CD", 2, 2, "FCD116", 0.3); rectangle.clickable = true; rectangle.close(); GMap11.Add(rectangle); } } else { t = (-B + Math.Sqrt(det)) / (2 * A); ix1 = x4 + t * dx; iy1 = y4 + t * dy; t = (-B - Math.Sqrt(det)) / (2 * A); ix2 = x4 + t * dx; iy2 = y4 + t * dy; if((x4>=ix1&&ix1>=x5)&&(y4<=iy1&&iy1<=y5)&&(x4>=ix2&&ix2>=x5)&&(y4<=iy2&&iy2<=y5)|| (x4 <= ix1 && ix1 <= x5) && (y4 >= iy1 && iy1 >= y5) && (x4 <= ix2 && ix2 <= x5) && (y4 >= iy2 && iy2 >= y5)) { if (z == 0) { //Label1.Text += nn[0]; neighborhood[0] = nn[0]; } else { //Label1.Text += nn[z / 2]; neighborhood[z / 2] = nn[z / 2]; } GPolygon rectangle = new GPolygon(); List<GLatLng> rectanglePts = new List<GLatLng>(); rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z]), double.Parse(xcoordinates[z + 1]))); rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z]), double.Parse(xcoordinates[z]))); rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z + 1]), double.Parse(xcoordinates[z]))); rectanglePts.Add(new GLatLng(double.Parse(ycoordinates[z + 1]), double.Parse(xcoordinates[z + 1]))); rectangle = new GPolygon(rectanglePts, "0000CD", 2, 2, "FCD116", 0.3); rectangle.clickable = true; rectangle.close(); GMap11.Add(rectangle); } } } } for (int i = 0, x = 0; i < neighborhood.Length; i++) { if (neighborhood[i] == null) continue; else { shortListednn[x] = neighborhood[i]; shortListednn[x] = shortListednn[x].Substring(9); //Label1.Text += "ShortlistedNN " + x + "=" + shortListednn[x]; x++; } } for (int i = 0; i < Globals.hoods.Count(); i++) { for (int j = 0; j < shortListednn.Length; j++) { if (Globals.hoods[i].getName() == shortListednn[j]) { LocationList newHood = new LocationList(shortListednn[j]); newHood = Globals.hoods[i]; Globals.shortListedNeighborHoods.Add(newHood); } } } /* for (int i = 1; i < Globals.baba.Length; i++) { Globals.baba[i] = null; } for (int i = 0; i < Globals.shortListedNeighborHoods.Count(); i++) { for (int j = 0; j < Globals.shortListedNeighborHoods[i].getLocationsCount(); j++) { if (Globals.baba[Globals.shortListedNeighborHoods[i].getSearchEngineCodeForMapping(j)] == null) { Globals.baba[Globals.shortListedNeighborHoods[i].getSearchEngineCodeForMapping(j)] = Globals.shortListedNeighborHoods[i].getNeighborhood(j); continue; } Globals.baba[Globals.shortListedNeighborHoods[i].getSearchEngineCodeForMapping(j)]=Globals.baba[Globals.shortListedNeighborHoods[i].getSearchEngineCodeForMapping(j)]+","+Globals.shortListedNeighborHoods[i].getNeighborhood(j); } } */ for (int i = 0; i < Globals.shortListedNeighborHoods.Count(); i++) { for (int j = 0; j < Globals.shortListedNeighborHoods[i].getLocationsCount(); j++) { int k = Globals.shortListedNeighborHoods[i].getSearchEngineCodeForMapping(j); s1 += Globals.shortListedNeighborHoods[i].getNeighborhood(j) + k.ToString() + ","; //Label1.Text+= Globals.shortListedNeighborHoods[i].getNeighborhood(j) + k.ToString() +"<br/>"; } //Label1.Text += "<------------Next Set of Neighborhoods for new neighborhood--------->"+"<br/>"; } //Label1.Text = s1; char[] seps = { ',' }; childList = s1.Split(seps); //for (int i = 0; i < childList.Length - 1; i++) //{ // Label1.Text += childList[i] + "<br/>"; //} for (int i = 0; i < childList.Length - 1; i++) { //Label1.Text += childList[i]+"<br/>"; length = childList[i].Length; if ((childList[i].Substring(length - 1)) == "1") { Globals.metromixList[m] = childList[i].Substring(0, length - 1); //Label1.Text += "Metromix" +Globals.metromixList[m] + " " + "<br/>"; m++; } else if ((childList[i].Substring(length - 1)) == "2") { Globals.dexknowsList[d1] = childList[i].Substring(0, length - 1); //Label1.Text += "dexknows"+Globals.dexknowsList[d1] + " " + "<br/>"; d1++; } else if ((childList[i].Substring(length - 1)) == "3") { Globals.yelpList[y] = childList[i].Substring(0, length - 1); //Label1.Text += "yelp"+Globals.yelpList[y] + " " + "<br/>"; y++; } else if ((childList[i].Substring(length - 1)) == "4") { Globals.chicagoList[ch] = childList[i].Substring(0, length - 1); //Label1.Text += "chicagoreader"+Globals.chicagoList[ch] + " " + "<br/>"; ch++; } else if ((childList[i].Substring(length - 1)) == "5") { Globals.menuList[me] = childList[i].Substring(0, length - 1); //Label1.Text += "menu"+Globals.menuList[me] + " " + "<br/>"; me++; } else if ((childList[i].Substring(length - 1)) == "6") { Globals.menuPagesList[mp] = childList[i].Substring(0, length - 1); //Label1.Text += "menupages"+Globals.menuPagesList[mp] + " " + "<br/>"; mp++; } else if ((childList[i].Substring(length - 1)) == "7") { Globals.yahooList[ya] = childList[i].Substring(0, length - 1); //Label1.Text += "yahoo"+Globals.yahooList[ya] + " " + "<br/>"; ya++; } else if ((childList[i].Substring(length - 1)) == "8") { Globals.yellowList[ye] = childList[i].Substring(0, length - 1); //Label1.Text += "yellow"+Globals.yellowList[ye] + " " + "<br/>"; ye++; } else if ((childList[i].Substring(length - 1)) == "9") { Globals.cityList[ci] = childList[i].Substring(0, length - 1); //Label1.Text += "city"+Globals.cityList[ci] + " " + "<br/>"; ci++; } else if ((childList[i].Substring(length - 2)) == "10") { Globals.zagatList[za] = childList[i].Substring(0, length - 2); //Label1.Text += "zagat"+Globals.zagatList[za] + " " + "<br/>"; za++; } } Array.Resize(ref Globals.metromixList, m); Array.Resize(ref Globals.zagatList, za); Array.Resize(ref Globals.yellowList,ye); Array.Resize(ref Globals.yahooList, ya); Array.Resize(ref Globals.menuPagesList, mp); Array.Resize(ref Globals.menuList, me); Array.Resize(ref Globals.chicagoList, ch); Array.Resize(ref Globals.yelpList, y); Array.Resize(ref Globals.dexknowsList, d1); Array.Resize(ref Globals.cityList, ci); //for (int i = 0; i < Globals.dexknowsList.Length; i++) //{ // Label1.Text += Globals.dexknowsList[i]; //} }
private List<GPolygon> constructRectangles(List<List<Point>> cornersList, Rectangle type) { List<GPolygon> polygons = new List<GPolygon>(); foreach (List<Point> corners in cornersList) { List<GLatLng> rectanglePts = new List<GLatLng>(); rectanglePts.Add(new GLatLng(corners[0].y, corners[1].x)); rectanglePts.Add(new GLatLng(corners[0].y, corners[0].x)); rectanglePts.Add(new GLatLng(corners[1].y, corners[0].x)); rectanglePts.Add(new GLatLng(corners[1].y, corners[1].x)); if (type == Rectangle.TARGET) { GPolygon rectangle = new GPolygon(rectanglePts, "ffffff", 0, 0, "000080", 0.3); rectangle.clickable = true; rectangle.close(); polygons.Add(rectangle); } if (type == Rectangle.CHOSEN) { GPolygon rectangle = new GPolygon(rectanglePts, "0000ff", 2, 1, "ffffff", 0); rectangle.clickable = true; rectangle.close(); polygons.Add(rectangle); } if (type == Rectangle.NOTCHOSEN) { GPolygon rectangle = new GPolygon(rectanglePts, "ff0000", 2, 1, "ffffff", 0); rectangle.clickable = true; rectangle.close(); polygons.Add(rectangle); } if (type == Rectangle.YUMITARGET) { GPolygon rectangle = new GPolygon(rectanglePts, "0000ff", 2, 1, "ffffff", 0); rectangle.clickable = true; rectangle.close(); polygons.Add(rectangle); } } return polygons; }
private GPolygon constructRectangle(List<Point> corners, Rectangle type) { GPolygon rectangle = new GPolygon(); List<GLatLng> rectanglePts = new List<GLatLng>(); rectanglePts.Add(new GLatLng(corners[0].y, corners[1].x)); rectanglePts.Add(new GLatLng(corners[0].y, corners[0].x)); rectanglePts.Add(new GLatLng(corners[1].y, corners[0].x)); rectanglePts.Add(new GLatLng(corners[1].y, corners[1].x)); if (type == Rectangle.TARGET) { rectangle = new GPolygon(rectanglePts, "ffffff", 0, 0, "000080", 0.3); rectangle.clickable = true; rectangle.close(); } else if (type == Rectangle.CHOSEN) { rectangle = new GPolygon(rectanglePts, "0000ff", 2, 1, "ffffff", 0); rectangle.clickable = true; rectangle.close(); } else if (type == Rectangle.NOTCHOSEN) { rectangle = new GPolygon(rectanglePts, "ff0000", 2, 1, "ffffff", 0); rectangle.clickable = true; rectangle.close(); } else if (type == Rectangle.YUMITARGET) { rectangle = new GPolygon(rectanglePts, "0000ff", 2, 1, "ffffff", 0); rectangle.clickable = true; rectangle.close(); } return rectangle; }