private void AddPoint(IndexWriter writer, String name, double lat, double lng) { Document doc = new Document(); doc.Add(new Field("name", name, Field.Store.YES, Field.Index.ANALYZED)); // convert the lat / long to lucene fields doc.Add(new Field(LatField, NumericUtils.DoubleToPrefixCoded(lat), Field.Store.YES, Field.Index.NOT_ANALYZED)); doc.Add(new Field(LngField, NumericUtils.DoubleToPrefixCoded(lng), Field.Store.YES, Field.Index.NOT_ANALYZED)); // add a default meta field to make searching all documents easy doc.Add(new Field("metafile", "doc", Field.Store.YES, Field.Index.ANALYZED)); int ctpsize = _ctps.Count; for (int i = 0; i < ctpsize; i++) { CartesianTierPlotter ctp = _ctps[i]; var boxId = ctp.GetTierBoxId(lat, lng); doc.Add(new Field(ctp.GetTierFieldName(), NumericUtils.DoubleToPrefixCoded(boxId), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS)); } writer.AddDocument(doc); }
public void AddPoint(int id, string name, double lat, double lng, IndexWriter currentWriter) { EnsureDistanceMatrixReady(); var writer = currentWriter != null ? currentWriter : MakeWriter(true, IndexWriter.MaxFieldLength.UNLIMITED); Document doc = new Document(); doc.Add(new Field("name", name, Field.Store.YES, Field.Index.ANALYZED)); doc.Add(new Field("PostID", Convert.ToString(id), Field.Store.YES, Field.Index.UN_TOKENIZED)); // convert the lat / long to lucene fields doc.Add(new Field(LatField, NumericUtils.DoubleToPrefixCoded(lat), Field.Store.YES, Field.Index.NOT_ANALYZED)); doc.Add(new Field(LngField, NumericUtils.DoubleToPrefixCoded(lng), Field.Store.YES, Field.Index.NOT_ANALYZED)); // add a default meta field to make searching all documents easy doc.Add(new Field("metafile", "doc", Field.Store.YES, Field.Index.ANALYZED)); int ctpsize = _ctps.Count; for (int i = 0; i < ctpsize; i++) { CartesianTierPlotter ctp = _ctps[i]; var boxId = ctp.GetTierBoxId(lat, lng); doc.Add(new Field(ctp.GetTierFieldName(), NumericUtils.DoubleToPrefixCoded(boxId), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS)); } writer.AddDocument(doc); if (currentWriter == null) // if we're not using the passed along writer, which is supposed to be terminated by the caller, then end our new writer { FinishWriter(writer); } }
public Shape GetShapeLoop(Shape shape, CartesianTierPlotter ctp, double latX, double longX, double latY, double longY) { double beginAt = ctp.GetTierBoxId(latX, longX); double endAt = ctp.GetTierBoxId(latY, longY); double tierVert = ctp.TierVerticalPosDivider; double startX = beginAt - (beginAt % 1); double startY = beginAt - startX; //should give a whole number double endX = endAt - (endAt % 1); double endY = endAt - endX; //should give a whole number int scale = (int)Math.Log10(tierVert); endY = Math.Round(endY, scale, MidpointRounding.ToEven); startY = Math.Round(startY, scale, MidpointRounding.ToEven); double xInc = 1.0d / tierVert; xInc = Math.Round(xInc, scale, MidpointRounding.ToEven); for (; startX <= endX; startX++) { double itY = startY; while (itY <= endY) { //create a boxId // startX.startY double boxId = startX + itY; shape.AddBox(boxId); itY += Math.Round(xInc, scale, MidpointRounding.ToEven); } } return(shape); }
public void Set(string name, object value, Document document, Field.Store store, Field.Index index, float?boost) { var service = (Service)value; var location = service.Location; var lat = new Field("Location_Latitude", NumericUtils.DoubleToPrefixCoded(location.Y), Field.Store.YES, Field.Index.NOT_ANALYZED); var lng = new Field("Location_Longitude", NumericUtils.DoubleToPrefixCoded(location.X), Field.Store.YES, Field.Index.NOT_ANALYZED); document.Add(lat); document.Add(lng); document.Add(new Field("metafile", "doc", Field.Store.YES, Field.Index.ANALYZED)); int ctpsize = Ctps.Count; for (int i = 0; i < ctpsize; i++) { CartesianTierPlotter ctp = Ctps[i]; var boxId = ctp.GetTierBoxId(location.Y, location.X); document.Add(new Field(ctp.GetTierFieldName(), NumericUtils.DoubleToPrefixCoded(boxId), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS)); } }