//*********************************************************************** // pj_gc_readentry() // // Read one catalog entry from the file. // // Format: // gridname,ll_long,ll_lat,ur_long,ur_lat,priority,date //*********************************************************************** static bool pj_gc_readentry(projCtx ctx, StreamReader fid, out PJ_GridCatalog.Entry entry) { entry = new PJ_GridCatalog.Entry(); string[] tokens = pj_gc_read_csv_line(ctx, fid); if (tokens == null || tokens.Length < 5) { if (tokens.Length != 0) { Proj.pj_log(ctx, PJ_LOG.ERROR, "Short line in grid catalog."); } return(true); } entry.definition = tokens[0]; entry.region.ll_long = Proj.dmstor_ctx(ctx, tokens[1]); entry.region.ll_lat = Proj.dmstor_ctx(ctx, tokens[2]); entry.region.ur_long = Proj.dmstor_ctx(ctx, tokens[3]); entry.region.ur_lat = Proj.dmstor_ctx(ctx, tokens[4]); if (tokens.Length > 5) { int.TryParse(tokens[5], out entry.priority); // defaults to zero } if (tokens.Length > 6) { entry.date = pj_gc_parsedate(ctx, tokens[6]); } return(false); }
//********************************************************************** // pj_c_findgrid() //********************************************************************** public static PJ_GRIDINFO pj_gc_findgrid(projCtx ctx, PJ_GridCatalog catalog, bool after, LP location, double date, ref PJ_Region optimal_region, ref double grid_date) { for (int i = 0; i < catalog.entries.Count; i++) { PJ_GridCatalog.Entry entry = catalog.entries[i]; if ((after && entry.date < date) || (!after && entry.date > date)) { continue; } if (location.lam < entry.region.ll_long || location.lam > entry.region.ur_long || location.phi < entry.region.ll_lat || location.phi > entry.region.ur_lat) { continue; } if (entry.available == -1) { continue; } grid_date = entry.date; if (entry.gridinfo == null) { int grid_count; PJ_GRIDINFO[] gridlist = pj_gridlist_from_nadgrids(ctx, entry.definition, out grid_count); if (grid_count == 1) { entry.gridinfo = gridlist[0]; } } return(entry.gridinfo); } grid_date = 0.0; optimal_region = new PJ_Region(); return(null); }